A Nerves-based firmware project for monitoring soil moisture using a Raspberry Pi Zero 2W and LM393 Soil Hygrometer Moisture Sensor.
VeggieVision is an embedded Elixir application built with the Nerves framework that continuously monitors soil moisture levels using an LM393 Soil Hygrometer Moisture Sensor. The project runs on a Raspberry Pi Zero 2W and communicates with the sensor via I2C protocol. The system automatically transmits humidity data to a remote HTTP server for data collection and analysis.
- Board: Raspberry Pi Zero 2W
- Sensor: LM393 Soil Hygrometer Moisture Sensor (Analog Output)
- Communication: I2C protocol
- I2C Address: 0x2
- I2C Bus: i2c-1
- Framework: Nerves Project
- Language: Elixir
- I2C Library: Circuits.I2C
- HTTP Client: Req
- Architecture: Supervisor pattern for process management
veggie_vision_firmware/
├── README.md
├── veggie_vision.ex
└── images/
└── raspberry_pi_zero_2_w_pinout.png
The main module VeggieVision implements:
- Supervisor Pattern: Manages the I2C communication process
- Periodic Monitoring: Reads sensor data every 15 minutes (900,000ms)
- HTTP Data Transmission: Automatically sends humidity data to a configured HTTP server
- Error Handling: Graceful handling of I2C bus failures and HTTP communication issues
- Data Processing: Reads 2 bytes from the sensor and processes the moisture data
- Automatic I2C bus initialization
- Periodic soil moisture monitoring (15-minute intervals)
- HTTP data transmission to remote server
- Comprehensive error logging for I2C and HTTP communication
- Supervisor-based process management for reliability
The firmware is configured to send humidity data to an HTTP server. Update the @server_url variable in veggie_vision.ex:
@server_url "http://<IP_ADDRESS>:4001/store"Replace <IP_ADDRESS> with your server's IP address or domain name.
The current measurement interval is set to 15 minutes (900,000ms). This can be adjusted by modifying the @measurement_interval variable:
@measurement_interval 900_000 # 15 minutes in millisecondsThe firmware automatically starts when deployed to the Raspberry Pi Zero 2W. The system will:
- Initialize I2C communication with the soil moisture sensor
- Read sensor data every 15 minutes
- Transmit humidity values to the configured HTTP server
- Log all activities and errors to the console
The firmware sends humidity data via HTTP GET requests to the configured server endpoint. The data is transmitted as a query parameter:
GET /store?hum=<humidity_value>
The server should be configured to handle these requests and store or process the humidity data as needed.
The LM393 Soil Hygrometer Moisture Sensor provides analog output that is read through the I2C interface. The sensor detects soil moisture levels and provides periodic monitoring capabilities for agricultural or gardening applications.
This project is designed for embedded applications using the Nerves framework, providing a robust and reliable solution for soil moisture monitoring in IoT applications with remote data collection capabilities.
