@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?
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
@Ascend I love it! Please keep us posted on developments! I’m glad to hear you were able to get everything up and running.
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…
Hey @Ascend how is this project going? Is it possible to read Farmduino pins (or what’s sent to them) using openhab?
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.
Very intersting post, as usual
I’m planning to connect my FB to a small solar battery next year, to get rid of the 30m power cable that goes from my terrace through the garden to the FB.
I was thinking how to solve the task to shutdown FB if the solar battery gets low to avoid damages to the SD card. The idea to control that via OH is great (I already use OH2 for house automation).
Do you have any experiences / hints what I need to buy / assemble to send the solar battery status to OH without a network cable?
- Are there any PV inverters with a WiFi modul that can send their status via WiFI network?
- Or would you use the Arduino to measure that and signal it via MQTT?
Do you have a working solution for this?
Can you provide any sample how to connect to FB message broker from OH2?
I am able to connect to my FB from OH2 now via mqtt. I can read the logs or the status, everything works fine.
Now I am playing around with publishing a message to the bot via MQTT, currently I’m using mqtt-spy to send a test command (sample taken from the Software docu), but every time I send a message, afterwards FB does not respond any more to the web app and I need to reboot.
Anyone has an idea about that?
Does the Farmbot react to your command? I was using the mqtt plugin yesterday to try out the publish function and it was working fine. I’m not familiar with mqtt-spy as I am using mqtt.fx for testing and troubleshooting. You are also receiving messages from the bot through mqtt-spy or do you just use it for publishing?
subscribing works fine, with mqtt-spy and OH. But when I tried to send a test command FB gets unresponsive after confirming the command.
maybe I try mqtt.fx then…
do you have a sample for a “publish command” from OH?
Or did you also try to call FB via http instead of mqtt from OH?
mqtt.fx worked fine, and now I pushed my first command to FB via MQTT.
How do you implement pushing commands, with a rule like this:
rule "Farmbot power off"
Item mqtt_fb_poweroff received command OFF
logInfo("RULE", "--> Farmbot power off")
val mqttActions = getActions("mqtt","mqtt:broker:farmbot")
or do you know a better way, like configuring the command json directly in the item?
Glad that it worked, even if I am curious what could have caused your bot to be that confused …
Since I only use 6 commands that are published over mqtt (sync, e-stop, unlock, homing, trigger water sequence, updateOS) I go the same way as you. You could also work with variables so you only need that json formatted block only once and only change the arguments.
Hi @Ascend, do you mean to provide the json block in a script file with parameters, and re-using it from there and setting the correct parameter values?
Can you provide a sample?
Unfortunately I’ve started to set up my OH on a new device with all the updates and newest versions. Right now I’m struggling setting up the MQTT 2.5 mostly with the same issues that you described in your OH Forum post (Autodiscovery etc.). I’ll try to get more into the publish action as soon as I’ve made progress setting everything up as it worked in my MQTT 1.x setup.