Last year I introduced an automatic watering system for a greenhouse with scheduled watering but I wanted to improve the setup with on-demand watering, only when the humidity of soil actually decreases below a threshold.
Hardwario already has a great, already preconfigured, box with a Soil Sensor module, but the greenhouse was too far away from the Radio dongle, and I wanted to use the LoRa network for quite a long time, so this was a needed push.
The original Plastic Enclosure, which came with a Soil Sensor has a 5 cm height that was too small to fit the LoRa module inside. So I found another box from ABB with a 8 cm height to fit everything inside. Also, the 3D-printed platform to hold a Battery module that came with the original box didn't fit in a higher box I bought, so I modeled a similar platform. If someone would be interested to reuse this, the part number of ABB box is 00851 and 3D model is available on Tinkercad.
Stock firmware uses Radio communication with a Radio module to send humidity data, so I started with that firmware and ported it to use LoRa instead of Radio protocol. Updated firmware is on my Github.
While I was writing a LoRa port of the firmware I also got an idea that in addition to just a sending humidity and temperature data it would actually be handy to know if the door to greenhouse is open or not (and use this information to trigger a notification). Reed magnet can be connected to a GPIO PIN 9 and thestate of the PIN is sent in LoRa message and any change of a state will also trigger a new message to be sent to the network (with a respective header).
As a network backend, I am using The Things Network and in addition to receiving raw payload from the network, you can also use Javascript decoder function for human-readable values.
Connecting to Home AssistantThe Things Network (TTN) has native support for MQTT protocol therefore hooking it up with existing Home Assistant instance was easy, I just needed to create a bridge between my Mosquitto MQTT broker and the one provided by TTN.
The bridge can be created e. g. by placing this to a /etc/mosquitto/conf.d/ttn.conf file:
connection ttn
address eu.thethings.network
remote_username greenhouse_monitor
remote_password <PASSWORD FROM TTN Console>
topic +/devices/+/up in
Then just adding a few MQTT sensors in Home Assistant config:
- platform: mqtt
state_topic: 'greenhouse_monitor/devices/soil/up'
name: "[Greenhouse] Temperature"
unit_of_measurement: "°C"
value_template: '{{ value_json.payload_fields.soilSensors[0].temperature }}'
- platform: mqtt
state_topic: 'greenhouse_monitor/devices/soil/up'
name: "[Greenhouse] Humidity"
unit_of_measurement: ""
value_template: '{{ value_json.payload_fields.soilSensors[0].humidity }}'
binary_sensor:
- platform: mqtt
state_topic: 'greenhouse_monitor/devices/soil/up'
name: "[Greenhouse] Door"
value_template: '{{ value_json.payload_fields.door }}'
device_class: door
payload_on: "open"
payload_off: "closed"
And status is now visible in the dasboard.
Comments