This is a simple sketch for temperature and humidity wireless sensor based on MySensors library. For more info about the requirements, please read on.
The shetch is intended for Arduino compatible board Devduino v2.0. The board comes with MCP9700 chip, which is an analog temperature sensor. This sketch also uses digital temperature and humidity sensor DHT22 and/or sensor HTU21/SHU21for maximum precision. The sensor node is wireless, and uses the nRF24L01+ wireless module for communication with sensor gateway.
Library dependencies are handled by PlatformIO. For the complete list, please see platformio.ini file inside the repository.
The sketch does not have the node ID set. Its assignment is left up to MySensors library. If you want to hardcode node ID, uncomment and define the MY_NODE_ID
in the sketch. The shetch also uses the default settings of MySensors library for the nRF24L01+ module (like channel, etc.). The sensor node wakes up from sleep every 5 minutes after sending all values to the gateway. To change this, redefine the SLEEP_TIME
to different value in milliseconds.
To choose connected sensors, just comment out one of the following lines in the sketch:
// Comment out if you don't want to use these sensors
#define WITH_SENSOR_DHT22 // connected to the DIGITAL connector
#define WITH_SENSOR_MCP9700 // on board
#define WITH_SENSOR_HTU21 // connected to the I2C connector
- Initialization of the sensor node
- Send the sketch info to the gateway
- Present all connected sensors
- Sensor ID 0 - DHT22 sensor humidity
- Sensor ID 1 - DHT22 sensor temperature
- Sensor ID 2 - MCP9700 sensor temperature
- Sensor ID 3 - HTU21 sensor humidity
- Sensor ID 4 - HTU21 sensor temperature
- Each 5 minutes do the following:
- send battery level in percents
- send DHT22 sensor humidity
- send DHT22 sensor temperature
- send MCP9700 sensor temperature
- send HTU21 sensor humidity
- send HTU21 sensor temperature
- go to sleep