-
Notifications
You must be signed in to change notification settings - Fork 0
Raspberry Pi
To control the Humidifier, we do need a physical device. My Humidifier (Like most) require a dry connection between the Ground and signal wire, when those 2 are connected the unit start, when they are disconnected the unit stop.
As an example, this is my device. Connection can be achieved with a simple wire connector.
I will replace the Wire connector by a Raspberry pi + Relay hat that will manage the connection automatically. To do this I will use:
- Rapsberry pi 2B
- Relay Hat
Then I will connect the 2 wires (ground and signal) on one of the 3 Relay (I picked the 1st one) on the normally open circuit. _This imply, that when the pi is off, or that Tefnut is not running, the Relay will be open, in other words, the Humidifier will NOT work)
This is what it will look like
- Install Raspberry pi OS
- Install required software
# update pi
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install pip3 git python3
# Install poetry
curl -sSL https://install.python-poetry.org | python3 -
# get the code
git clone [email protected]:marcolivierarsenault/tefnut.git
cd tefnut
# install dependencies
poetry install
# copy configs
cp _template.settings.toml settings.toml
Configure config file Configuration
# run program
poetry run gunicorn --threads=2 -b 0.0.0.0:5000 main:app
# run the script even if logout of ssh
nohup poetry run gunicorn --threads=2 -b 0.0.0.0:5000 main:app &
Optionally you can turn the python script in a Linux service. To do this:
- Create service file
sudo vi /lib/systemd/system/tefnut.service
[Unit]
Description=Tefnut
After=multi-user.target
[Service]
WorkingDirectory=/home/marco/tefnut
ExecStart=/home/marco/.local/bin/poetry run gunicorn --threads=2 -b 0.0.0.0:5000 main:app
User=marco
KillSignal=SIGINT
Restart=always
RestartSec=300
[Install]
WantedBy=multi-user.target
- Configure the service
sudo systemctl daemon-reload
sudo systemctl enable tefnut.service
sudo init 6 # Reboot
- After reboot, verify it is working:
journalctl -u tefnut.service
sudo systemctl status tefnut.service
Port 80 is blocked by the os, and tefnut uses port 5000. If you want to forward the traffic from port 80 you can set an internal rule in the pi:
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5000