Integrating Atlas Scientific Wi-Fi Hydroponics Kit to Home Assistant
by vessosa in Workshop > Hydroponics
3258 Views, 3 Favorites, 0 Comments
Integrating Atlas Scientific Wi-Fi Hydroponics Kit to Home Assistant
The Atlas Scientific Wi-Fi Hydroponics Kit reads pH, Conductivity, and temperature and has an Arduino module that can send data to any external server. By default the company supports ThingSpeak, but I was able to integrate it with Home Assistant (https://www.home-assistant.io/) adding monitoring and automation to your hydroponic gardens. Here's how i did it
Supplies
- Atlas Scientific Wi-Fi Hydroponics Kit - https://atlas-scientific.com/kits/wi-fi-hydroponics-kit/
- A Home-Assistant running a Mosquitto broker service (you should be able to do it easily with a simple Raspberry pi - https://www.home-assistant.io/getting-started/)
Home Assistant and Mosquitto Broker
First, be sure to have installed Mosquitto broker to your home assistant.
To be sure, go to your main page > Configuration > Devices & Services > and look for Mosquitto broker.
If you don't have it, please install following the instructions at: https://www.home-assistant.io/docs/mqtt/broker/
Preparing Wi-Fi Hydroponics Kit
Check out the library for Atlas Scientific EZO devices in I2C mode at https://github.com/Atlas-Scientific/Ezo_I2c_lib/pull/16. This is a branch that I have prepared to add support to MQTT for home assistant.
After that, use your favorite editor and open Examples/IOT_kits/hydroponics_kit_mqtt/hydroponics_kit_mqtt.ino
You need to change the following variables:
- ssid (The name of the Wi-Fi network you are connecting to)
- pass (Your WiFi network password)
- MQTT_KEY (Your MQTT server password)
The last variable, MQTT_KEY, you can retrieve it by opening Home Assistant > Configuration > Devices and Services > Moskito broker > Configure > Re-Configure MQTT > Copy password.
Upload to Arduino
Open you Arduino IDE and follow the instructions from Atlas Scientific to add your board and open the project that you have checked out from github (https://files.atlas-scientific.com/Wi-Fi-Hydroponics-kit-setup-guide.pdf).
It's necessary to install the MQTT libraries, to do that, using Arduino IDE, click under Tools > Manage Libraries...
Search for "Adafruit MQTT Library" and click Install.
Next just click to Upload and follow what's going on over Tools > Serial Monitor.
If everything is fine you should see logs showing the TEMP/EC/PH values and also something like "Sending data to mqtt".
Checking If Home Assistant Can Receive Data
At this moment, if everything is fine, Home Assistant backed by Mosquito MQTT Broker should be already receiving the data from your Wi-Fi kit.
To check that, open Home Assistant > Configuration > Devices and Services > Moskito broker > Configure.
Then over Listen to a topic, enter one of the following topics and check if you can see any data coming by clicking at "Start Listening":
- sensors/hydroponics-kit/ph
- sensors/hydroponics-kit/temp
- sensors/hydroponics-kit/ec
Configuring Home Assistant Dashboard
First of all, you need to configure some sensors on Home Assistant.
Todo that, Click at File editor, then open /config/configuration.yaml
At the of the file, add the following configuration:
sensor: - platform: mqtt state_topic: 'sensors/hydroponics-kit/ph' name: 'PH' value_template: "{{ value_json }}" unit_of_measurement: 'PH' - platform: mqtt state_topic: 'sensors/hydroponics-kit/temp' name: 'Temperature' value_template: "{{ value_json | float }}" unit_of_measurement: '°C' - platform: mqtt state_topic: 'sensors/hydroponics-kit/ec' name: 'EC' value_template: "{{ value_json / 1000 }}" unit_of_measurement: 'µS/cm' - platform: mqtt state_topic: 'sensors/hydroponics-kit/ec' name: 'EC (TDS)' value_template: "{{ value_json /1000 * 500 }}" unit_of_measurement: 'TDS'
Save, and restart Home Assistant to apply the configuration.
Next, let's add the components to the dashboard, this will be up to you, but I like to create a new view, to do that, follow the instructions below:
- Click at the three dots, and then Edit Dashboard
- Click in the + (Add view)
- Click at Add Card
- Select Entities, and configure the entities like in the picture attached. You will be able to visualize all the current data, including the history of the data sent.
Feel free to add other panels, an RTSP camera, switches, and automation.
Some ideas:
- Add a light/aerator switch and automate it to turn on and off at specific times
- Add a camera that takes pictures every day at a particular hour and send them to your Telegram. Or make a timelapse video: https://youtu.be/gw-thrd6vyw
- Add a pump that will release doses of nutrient or PH reducer to the water (We could use the Wi-Fi kit for that)
- Send Telegram messages if some EC or PH value goes to an out-of-range value.
- Etc.
I hope that you liked and feel free to comment and ask questions!