Skip to content

Project to monitor the water level of a creek using LilyGO LoRa32 OLED v2.1_1.6

License

Notifications You must be signed in to change notification settings

MediaLabUniovi/IOT_Cooper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

english | spanish

Static Badge

SENSOR COOPER V3.2 - MEDIALAB_ LPWAN: LORA ULTRASONIC SENSOR TO MEASURE SAN MIGUEL'S CREEK WATER LEVEL

Powered by

made-in-ArduinoIDE programmed-for-LilyGOLoRa32



Introduction ↩️

In honour of Martin Cooper, Princesa de Asturias Award 2009, and Arlene Harris and their vision of IoP, The Internet of People, in MediaLab_ LPWAN we wanted to develop an IoT device that could improve the quality of the Polytechnic School of Engineering of Gijón. As a result, the idea of the Cooper Sensor came in as a LoRa device, synchronizable with The Things Network, that could be left measuring the water level of San Miguel's creek without any need of mantainance.


With these sensors, the aim is to monitor the possibility of a flood in the main building during the heavy rains season. Specifically, in 2018, a major flood took place turning useless many expensive equipment from the lower floors that were used by the students during the laboratory practices of many subjetcs:




In this repo, you will find all the files and teaching guides required to fully understand and even take the creative freedom to improve this project. Folders and files have been given a self-explanatory name to make navigation more intuituve.


Main features ↩️

  • Developed using LilyGO LoRa32 OLED v2.1_1.6 (ESP32 based board with built-in LoRa capabilities that supports solar recharging and battery management)


  • Changes made for JSN-SR04T (Ultrasonic distance sensor)


Warning

This sensor is extremely sensitive to physical disturbances. Be sure to perfectly align it perpendicularly to the surface where the ultrasonic beam bounces and also mind having direct vision to it

  • Dynamic Data Transmission Rate implementation: send interval dynamically changes its value between 20 and 40 minutes depending on the typical deviation from the latest 5 distances sent to The Things Network (By OTAA; file payload_formatter.json is a suggestion on how to decode the sent bytes)


  • Custom PCB


Tip

Consider soldering female pin connectors so the electronic components can simply be plugged in and unplugged if a repair has to be done

  • Custom housing to fit all the elements in the most efficient way (Container + Solar panel holder + USB protector)




    Assembly example:


Warning

Clear colour PETG 3D printing filament is recommended to survive sun radiation and plastic deformations. An O-ring is also a good choice to fix and stabilize the sensor inside of the bell. Four M3 screws are needed to fix the assembly


To-do list ↩️

The following list enumarates all the tasks involved in the researching process of this project and if they have been strictly completed:

  • Full understanding of the development board and its pinout
- Some pins are conflictive due to poor manufacturer documentation, so testing is still being
- carried out
  • Full understanding of the sensor working mode and alternative modes

  • Sensor code implementation

  • LoRa code implementation

  • Low power code implementation

  • Low power hardware components

- A transistor is being tried to be implemented so the sensor can be powered-on from the
- board's 5V pin and powered-off when going to deep slee, but it is getting tricky

Electric schematic with the transistor


  • PCB design
- As low power hardware has not been fully implemented, PCB has to wait
  • Casing 3D modeling

  • Data visualization app


Component list ↩️

Component Model
Dev Module LilyGO LoRa32 OLED v2.1_1.6
Distance sensor JSN-SR04T
N-Channel MOSFET IRF540N
Resistor 2k2
Battery 18650
Solar panel SYP-S0606
PCB Custom (file included)
Housing Custom (file included)

Connection list ↩️

JSN-SR04T Transistor Resistor 18650 Shield SYP-S0606 LilyGO
trigger - - - - 13
echo - - - - 12
5v S - - - -
GND - indifferent - - GND
- G indifferent - - 15
- D - - - 5V
- - - USB-In USB-Out -
- - - USB-Out - USB-In

Sketched it looks the following way:


Caution

Board model used in the sketch above is a TTGO T3 v1.3, but pin numbers correspond to those on the v2.1_1.6


Flowchart (Simplified!) ↩️

graph TD;
  A[Turn on] -->|1| B(Wake up if in deep sleep)
  B -->|2| C(Get distance and battery measurement)
  C -->|3| D(Send bytes to TTN)
  D -->|4| E(Time data transmission rate)
  E -->|5| F(Go to deep sleep)
  F -->|6| B
Loading

Code files ↩️

In this section, a brief description on how the code is distributed among files in medialablpwan/lorawaterlevelmonitoring/main/, where the code is available and ready to flash or edit, is given:

  • main.ino
    /*
    Definition of global functions
    Variables to be stored in the RTC memory
    'setup()' and 'loop()' functions
    */
  • sensor.ino
    /*
    Functions and variables needed to make a sensor work
    */
  • ddc.ino
    /*
    Functions and variables for the implementation of the dynamic data transfer rate
    */
  • sleep.ino
    /*
    Functions to activate ESP32's deep sleep mode
    */
  • ttn.ino
    /*
    Functions from LMIC library
    */
  • configuration.h
    /*
    Sensor macros and boolean toggles
    */
  • credentials.h
    /*
    OTAA keys for TTN synchronization
    */
  • lmic_project_config.h
    /*
    LoRa frequency band and radio chip selector
    */

A more in depth analysis is given in the code itself as comments explain what each function does.

Tip

The most important files to edit are sensor.ino, where any sensor can be implemented, and configuration.h, where the peripherals' macros are declared

Caution

Additional code may be needed if implementing I2C I/O. The functions to make them work are in the original project in TTGO-PAXCOUNTER-LoRa32-V2.1-TTN/main/main.ino


Libraries ↩️

Note

Other libraries, like SPI library, are easily downloadable from Arduino IDE



Deployment experiment ↩️

The first unit has been deployed near the Polytechnic School of Engineering of Gijón:




Access the Grafana panel1 via this QR code or the link below it:


http://4f566df1fed52c6e7fd5f661f64ae3eb.balena-devices.com:8080/d/vJhQNCZgz/sensores-jsn-sr04t-arroyo-de-san-miguel?from=now-24h&orgId=1&to=now&refresh=1m



License ↩️

This project is licensed under the GPL-3.0 license. Contains code from rwanrooy/TTGO-PAXCOUNTER-LoRa32-V2.1-TTN


Contact ↩️

Important

We will kindly answer doubts and read suggestions: Gmail Badge

More info about our activities: Linkedin Badge

Authors: Daniel Rodríguez Moya, Óscar Gijón, Ramón Rubio and MediaLab_ LPWAN Workgroup :shipit:

Footnotes

  1. Instructions on how to deploy Grafana panels are given on the repo medialablpwan/documentacion.

About

Project to monitor the water level of a creek using LilyGO LoRa32 OLED v2.1_1.6

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published