LoRa Based Smart Disaster & Environment Monitoring System
by sanjula nipun in Circuits > Sensors
4514 Views, 54 Favorites, 0 Comments
LoRa Based Smart Disaster & Environment Monitoring System
π LoRa Based Smart Disaster & Environment Monitoring System
Disasters like floods, earthquakes, and gas leaks often happen without warning, but what if we could detect early signs and act faster? β οΈ
I thought of building a good device using ESP32 and LoRa to monitor changes happening in the environment in real time π. In this, we can use different sensors to detect disasters before they happen.
For example, we can monitor:
- π§οΈ Rain levels
- π§ Water rise
- π Ground vibrations
- π«οΈ Air quality
- π‘οΈ Temperature
- π¨ Humidity
- π« COβ levels
By creating a network of these sensors, we can identify early warning signs of:
- π§οΈ Floods
- π Earthquakes
- π«οΈ Gas leaks
- π± Landslides
This kind of system can help us take early action, reduce damage, and improve safety in vulnerable areas π¨.
This project is not just about reading sensors. itβs about creating a smarter, responsive system that can help detect danger early and potentially save lives β€οΈ
Supplies
ESP32 Based Device
- 1x 0.96 I2C Oled Display
- JST Wires
- Circuit Wires
- 1x 868mHz Lora PCB Antenna
- 1x WiFi Antenna PCB Antenna
- 1x 868mHz Lora Antenna
- 1x WiFi Antenna Antenna
- 1x White Color Encloser 12mm
- 1x White Color Encloser 25mm
- 1x Solar Panel (5-6V 1A)
- 2x 3.7v Lithium Iron Battery (2500mAh)
- 1x I2C Temperature + Humidity (SHT20 Metal cover version)
- 1x CO2 TVOC Air Quality Sensor EN160 (Optional)
- 1x MQ2 Gas Sensor (Optional)
- 2x ESP32 or ESP32 Base PCB (In PCB desing step i will add all smd list)
- 8x M2 Screws & Nuts + M2x8 Spaces with rod
- 2x PG7 gland
You can select any one sensor or few if you like.
DIsplay Frame
- 3D Printer
- PLA Filament (If you dont have 3d Printer, you can use 3D printing service)
Tools & Others
- Soldering Iron
- Hot Air Gun
- Glue Gun + Glue Stick
- Soldering wire
- Wire Cutter
- Screw Driver
- Masking Tape
- Dubble Side Tape
- Super Glue
- Mini Drill
- Wire Cutter / Pliers
- Mini Drill
System Structure Planning
- So, in this project, Iβm going to build a system with a gateway and a node π§π‘. You can also connect multiple nodes to the same system.
- The node is where the sensors π‘οΈπ«οΈπ§ are placed. It reads the data and sends it to the gateway wirelessly via LoRa πΆ.
- In this scenario, the node needs at least one sensor. Since itβs placed outside, it is better to make it a battery-powered device π. If we add a battery, we can also connect a solar panel βοΈπ to keep the device active for a long time.
- On the gateway side, we can use USB power β‘ because itβs used indoors. Optionally, we can also add a backup battery π for reliability.
- After that, we can display the data from the gateway on a web interface π and even wirelessly show it on a large color display π₯οΈπ‘.
- This is basically my system structure planning ποΈ. Now, we can see how to actually build it step by step π οΈ.
Enclosure Box Selection
Iβm going to show you the node and gateway device enclosures π¦π§. I ordered two enclosure boxes online π. Even though both look the same from outside π, I chose them in different sizes.
Here, I used a white enclosure βͺπ¦ because when itβs placed outside, there is strong sunlight βοΈ which can increase the temperature. π‘οΈ
If I had chosen a black enclosure β«, the internal temperature would rise a lot more π₯. Since itβs white, it helps to reduce the heat slightly. βοΈ
The node side needs a battery π and sensors π‘οΈπ«οΈ, so I went with a slightly larger enclosure π¦β¬οΈ. The gateway got a slightly smaller box π¦β¬οΈ because it doesnβt need to handle many components.
You can also see the internal structure ποΈ of my enclosure box. For this, we definitely need to design and build our ESP32 LoRa PCB β‘π‘.
PCB Designing
This is the ESP32 PCB that I designed for this project. π§βπ»π§
- When talking about the PCB, the main components are the ESP32 chip β‘π‘ and the RFM95 LoRa module. πΆ
- I have also included a USB Type-C interface π with a CH340 chip so that we can easily upload the program. π»
- Additionally, I added a battery charging IC πβ‘. With this, the battery can be charged either from USB or from a 5β6V solar panel. βοΈπ
- I included a battery fuel gauge IC ππ to monitor the battery status. It allows us to check details like current consumption, battery percentage, and more. π
- I also added a small switch near the USB port ππ. With this, we can turn ON/OFF the power going to the MCU β‘π‘.
- Finally, I added a JST battery connector on the back side of the PCB ππ, so the battery can be easily connected from the rear.
Also, today Iβm not going to explain how to design the PCB, because PCB design is not the main focus of this project. However, I have added all the PCB files and detailed information in one place, so you can download everything easily if you want to build the same board. πβ¬οΈ
Now the next step for us is simple: Order the PCB and solder the components onto the board. π©β¨
PCB Assemble Process
So here is the assembled PCB. π§π‘ Once itβs complete, it looks really nice β¨. Anyway, I ordered this as a black PCB β«, but you can choose any color you like. π¨
On the back side of the assembled PCB, I attached a piece of double-sided tape π§· so we can stick the battery to the back of the PCB π. Then, connect the battery to the JST connector. ππ
When attaching the battery, remember to place it in the center so it doesnβt block the 4 mounting holes. β οΈ
After that, you can add another piece of double-sided tape on top of the battery π§· and fix the whole setup firmly inside the enclosure. π¦
Iβve shown how I did it in the photo. πΈ
Node Enclosure Assemble (Wire Hole)
Now, for the node enclosure box, we need to make two holes on the side. π¦π©
One hole is for the solar panel wire connection βοΈπ. For that, Iβm using a PG7 gland. π§
The second hole is for the sensor connection π‘οΈπ«οΈ. Since itβs also PG7 size, I made both holes the same size. π’
When making the holes, I first placed a piece of masking tape π§· on the enclosure surface, then marked the positions βοΈ and drilled the holes. If we donβt use masking tape, thereβs a higher chance of damaging or scratching the enclosure surface. β οΈ
Node Enclosure Assemble (Sensor & Antenna)
- Now you can see the two clean holes I made π©β¨. I used a mini drill π οΈ to make them.
- After that, we can insert the sensor and the gland π‘οΈπ§ and tighten them properly using the clip π. Then you can check that everything is firmly fixed to the enclosure box. π¦
- Next, take the two PCB antennas π‘π‘ and remove the protective layer from the back glue tape π§·, then stick them inside the node enclosure box. π¦
- One antenna is for LoRa signal πΆ and the other is for ESP32 WiFi π. When attaching them, make sure to place them on opposite sides βοΈ and not too close to each other. β οΈ
Iβve added a photo of how I attached them πΈ take a good look at it. π
Node Enclosure Assemble (PCB Wire Lines)
Now we need to mount the PCB to the bottom part of the enclosure box π¦π§. For this, I used four M2 copper pillars π‘. I designed the PCB to match the 4 holes in the enclosure base perfectly.
I fixed the copper pillars using super glue π§΄, and then we can place the PCB on top and secure it with screws π©. (First, align and test everything, I did the final fixing later because I still had wires to pass) β οΈ
Next, we need to connect the sensor wires to the PCB π. Iβve marked this in my third photo. πΈ
In my sensor:
- π΄β« Red & Black wires β VCC & GND
- π‘ Yellow wire β SCL
- βͺ White wire β SDA
I connected these to the I2C lines on the PCB π‘.Before closing the enclosure, make sure to pass all the wires and complete the connections π.
Node Enclosure Assemble (Solar Panel)
Next, we need to solder two wires to the solar panel βοΈπ§ and pass those wires through the gland into the enclosure box π¦π. After that, we can connect those two wires to the marked VCC and GND points on the PCB. β‘
When choosing a solar panel, be careful to use a 5β6V panel βοΈπ. If you use a panel higher than 6V, there is a risk of damaging the charging IC on the PCB β οΈ, so keep that in mind.
Once all the wires are connected properly π, we can secure the PCB using the 4 screws π©. Finally, close the enclosure by fixing the back cover with the two screws π¦π.
(But before closing it completely, donβt forget to upload the ESP32 code π»π‘ itβs much easier to do that first! π)
Gateway Enclosure Assemble (Antenna Hole)
Now we are going to build the gateway enclosure box π¦π‘. First, just like before, we need to make two holes on the side π©. For the gateway, I decided to connect two external antennas π‘π‘, so we need two holes for them.
As before, I used masking tape π§·, marked the positions βοΈ, and made two small holes matching the size of the antenna copper wires. π§
After that, we can insert the antenna wires through the holes π‘ and secure them tightly using copper nuts so they are firmly fixed to the enclosure. π¦
Finally, you can set up the antennas and see how they look. πβ¨
Gateway Enclosure Assemble (3D Print Display Frame)
For the gateway device π‘, I decided to add a small display π₯οΈ to make it more visual and user-friendly πβ¨. For this, I selected an I2C display π.
The main challenge was how to mount the display neatly on the enclosure box π¦. So I decided to design a custom 3D printed frame π§©.
I designed the frame using Autodesk Fusion 360 π» and then 3D printed it π¨οΈ. After printing, I did some finishing work using sandpaper to make the surface smooth and also slightly rounded the edges β¨ for a better look and feel.
Finally, I was able to mount the I2C OLED display into the frame π₯οΈπ¦ and fit it nicely onto the enclosure.
I have added two design versions here for you. This is because in the market there are two common I2C OLED display sizes π₯οΈπ. You can simply check your display size first π and then choose the correct design before printing. π¨οΈ
Gateway Enclosure Box Assemble (Complete & Screw)
Now just like before, I started with the Gateway enclosure setup. First, I used masking tape π§· and marked the exact position where the display frame should be installed. π₯οΈ
After marking, I carefully cut and removed that section βοΈ using a drill , making sure the opening is clean and accurate. Then the display frame fits perfectly into the gateway enclosure box π¦β¨.
Next, I connected the display wires π:
- π΄ VCC
- β« GND
- π‘ SCL
- βͺ SDA
I soldered these wires directly onto the PCB I2C lines π§π‘. After soldering, I also connected the battery π and then secured the PCB using screws (M2 type) π© so everything is firmly fixed inside the enclosure π¦.
Finally, I connected the two antennas using IPEX connectors π‘π‘:
- πΆ Large antenna β LoRa
- π Small antenna β WiFi
ESP32 Program
Now the next step is to upload the Arduino code to our ESP32 PCB. π»β‘
To do this, simply connect the USB Type C port on the PCB to your laptop using a USB cable. π
After connecting the USB cable π, you can use the small switch near the USB port π on the PCB. By switching it to the right side, you can turn ON the power to the circuit β‘π‘.
Then follow these steps in the Arduino software:
1οΈβ£ Open the Arduino IDE.
2οΈβ£ Go to Board settings and select ESP32 Dev Module.
3οΈβ£ Select the correct COM port connected to your device.
4οΈβ£ Click Upload to send the code to the ESP32.
Finally, we need to upload the code separately for both devices π»π‘ β the gateway and the node. These are based on the custom PCB designs we built.
Also, in the gateway device, there is a SPIFFS file system π, so donβt forget to upload the SPIFFS data after uploading the ESP32 code β οΈ. This is very important for the gateway to work properly.
Once both devices have the programs successfully uploaded β , we can assemble everything fully.
Then we can fix the PCB using screws π© inside both enclosures π¦ and properly close the enclosure boxes. At this point, both the node and gateway devices are fully completed and working. π‘
Complete Devices
Wolaaa π₯π‘ this is the LoRa devices we built. It looks like a proper finished product from a shop πͺβ¨, and it has a really nice and clean design. The gateway with the 3D printed display frame also gives it a very good professional look ππ₯οΈ.
Now what we need to do is install the node device outdoors ππ¦. But at this moment, I didnβt have enough time to do that because I was busy with this project work.
My idea was to mount the 3D printed holder together with the solar panel βοΈ and the node box π¦ on a pole or outdoor structure. I really wanted to complete that setup, but I didnβt have enough time at the moment β³.
I will try to finish it and give an update soon π§π‘. Otherwise, you can also try and install it in your own way and improve it π.
Anyway, now our device is complete π, and next we can focus on how we deploy and use it in real applications πβ‘.
How It Woks - Guideline 1
So now I temporarily took the node device and solar panel βοΈ outside for testing. First, I placed the solar panel in a low sunlight area π€οΈ to check how it performs.
After that, I decided to place it in a proper direct sunlight position βοΈπ so I can clearly observe the difference in the data readings. π
From this, we can confirm that the node sensor is working properly π‘οΈπ‘ and responding correctly to environmental changes.
How It Woks - Guideline 2
With the node placed outside ππ¦, you can now observe how the gateway device works π‘. Unfortunately, my gateway device accidentally fell to the ground π’, and because of that, half of the I2C OLED display stopped working. π₯οΈβ οΈ
But donβt worry, in your build, it should work perfectly fine π. In my case, the issue happened only because it fell, so the display text is not showing properly.
Even with that, you can still see a lot of useful data on the display π:
- π‘ Node data
- π Battery sensor details
- π‘οΈ Temperature & humidity
- πΆ LoRa signal strength
And even if the display doesnβt work, you can still use the gatewayβs WiFi π to access the web dashboard in real time ππ‘. So letβs take a look at that next.
How It Woks - Guideline 3
Now letβs see how the WiFi function works ππ‘. When you turn ON the gateway, you will see a WiFi network called βDisasterMonitor-GWβ πΆ. You can connect to it using the password βmonitor123β π.
After connecting, go to your web browser π and enter the IP address β192.168.4.1β. Then youβll be able to see the nice web dashboard πβ¨.
First, it shows the battery sensor details of the gateway π:
- β‘ Battery voltage
- π Current consumption (mA)
- π Battery percentage
This gives a clear understanding of the gateway battery status π.
Then you can also see:
- π Your IP address
- β±οΈ Device uptime
- πΆ LoRa packet received status
- π‘ Number of active nodes
Right after turning it ON, you will see a βsearching for nodeβ message π for a few seconds. After that, the node details will automatically appear on the dashboard ππ‘.
How It Woks - Guideline 4
Here is how the dashboard looks on a mobile phone π±π. Iβm explaining it from mobile view because it gives a larger and clearer interface compared to desktop πβ¨.
First, we have a tab called βALERTS & THRESHOLDSβ β οΈ. From this, we can set the range for temperature and humidity alerts π‘οΈπ§.
- π‘οΈ Temperature range is set between 25 β 35
- π§ Humidity range is set between 20 β 85
- π Battery alert is set at 15%
We can adjust these values and apply the settings βοΈ.
Below that, we can see the full details of the node π‘:
- πΆ LoRa signal strength
- π‘οΈ Temperature
- π§ Humidity
Currently, the values are in normal status β . If they go beyond the set thresholds, it will show as HIGH or LOW. β οΈ
At the bottom, we can see the battery sensor details of the node π:
- β‘ Battery voltage
- π Current
- β€οΈ Battery health
This helps us understand how long the node can keep running. β³
Also, we can check the βLast Seenβ status β±οΈ, which helps us determine whether the node is online or offline. π‘βοΈ
How It Woks - Guideline 5
Now I temporarily set the temperature range to 30Β°C π‘οΈβ οΈ to show how the alert system works. As you can see, the current temperature is around 34.5Β°C. Once we set the maximum level to 30Β°C, the system shows the temperature as HIGH in red color π΄ and also gives an active notification π¨.
This is how our system works π‘. In the same way, you can also adjust the humidity levels π§β¬οΈβ¬οΈ and observe the changes. If you connect a different sensor, youβll be able to monitor that as well π.
For example, if we add an MQ2 sensor π₯ to create a gas monitoring node, we can track gas levels in the same way and get alerts just like this. π¨π‘
END
So this is the end of our project. ππ‘
My idea was to build two more nodes π§π¦:
- One with a COβ + MQ2 gas sensor π«οΈπ₯
- Another with an accelerometer π to detect earthquakes
But due to the high cost π° and limited time β³, I was only able to build the temperature monitoring node π‘οΈ.
These days, we often see in the news about rising global temperatures and climate changes (El NiΓ±o) πβοΈ. Because of that, this project can be very useful for monitoring outdoor temperature π.
You can also expand this into automation systems β‘:
- Turn ON a fan π when temperature rises
- Activate a water pump π§ when needed
All the code files and resources for this project π»π can be downloaded from here.
So for now, Iβm ending this project here π. If you have any questions or need help, feel free to leave a comment. π¬π