Update on progress in farmbot-py and some challenges

Hey all,

I’ve posted some time ago on the topic of our own custom Python client (https://github.com/xebia/farmbot-py). Since one of us had to go off and get married our project was on hold for a while, but we’re on a roll again!

The client has been refined a bit more, and runs well against the 7.0.1 version (we can’t get version 8 to work - more about that later). The library is still for people who know their way around a Python IDE, we’ll look at easy deployment and install at a later time.

  • added logging
  • can check if a tool is mounted based on what is returned in the /logs channel
  • some API improvements, like:
    • watering a zone based on a set of rectangular coordinates,
    • single reset command to reset lights, pumps and go home in one go,
  • fixed unit tests, may add more

I’m somewhat proud of the simplicity of the scripts at the moment. To water all 6 zones in our bed all we need is this, combined with settings in the config file:

from farmbot.bot import create_farmbot, Axis
from farmbot.config import ToolBay
from farmbot.log import configure_logger

bot = create_farmbot('./config.json')
cfg = bot.cfg
configure_logger(cfg)
try:
    bot.set_lights(True)
    bot.go_home(Axis.all)
    if not bot.tool_mounted():
        bot.pick_up_tool(ToolBay.Watering_Nozzle)

    bot.water_zone(cfg.zones["6"], -250)
    bot.water_zone(cfg.zones["5"], -200)
    bot.water_zone(cfg.zones["3"], -200)
    bot.water_zone(cfg.zones["4"], -250)
    bot.water_zone(cfg.zones["2"], -250)
    bot.water_zone(cfg.zones["1"], 0)

    bot.return_tool(ToolBay.Watering_Nozzle)
    bot.reset()
    bot.blink_lights(3)
finally:
    bot.stop()

Now for the challenges.

  1. The biggest one is robustness in the face of communications- or any other failure.
    1a) The farmbot sometimes just stops responding and needs a restart, or messages get lost or don’t get sent. In one instance this happened just when the water was turned on, so it was good we were around to shut it down or we’d have flooded the plant bed :slight_smile:
    1b) The other issue is re-entrance. When a sequence is half way, on a restart we need to recover from that point in some way. Redoing the whole program is not always feasible. As of yet we still have to figure out what information we can use to determine the current status and position of the bot and base any further actions from that point forward.
    1c) On returning to work with the bot we found that there now is a flooding protection on the MQTT server because of frequent reconnects… which unfortunately is done by the Farmbot OS itself when it borks and restarts. We’ll need to talk this over with the Farmbot pplz, but it’s a good case of what a client needs to be robust against. Whatever the solution, robustness means dealing with situations like this. Reality will always throw a spanner in somewhere :slight_smile:

  2. Planting seeds is still currently more a hardware challenge than it is a software issue, so testing that is still a bit iffy.

  3. A general challenge for all farmbot users is better detection and optical recognition stuff to allow the bot to make smarter decisions. I’ve personally looked at OpenCV and it’s a bit above my mathematical experience, so it would be great if someone in the community could just provide easily usable algorithms for plant detection etc.

  4. Height detection. In our experience the bot kills little plants when it waters because the water stream is so powerful. We’ve found that short bursts from the lowest possible height works pretty well, but we need to code the height in the scripts at the moment: there is no “height of whatever is under the tool mount” sensor at the moment. Other options would be a diffferent shower head or a lower power pump, but that’s a bit more involved than we have time for at the moment: our expertise is software, not hardware :slight_smile:

  5. Getting version 8 to run. As far as we can see version 8 borks on us because it can’t find the update server. Needs looking into.

If anyone ever wants to use our code, please contact us directly so we can support you in setting things up. I’m aware that the documentation still needs work :slight_smile:

3 Likes

@sbeaumont I’m glad to see you are working on it again.

I’m forwarding the FBOS v8 update issues to @connor for review- thanks for letting us know about it. Thanks for your patience (and help!) while we transition FBOS v8 out of beta status. As a temporary workaround, you could try re-flashing / configurating your device directly from an image on the releases page.

it was good we were around to shut it down or we’d have flooded the plant bed

The “pin guard” feature will help prevent this. We are updating our documentation now to make users more aware of this feature. I will send you the link when it is available.

there now is flooding protection on MQTT … unfortunately is done by the Farmbot OS itself

This issue was likely fixed in v8. Our best way forward would be to solve the v8 update issue and see if that helps. Unfortunately, this flooding protection was put in place to prevent real-world/system-wide service degradations. I would be happy to take a look at your logs via private message, but I am under the impression that this was already fixed in v8.

1 Like

@sbeaumont We’ve updated the docs based on your feedback. Please see https://software.farm.bot/v8/docs/hardware-settings#section-pin-guard

The pin guard feature provides an extra layer of safety to your FarmBot in the event of a software malfunction in FarmBot OS or a disruption in connectivity. When a pin guard is set, the firmware will automatically set the selected PIN NUMBER to the selected STATE after the TIMEOUT is reached. For example, the pin connected to your solenoid valve could be set to automatically turn off after 60 seconds. This would prevent flooding your garden if you manually turned the water on and then connectivity between your web browser and the FarmBot cut out, preventing you from turning the water off on your own.

Nice! Is this already in v701? Edit: ah, indeed, found it. Nice!

Getting a 404 on the link BTW: it seems you haven’t published v8 docs to the public. It’s not in the list of versions to choose.

Oh and just to be clear: we flashed the v8 on a card, and on installing expected the farmduino to be updated accordingly. In the logs it seems that it times out on the URL it tries to pull the update from, which is the farmduino part…?

@sbeaumont Whoops! We have updated the v8 docs to be public. Thanks.