- Raspberry PI Zero 2W (any PI should work ok)
- nodemcu-32s
- USB OTG Cable, Power Supply, etc...
- Flash the OS into the SD card (32gb is plenty) (Config: Username, Wifi and SSH)
- Connect the i2c RTC module to the rpi
- Connect the USB OTG cable from the raspberry pi to the nodemcu-32s
- Boot the raspberry pi (first time takes time to expand fs and setup)
- First time boot: make sure the os is up to date
sudo apt-get update
andsudo apt-get upgrade
- Intall the
at
commandsudo apt-get install at
- Check for usb to serial device under
/dev/ttyUSBX
whereX
is usually 0, this utility python script can be used to find the first available ttyUSB device regardless of the number - Setup PI i2c hardware clock
- Install
curl -fsSL https://tailscale.com/install.sh | sh
- Configure
sudo tailscale up
- Download plataformio cli tool here
Is a good idea to use set the path: Edit
$HOME/.profile
add this at the botom:
# set PATH so it includes plataformio if it exists
if [ -d "$HOME/.platformio/penv/bin" ] ; then
PATH="$HOME/.platformio/penv/bin:$PATH"
fi
- Cd to
/
and clone the repogit clone https://github.com/maggiben/smart-green.git
try not to useroot
user
do not try to compile the code in a raspberry pi zero 2w because it will hang, compile the code elsewhere and deploy using this tool
build-and-deploy.sh
to upload the compiledfirmware.bin
andfirmware.elf
to the target raspberry pi system, to use the tool, setup variablesRASPBERRY_PI_USER
,RASPBERRY_PI_IP
andREMOTE_PATH
to you desired user, destination ip and firmware path for plataformio
- Set the date on the nodemcu:
python3 serial-ping.py -m set-rtc:$(date +"%Y-%m-%dT%H:%M:%S")
- Check the time:
python3 serial-ping.py -m time
- Set the alarms on the nodemcu:
python3 serial-ping.py -m 'set-alarms:{"alarm":[[{"id":0,"weekday":2,"hour":19,"minute":30,"status":1},{"id":0,"weekday":2,"hour":19,"minute":31,"status":1}],[{"id":1,"weekday":8,"hour":19,"minute":30,"status":1},{"id":1,"weekday":8,"hour":19,"minute":31,"status":1}],[{"id":2,"weekday":64,"hour":19,"minute":30,"status":1},{"id":2,"weekday":64,"hour":19,"minute":31,"status":1}]]}'
- Set the planst on the nodemcu:
python3 serial-ping.py -m 'set-plants:{"plants":[{"id":0,"size":10,"status":1},{"id":1,"size":18,"status":1},{"id":2,"size":18,"status":1},{"id":3,"size":18,"status":1},{"id":4,"size":18,"status":1},{"id":5,"size":18,"status":1},{"id":6,"size":18,"status":1},{"id":7,"size":18,"status":1},{"id":8,"size":18,"status":1},{"id":9,"size":18,"status":1},{"id":10,"size":18,"status":1}]}'
- Get the time untill the next alarm
python3 serial-ping.py -m next-alarm
- Reset Task Values
python3 serial-ping.py -m reset-task
- Check the total watering time
python3 serial-ping.py -m get-watering-time
here: link