An ESP32 farm sensor with ESPHome
An ESP32 board costs a few dollars, has Wi-Fi, and reads almost any sensor. ESPHome turns it into a working node from one text file.
Add a device in Urvara and download its ESPHome configuration. The file already has the MQTT broker, the device ID and the topics. Add your Wi-Fi name and the device token as secrets, set the pins and calibration values for your sensors, and flash the board.
What Urvara writes for you
For a new device with no readings yet, the file is a starter kit of five common farm sensors:
| Reading | Sensor in the file | Sent every |
|---|---|---|
| Water temperature | DS18B20 probe | 30 seconds |
| pH | Analogue pH board | 60 seconds |
| Water level | JSN-SR04T ultrasonic | 30 seconds |
| Pump current | SCT-013 current clamp | 15 seconds |
| Flow | Pulse flow meter | 15 seconds |
For a device that already has readings, the file has a block for each reading it knows how to build, and a placeholder for the rest. An output you marked as switchable becomes a relay that starts in the off state.
Steps
- In Live farm, open Devices, add a device and copy its token. It is shown once.
- Download the configuration from the device’s row.
- Put your Wi-Fi name, Wi-Fi password and the device token in ESPHome’s secrets file.
- Go through every line marked
SET,CHECKorCALIBRATEand set the pin or the value for your hardware. - Flash the board with ESPHome.
- The readings appear on the Now tab by themselves.
The file is written for the esp32dev board and has not been compiled or flashed by us. Pin numbers and calibration values in it are placeholders. Check it against your own board before you rely on it.
How the board talks to Urvara
| Setting | Value |
|---|---|
| Broker | The MQTT host shown in the app, port 1883 |
| User name | The device ID |
| Password | The device token |
| Topics | Under urvara/v1/<device id>/ |
| Online and offline | Reported by the board itself on connect and on loss of power |
More on topics and message formats in MQTT for farm sensors.
Other firmware works too
ESPHome is the one Urvara writes a file for. Anything that can publish MQTT or send an HTTP request can send readings: Arduino code, MicroPython, a Raspberry Pi script.
- A generated ESPHome file for the
esp32devboard. - MQTT direct to the built-in broker, or to the gateway.
- Relays that can be switched from the app.
- Firmware updates over the air, managed from Urvara.
- Ready files for more boards.
- Pairing a new device by scanning a code.
Questions people ask
What is ESPHome?
ESPHome is free, open-source firmware for ESP32 and similar boards. You describe the sensors in a short text file and it builds and flashes the firmware, so you do not write code.
Can an ESP32 run on a battery in a field?
It can, with deep sleep and a solar panel, but Wi-Fi uses a lot of power and has short range. For a battery sensor far from buildings, LoRaWAN is usually the better choice.
Last checked against the product: .