The Urvara gateway
Farm internet goes down. A monitoring system that loses every reading during an outage has a hole exactly where the interesting part was.
The Urvara gateway is a small program for a Raspberry Pi or any always-on computer at the farm. Devices on the farm network talk to it. It forwards their readings to the Urvara server, keeps them on disk while the internet is down, and sends them when it returns, oldest first.
What it gathers
| Source | How |
|---|---|
| Sensor boards | They publish MQTT to the gateway’s own broker |
| Meters, inverters, drives | The gateway reads them over Modbus |
| Zigbee sensors | The gateway listens to Zigbee2MQTT |
| LoRaWAN sensors | The gateway listens to ChirpStack or The Things Stack |
| Cameras | The gateway fetches a still picture on a timer, and sends live video while someone is watching |
Through an outage
- Every reading is written to disk with the time it arrived.
- Up to 500,000 messages are kept, enough for several days of ten sensors reporting every ten seconds. Beyond that the oldest are dropped.
- When the link returns, readings are sent oldest first, in batches.
- A reading sent twice is stored once, so a retry never doubles your data.
- Camera pictures are not kept during an outage; that picture is skipped.
One token for the whole farm
Devices behind the gateway need no token and no set-up in Urvara. You register the gateway once, and every device it hears appears in the app by itself under its own name. That also means the gateway’s MQTT port must stay inside the farm network.
Commands
The gateway asks the server for waiting commands every 3 seconds and passes them to the board over MQTT. Only boards on MQTT can be switched; Modbus, Zigbee and LoRaWAN devices are read-only.
Live camera view
Give a camera a stream address in the gateway’s settings file, usually one that starts with rtsp://, and install ffmpeg on the gateway computer. On a Raspberry Pi that is sudo apt install ffmpeg. When someone opens the live view in the app, the gateway pulls the camera’s video, cuts it into two-second pieces and uploads them, and the browser plays them. When the view is closed, sending stops within about half a minute.
- The picture is roughly 5 to 10 seconds behind. Video only, no sound.
- Nothing is recorded or stored.
- Up to 4 live views for one farm at once.
- A camera can have a snapshot address, a stream address, or both. With only a stream it has a live view but no pictures for the AI to check.
- For a camera whose video format browsers cannot play, such as H.265, a
transcodesetting re-encodes it. That uses much more processor on the gateway.
Running it
- Add a device of kind Gateway in Live farm and copy its token.
- Download the gateway for your computer. It is one file, with builds for a Raspberry Pi and for other Linux computers.
- Put Urvara’s address and the token in the gateway’s settings file, and start it.
- Local MQTT, Modbus, Zigbee2MQTT, LoRaWAN servers and cameras.
- A disk backlog through internet outages.
- On/off commands to MQTT boards, by hand or from an automation.
- A live view of a camera through the gateway, a few seconds behind, with no sound and nothing recorded.
- Updating the gateway from the app.
- A local screen on the gateway that works with no internet at all.
- Recorded video and browsing older pictures. Video is live only, and only the newest picture of each camera is shown.
Live farm has been tested with simulated devices on every route except USB. It has not yet been run with physical sensors in the field, so treat pin numbers, calibration values and radio set-ups as things to check on your own hardware.
The live view was tested with the real gateway program and ffmpeg using a test video file, and played in the app. It has not yet been tried with a physical RTSP camera.
Questions people ask
What is an IoT gateway on a farm?
An IoT gateway is a small computer at the farm that collects data from local sensors and equipment, which often use radio or wired links that cannot reach the internet themselves, and forwards it to a server.
Do I need a gateway to use Urvara?
No. A device with Wi-Fi can send readings straight to the Urvara server by MQTT or HTTP. You need the gateway for Modbus, Zigbee, LoRaWAN on a local server, cameras and their live view, and to keep readings through an internet outage.
What happens to my data when the internet is down?
Devices behind the gateway keep reporting to it, and it stores the readings on disk. When the internet returns it sends them all, with their original times. Devices that talk straight to the server cannot send during an outage.
Last checked against the product: .