Simulating a river level sensor using ESP32 and MicroPython - Monitoring River Levels Using LoRaWAN

Simulating a river level sensor using ESP32 and MicroPython

Use a Pycom LoPy4 ESP32 development board equipped with a Semtech SX1276 LoRa transceiver to simulate the river level sensor.

Photograph of an ESP32 development board running MicroPython

Figure 12 –

The microcontroller is awakened every ten minutes from deep sleep using its real-time clock (RTC), and configured to run a short MicroPython application which retrieves a distance reading to the water surface using the HC-SR04 ultrasonic distance sensor. The captured distance is thereafter reorganized into two bytes – the first byte houses the distance in meters, and the second byte houses the remainder in centimeters.

This data is then broadcast out using LoRaWAN.

This paper provides a MicroPython application example which demonstrates the application running on generic MicroPython for ESP32 firmware. When running, the console displays the distance recorded by the HC-SR04 ultrasonic distance sensor, LoRaWAN OTAA join status, and the bytes sent.

The following is a running sample MicroPython application:

Distance recorded (0.1722414m) Waiting to join LoRaWAN using OTAA... Waiting to join LoRaWAN using OTAA... Waiting to join LoRaWAN using OTAA... Joined LoRaWAN Bytes sent (bytearray(b'\x00\x11')) Sleeping... (600000ms)