← Back to ideas

Redson Dev · Idea

IoTIntermediateAges 18+A weekend

Smart Farm Gate Counter with LoRaWAN Connectivity

Published July 1, 2026

This project offers a practical solution for local farmers needing to monitor livestock or vehicle movements through a gate. Building a smart farm gate counter, you can track daily comings and goings without manual checks, sending data wirelessly over long distances. This is particularly useful for farms outside of Lilongwe or Blantyre, providing valuable insights into farm activity for operations like Mchinji Coffee Estates.

What you'll need

  • ESP32 LoRaWAN Development Board (e.g., Heltec WiFi LoRa 32 V2)
  • Magnetic Reed Switch Sensor (NC/NO with wires)
  • Small solar panel (6V, 1W)
  • LiPo battery (3.7V, 1000mAh)
  • LiPo charger module (TP4056)
  • Waterproof project enclosure (e.g., IP65 rated, 100x68x50mm)
  • Jumper wires, solder, soldering iron

Step-by-step

  1. 01

    Assemble the Core Electronics

    Connect the LiPo charger module to the solar panel and the LiPo battery. Solder the output from the LiPo charger to the battery input terminals of the ESP32 LoRaWAN board. Ensure polarity is correct to prevent damage.

  2. 02

    Integrate the Reed Switch

    Connect one lead of the magnetic reed switch to a GND pin on the ESP32 board. Connect the other lead to a digital input pin, such as GPIO23. This pin will be configured as an input with an internal pull-up resistor.

  3. 03

    Configure LoRaWAN and Device Code

    Using the Arduino IDE with ESP32 board support, install the 'MCCI LoRaWAN LMIC library'. Configure your device with a unique DevEUI, AppEUI, and AppKey obtained from a LoRaWAN network server (e.g., The Things Stack). Write code to increment a counter when the reed switch changes state (gate opens/closes) and transmit this count via LoRaWAN every 15 minutes or upon significant change.

  4. 04

    Weatherproof and Test

    Mount all components securely inside the waterproof enclosure. Ensure the solar panel is exposed to sunlight. Position the magnetic reed switch and its corresponding magnet properly on the gate so that the gate opening/closing triggers the switch. Conduct extensive testing over several hours to verify power management and LoRaWAN transmission reliability.

  5. 05

    Deploy and Monitor

    Install the sealed unit on your farm gate, ensuring the solar panel has unobstructed sunlight. Access your LoRaWAN network server dashboard to monitor the incoming gate count data. You can then integrate this data with a simple dashboard or spreadsheet for long-term tracking and analysis of gate activity.

Tips

  • Use a low-power sleep mode on the ESP32 between transmissions to maximize battery life, especially during cloudy days.
  • Place the reed switch and magnet carefully to avoid false triggers from wind or minor gate movements.
  • Consider adding a small status LED (with a series resistor) for visual confirmation of successful transmissions during initial setup.
#lorawan#esp32#farm-tech#sensor#data-logging