This repository contains an Arduino sketch for a rain gauge system that utilizes LoRa communication, RTC for timestamping, and an SD card for data logging.
CASA0016:MDB
Satria Mitra Utama
- Arduino MKR board with LoRa connectivity
- DS3231 RTC module
- SD card module
- Reed switch for rainfall measurement
- 5mm Neodymum magnet
- Printed Rain Gauge
- 25mm screw with diameter 2mm
- Lot of wires
- Lipo Battery
- Solar Panel
- Adafruit Solar Charger
- Connections: Wire up the components according to the provided pin configurations.
No | Hardware | Hardware Pin | Arduino MKR Pin |
---|---|---|---|
1 | RTC | VCC | VCC |
GND | GND | ||
SCL | SCL/12 | ||
SDA | SDA/11 | ||
2 | Sd card | VCC | VCC |
GND | GND | ||
MOSI | 8/MOSI | ||
MISO | 10/MISO | ||
SCK | 7 | ||
3 | Reed switch | SW1 | 6 |
VCC | VCC | ||
GND | GND | ||
4 | Charger | JST + | JST + |
JST- | JST - |
-
Rain Gauge:
- Print these files using PLA (not waterproof) or PETG(waterproof) filament
- rain_gauge-can.stl
- rain_gauge-bucket.stl
- rain_gauge-base.stl
- Insert your 5mm neodymum magnet into the side hole of bucket
- Use long shaft/screw to insert the bucket into the base
- Plug the reed switch module into base. Final piece of Rain Gauge should looks like this
- Print these files using PLA (not waterproof) or PETG(waterproof) filament
-
Libraries: Install the necessary libraries (Wire, RTClib, MKRWAN, SPI, SD) in the Arduino IDE.
-
TTN Application:
-
Sign up for The Things Network
-
Select your region and create your application on TTN console
-
Plug your Arduino MKRWAN and run a script from Arduino IDE>Examples>MKRWAN>First Configuration, take a note on your DevUI
-
Create a file named arduino_secrets.h on the same folder of Arduino LoRa Transmitter scripts and copy paste your appEui and appKey from TTN Console
const char *appEui = "0000000000000000"; const char *appKey = "<APP_KEY>";
-
-
Upload the scripts of Transmitter and see live data on TTN Console
-
If you can see your data, congratulations, if not please do see Troubleshooting sections
-
Install Node-Red on your Raspberry PI or on your PC
-
Import Node-Red json files configuration from Scripts>Node-Red
-
See the payload on the debug message on Node-red. You can modify or create your own dashboard. Done
- Sets up and initializes the DS3231 RTC module for accurate timekeeping.
- Handles RTC power loss scenarios by setting the time using the sketch compilation time if power is lost.
- Monitors rainfall using a reed switch and software debouncing to count pulses accurately.
- Resets accumulated rainfall at midnight to start afresh.
- Sends rain gauge data via LoRaWAN to TTN at regular intervals.
- Logs data (date, time, accumulated rainfall) onto an SD card in a CSV format for local storage.
- Monitor the Serial Monitor to observe real-time data and system status.
- Access the
rain.txt
file on the SD card for detailed logged rain gauge data.
- If encountering issues during LoRa connection, ensure proper positioning for signal reception.
- Check your appKey and appEui on TTN Console and your aduino_secrets.h
- Verify wiring connections and component compatibility.
- Dont forget to attach your antenna
- Use low power library
- Design a watertight enclosure
- Prototype and iterate to make it better
- Outdoor device needs a waterproof and watertight material
This project is licensed under the MIT License.
- Dusan DJ for his awesome tipping buckets
- Arduino community
- Libraries used: RTClib, MKRWAN, SD
- Node Red