The Apocalypse Sensor Kit is meant for gardening. It's a cheap, DIY suite of hardware and software that you can put together yourself, plant in the ground, and get readings for light intensity, soil moisture, humidity, and temperature. Read the full documentation.
The Apocalypse Sensor Kit consists of three main components:
- Sensor Modules: Battery-powered devices that collect environmental data.
- Receiver Device: A central hub that receives and stores data from sensor modules.
- Mobile Application: For visualizing and analyzing the collected data.
This document is a walk through of the firmware development for the Apocalypse sensor module.
- Hardware Requirements
- Software Dependencies
- Pin Configuration
- Functionality
- Message Format
- Setup and Installation
- Usage
- Power Management
- Troubleshooting
- Network ID Configuration
- Unique ID Generation
- Arduino board (Arduino Pro Mini 3.3V 8MHz recommended)
- DHT11 temperature and humidity sensor
- BH1750 light sensor
- Soil moisture sensor
- LoRa module (e.g., Ra-02)
- Battery for power supply
This project requires the following libraries:
- DHT sensor library for Arduino
- Adafruit Unified Sensor
- BH1750
- LowPower
- LoRa
- Wire (for I2C communication)
- SPI
- EEPROM
Ensure these are installed in your Arduino IDE before compiling the code.
- DHT11 sensor: Pin 8
- Soil moisture sensor data: Pin A0
- Soil moisture sensor power: Pin 7
- Battery voltage measurement: Pin A1
- BH1750 sensor: I2C pins (SDA and SCL)
- LoRa module: SPI pins
- The device initializes all sensors and the LoRa module.
- It generates or retrieves a unique ID for the node.
- It then enters a loop of:
- Waking up and reinitializing LoRa
- Reading sensor data (with multiple samples for accuracy)
- Transmitting data via LoRa
- Entering a low-power sleep mode
The LoRa message is formatted as follows: ##NETWORK_ID@ENV@NODE_ID:SEQUENCE:TIMESTAMP@TEMP;HUMIDITY;LIGHT;SOIL@BATTERY@CHECKSUM$$
##
: Start delimiterNETWORK_ID
: Identifier for the network (e.g., "WD")ENV
: Message type identifierNODE_ID
: Unique identifier for this sensor nodeSEQUENCE
: Message sequence numberTIMESTAMP
: Current timestamp (milliseconds since boot)TEMP
: Temperature reading (°C)HUMIDITY
: Humidity reading (%)LIGHT
: Light intensity (lux)SOIL
: Soil moisture reading (%)BATTERY
: Battery voltage (V)CHECKSUM
: Hexadecimal checksum of the message$$
: End delimiter
Example: ##WD@ENV@12345:10:[email protected];53.20;216.33;[email protected]@a08$$
- Connect all sensors and the LoRa module to your Arduino board according to the pin configuration.
- Install all required libraries in your Arduino IDE.
- Copy the provided code into your Arduino IDE.
- Adjust the
NETWORK_ID
andLORA_FREQUENCY
as needed. - Upload the code to your Arduino board.
Once set up and powered on, the device will automatically begin its sensing and transmission cycle. Use a LoRa receiver to capture and decode the transmitted messages.
The device uses low-power sleep modes to conserve energy. It sleeps for approximately 15 minutes between readings (adjustable via SLEEP_CYCLES
).
- If sensors fail to initialize, the built-in LED will blink rapidly.
- Enable
DEBUG
mode for verbose serial output to diagnose issues. - Ensure all connections are secure and power supply is adequate.
- Verify that the LoRa frequency matches your regional regulations.
The Network ID is a crucial parameter that MUST be customized for your specific implementation. It serves as a filter for the receiver device to process only messages from sensors within its group.
- Change the
NETWORK_ID
in the code to a unique, short identifier for your sensor network. - Keep the Network ID as short as possible (e.g., "WD", "A1") to minimize transmission length.
- Ensure all sensors in your network and the corresponding receiver use the same Network ID.
Identify Calibration Points:
dryValue
: This represents the analog value output by the sensor when the soil is completely dry. The default dry value is set to 690.wetValue
: This represents the analog value output when the soil is completely saturated with water. The default wet value is set to 380.
Collect Calibration Data:
- Place the soil moisture sensor in a sample of completely dry soil (or leave it exposed to air) and record the analog value. This is the dry value.
- Submerge the sensor in a sample of water-saturated soil and record the analog value. This is the wet value.
Adjusting Calibration Values:
The default calibration values (dryValue = 690
and wetValue = 380
) may need to be adjusted depending on,
- Sensor Variability: Different sensors might have slight variations in their readings.
- Environmental Conditions: Soil type, salinity, and temperature can affect the sensor's readings.
The device generates a unique 5-digit ID for each node, which is stored in EEPROM:
- On first run, it generates a random ID based on sensor readings and analog noise.
- The ID is stored in EEPROM and reused on subsequent boots.
- This ensures each node has a persistent, unique identifier.