FB and openhab integration

Hi folks,

@Ascend and I are currently playing around to use FB with openhab via MQTT. As this seems to very promising because it can make up for all the currently missing features for decision making and weather sensors, did anyone else already try?

Cheers
Klim

2 Likes

For everyone interested and those who don’t not know what OpenHAB is and what its capable of, here is a short description with my first draft.

Most popular smarthome systems are operating in their own language which makes it impossible to integrate devices that are not specially made for this system. OpenHAB was made to change that and integrate different home automation systems into one system, so you can even combine devices that are made by a different manufacturer or communicate via different communication protocols.
A more detailed description can be found on their homepage https://www.openhab.org/introduction.html.

I started this project almost a month ago. It teached me a lot about the communication structures that FarmBot is using and was really fun. There is still a lot of work of binding more sensors, actors, APIs and improve the visuals of the panel.

The OpenHAB webserver is running on a raspberry pi 3. Temperature and humidity are measured by two DHT22 sensors (in greenhouse and outside) and stored in a mysql DB and shown in a chart. Solar stats contain a 5A current sensor and a voltage divider to track the state of the solar battery. If the battery gets low, the system automatically switches to a 24V power supply until the battery is fully recharged. The water level in the water barrel is tracked by a simple ultrasonic sensor and displayed in liters. All sensor are connected to a NodeMCU board which sends the raw sensor values via MQTT to OpenHAB.
The weather forecast is an external API (weatherunderground) which is updated every 15 minutes. Those forecast information can be used for FarmBot decision making, but since my FarmBot is inside a greenhouse this feature is not that interesting for me.



Thanks @RickCarlino and @Gabriel for your patience and help in my trouble thread. I really appreciated that :blush:

3 Likes

@Ascend I love it! Please keep us posted on developments! I’m glad to hear you were able to get everything up and running.

Hey folks,

today i managed to store the soil moisture sensor data in the InfluxDB as soon as a measurement is made, which is quite great!

The last days I implemented and played around with decision finding if the bot needs to water or not based on weather underground probabilities of rain today and tomorrow and the precipitation forecast. So far I programmed sequences to mount and store water and soil sensor tool and the next step is to mix all together and decide if it should water or not based on the forecast for rain and the soil moisture measurement… I am very excited about it!!! Keep you posted…

4 Likes

Hey @Ascend how is this project going? Is it possible to read Farmduino pins (or what’s sent to them) using openhab?

Hey @whitecaps
Openhab can communicate with farmbot by using mqtt or http requests. For reading Farmduino pins you could track the logs and set a variable to the last changed state, but thats really unstable and unsafe I guess. But with the new ASSERTIONS function at farmbot itself, you can check the state or value of the pin and report it if needed to the Openhab.

Thanks @Ascend have you used it with Farmbot Events? Just wondering if you could trigger an event based on a specific date time schedule which would call a sequence to make the pin change and also notify openhab via mqtt? My main driver is to do this over wifi to remove cables.

I’m still mostly using the functions that are provided by my.farmbot.io, but you could do a lot of things from Openhab like triggering sequences at specific decisions. For example you could trigger a sequence every day at 8 pm that changes or toggles a pin. Pin states can be read easily through mqtt, so you could check if the pin state really changed after a few seconds. If that didn’t change for any reason, you can send an e-stop to the device and send a notification message at your smartphone indicating that something went wrong there.

Which cables are you planning to remove?

Have you had to write a lot of code to get your data into OpenHab or is it mostly configuration?

I have a relay box with a very long cable for grow lights. I have also found the output from the Farmduinos digital pins is very noisy and needs to be cleaned up to provide a good signal to the relay. The solution I’m using at the moment is attaching the relay to the servo pins which give a clean signal but I may want to use those in the future. So keen to try and unplug the relay from the Farmbot and use OpenHab on an R pi to control it. Also keen to explore more about OpenHab as you guys have done.

It was mostly configuration and only a few additional scripts. Always depends on how deep you need to get into the functions of OpenHab/Farmbot.

In this case you won’t necessarily need a connection between FarmBot and Openhab right? Or is the controlling of the growing lights based on any FarmBot states?

I would prefer to use Farmbot to control as much as possible and have OpenHab as a visualisation/Integration tool. But you are right you could hand control of the relay over to openhab. I am going to have a think and look at a few other options just to cover my bases.

As always thanks @Ascend!

You could also set up a simple and cheap ESP8266 device (recommending a NodeMCU board) that communicates with your FarmBot device over mqtt in your WiFi network. But thats not as easy on FarmBot side as this would require to write a custom farmware that sends out the mqtt commands. Also this does not provide a visualization in any way.

1 Like