For my ongoing heating project I needed to be able to communicate with different nodes around the house. Wirelessly.
To accomplish this objective, I decided to use some NRF24LO1+ modules. These are great because they have an onboard chip so that you don’t have to encode/decode the data yourself. The range on them is pretty good - ‘proper’ testing this w/e! - I got two without antennae and one with one - this is going to be the hub on a RPi so the range needed to be further (apparently someone got the to work over a distance of 1km!).
First, the Raspberry Pi side. I hooked up the RF module and wrote this script: https://github.com/xavbabe/heating/blob/master/monitor.py What it does is to:
- Setup MySQL database connection
- Setup Google Spreadsheet connection
- Setup the radio
- Get the external temperature
- Ask the Arduino for the temperature and checks that back against last saved temperature
- Tells the Arduino what to do based on the data
- Dump all results into MySQL database and Google Spreadsheet
I wired up the RF module to it and wrote and uploaded this:
https://github.com/xavbabe/heating/blob/master/arduino/arduino.ino
What this one does is to:
- Wait for the RPi to ask for the temperature
- Send the temperature back to the RPi for processing
- Wait for instructions
- Turn on/off the heating based on what instructions it received