How can I show Arduino sensor data in the FarmBot Web App?

Hi everyone! I’m new to FarmBot and coding :sweat_smile:
I’m trying to use FarmBot Genesis v1.2 to grow Wolffia (duckweed) and I want to add some custom sensors.

I connected several sensors to an Arduino Nano, including:

  • Water temperature (DS18B20)
  • Light sensor (BH1750)
  • Air humidity/temp (DHT22)
  • Water pH and TDS sensors

The Nano sends data via USB Serial to the Raspberry Pi that runs FarmBot OS.

Now I want to show these sensor readings in the FarmBot Web App when I press the “Read Sensor” button.

:pushpin: I’m not very familiar with Elixir or FarmBot OS internals, so I’d like to ask:

  1. Is it possible to make FarmBot OS read data from the Arduino via serial?
  2. Has anyone done something similar and gotten the values into the Web App?
  3. Are there any guides or repos for this kind of setup?

Thanks in advance! :pray:
Any tips, examples, or beginner-friendly advice would be very appreciated.

Hi @Butbaz

Yes.

Not that I’ve noticed [I’m not a ‘power user’ but I do have some familiarity with the FBOS internals] . . Have you searched this forum ?

The FarmbotOS code itself will actually use /dev/ttyUSB0 to talk to the Arduino RAMPS setup in Genesis V1.2 models, so your application can certainly be realized.

There is a (deprecated) Python 3.11 execution environment still there in the latest FBOS but not exactly safe or simple to use :slight_smile:

Elixir/Erlang are your friends for this sort of integration, but it’s a rather steep learning curve to begin building your own FarmbotOS versions and to understand where your Nano-handling code should live, etc. I can help with the Elixir code which does the New Sensor Reading (which sends the sensor reading to the WebApp to be stored).

** edit **

I should have mentioned that there is a Lua interface to UARTs on FarmbotOS.
Sidecar Hardware | FarmBot Developer Documentation
I haven’t used it but seems it might help you.

There is also a Lua function to create your new Sensor Reading :yum:
Pins | FarmBot Developer Documentation
In that sample code you would not use Lua read_pin() function but instead your own function which gathers values from the serial Nano feed.

I would like to know if it’s possible to use a language that’s easier than Erlang or Elixir. For example, using an ESP32 board to connect to a device, and then linking it to a Nano board or a Raspberry Pi.

Hi @xImTonG

Yes, FarmBot Inc. have made the Lua language useful for controlling most of Farmbot,
however Lua coding seems to be only available in Sequences (i.e. no long-running Lua execution environment ?)

Look at Lua | FarmBot Developer Documentation