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

Cover.jpg
F65DXCWMN97SIDS.jpg
F7FVQBKMN97RGFM.jpg

🌍 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:

  1. 🌧️ Rain levels
  2. πŸ’§ Water rise
  3. 🌎 Ground vibrations
  4. 🌫️ Air quality
  5. 🌑️ Temperature
  6. πŸ’¨ Humidity
  7. 🫁 COβ‚‚ levels

By creating a network of these sensors, we can identify early warning signs of:

  1. 🌧️ Floods
  2. 🌎 Earthquakes
  3. 🌫️ Gas leaks
  4. 🌱 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

dfc8fc5c-b037-49a1-b8c6-98b4be2c88db.jpg

ESP32 Based Device

  1. 1x 0.96 I2C Oled Display
  2. JST Wires
  3. Circuit Wires
  4. 1x 868mHz Lora PCB Antenna
  5. 1x WiFi Antenna PCB Antenna
  6. 1x 868mHz Lora Antenna
  7. 1x WiFi Antenna Antenna
  8. 1x White Color Encloser 12mm
  9. 1x White Color Encloser 25mm
  10. 1x Solar Panel (5-6V 1A)
  11. 2x 3.7v Lithium Iron Battery (2500mAh)
  12. 1x I2C Temperature + Humidity (SHT20 Metal cover version)
  13. 1x CO2 TVOC Air Quality Sensor EN160 (Optional)
  14. 1x MQ2 Gas Sensor (Optional)
  15. 2x ESP32 or ESP32 Base PCB (In PCB desing step i will add all smd list)
  16. 8x M2 Screws & Nuts + M2x8 Spaces with rod
  17. 2x PG7 gland

You can select any one sensor or few if you like.


DIsplay Frame

  1. 3D Printer
  2. PLA Filament (If you dont have 3d Printer, you can use 3D printing service)


Tools & Others

  1. Soldering Iron
  2. Hot Air Gun
  3. Glue Gun + Glue Stick
  4. Soldering wire
  5. Wire Cutter
  6. Screw Driver
  7. Masking Tape
  8. Dubble Side Tape
  9. Super Glue
  10. Mini Drill
  11. Wire Cutter / Pliers
  12. Mini Drill

System Structure Planning

3STRCT.jpg
  1. 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.
  2. The node is where the sensors πŸŒ‘οΈπŸŒ«οΈπŸ’§ are placed. It reads the data and sends it to the gateway wirelessly via LoRa πŸ“Ά.
  3. 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.
  4. On the gateway side, we can use USB power ⚑ because it’s used indoors. Optionally, we can also add a backup battery πŸ”‹ for reliability.
  5. After that, we can display the data from the gateway on a web interface 🌐 and even wirelessly show it on a large color display πŸ–₯οΈπŸ“‘.
  6. This is basically my system structure planning πŸ—οΈ. Now, we can see how to actually build it step by step πŸ› οΈ.

Enclosure Box Selection

f81cc488-bdc4-4f64-85f2-15648674fe66.jpg
e22f9d1c-e5ff-4300-b5c0-23e9443a72d5.jpg
1d82f7f9-c58c-43b6-9c03-a053282b4ca6.jpg
e5e534da-c95c-4bbb-884d-c375bbda1fbd.jpg

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

PCB.jpg

This is the ESP32 PCB that I designed for this project. πŸ§‘β€πŸ’»πŸ”§

  1. When talking about the PCB, the main components are the ESP32 chip βš‘πŸ“‘ and the RFM95 LoRa module. πŸ“Ά
  2. I have also included a USB Type-C interface πŸ”Œ with a CH340 chip so that we can easily upload the program. πŸ’»
  3. Additionally, I added a battery charging IC πŸ”‹βš‘. With this, the battery can be charged either from USB or from a 5–6V solar panel. β˜€οΈπŸ”‹
  4. 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. πŸ“Š
  5. I also added a small switch near the USB port πŸ”˜πŸ”Œ. With this, we can turn ON/OFF the power going to the MCU βš‘πŸ“‘.
  6. 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

fdc3349e-2dd8-4485-a9ee-8c5fbdc7d807.jpg
80fdc0ee-2c4d-4ba0-ba5d-b49509ac8da8.jpg
002f0850-6c21-42e5-bdbc-23066f3b89b7.jpg

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)

76ab4a7e-77ca-4499-9246-338a7545deb1.jpg
b165ad00-0104-4146-a8a7-2dcd40387625.jpg

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)

7e4ac4ea-275b-4425-a980-e01d6249e6b0.jpg
a987d2ca-40b6-49bb-a0e5-d0c19640c0db.jpg
681324c4-6499-4a87-9bd6-fcb78d2d9a01.jpg
9dd4cbc5-639a-443f-a6bb-f655315e434a.jpg
  1. Now you can see the two clean holes I made πŸ”©βœ¨. I used a mini drill πŸ› οΈ to make them.
  2. 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. πŸ“¦
  3. Next, take the two PCB antennas πŸ“‘πŸ“‘ and remove the protective layer from the back glue tape 🧷, then stick them inside the node enclosure box. πŸ“¦
  4. 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)

fcd4c38f-f992-4d5b-8b6f-f4a0a1eff548.jpg
7e2b7e13-2481-4077-af24-b0450dfa941f.jpg
PCB1.jpg

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:

  1. πŸ”΄βš« Red & Black wires β†’ VCC & GND
  2. 🟑 Yellow wire β†’ SCL
  3. βšͺ 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)

76dc78ef-be3a-4fda-a8e1-b1bc7194a877.jpg
PCB2.jpg
7d4dfefa-e167-4b59-8960-6a3348daca7b.jpg

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)

cefaa0d8-fecc-45fd-a942-c838ace4b4e5.jpg
e15f2946-972d-4cba-90b4-34837197550a.jpg
9dd7391f-ef4b-42d9-824c-af9b5742f11f.jpg
7dc982a9-bac9-4fe3-800d-b393a209ef88.jpg

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)

54e471c8-5e93-4e89-9cbb-a532968fd0d0.jpg
1dbde9ec-d4ca-4e0c-b54f-eb98d6e642e2.jpg
dxjuomfkc2sub2jqzwn0czpvcy5vymply3q6z2rzlwj1y2tldc1wcmqvdw5pzmllzc1nywxszxj5ltiwmtiyny00ntq2lwexntkx.png

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)

8ef38fdd-61f0-4764-b30f-8064e814e7bc.jpg
730da77a-7c4c-4f07-8856-039b6a7b1122.jpg
e0318390-a34b-42ff-9750-541e12fa4feb.jpg

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 πŸ”Œ:

  1. πŸ”΄ VCC
  2. ⚫ GND
  3. 🟑 SCL
  4. βšͺ 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 πŸ“‘πŸ“‘:

  1. πŸ“Ά Large antenna β†’ LoRa
  2. 🌐 Small antenna β†’ WiFi

ESP32 Program

Capture.PNG
GT.PNG
ND.PNG

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

c634aa43-20dc-498c-9404-1c63f7090592.jpg
6d6519d0-4718-4652-818d-1e82a14800f3.jpg

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

ff4725eb-a7f5-43b8-9b96-14d8c8a08ff8.jpg
630957a7-984c-4bde-8ea1-3e8ea24a9eb7.jpg

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

0ac39000-2781-4fce-aa66-9463af9ed869.jpg
4ec73552-2df0-4fd7-b242-b9621ba9c2eb.jpg

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 πŸ“Š:

  1. πŸ“‘ Node data
  2. πŸ”‹ Battery sensor details
  3. 🌑️ Temperature & humidity
  4. πŸ“Ά 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

A2.jpg
A1.PNG
A3.PNG
A5.PNG

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 πŸ”‹:

  1. ⚑ Battery voltage
  2. πŸ“Š Current consumption (mA)
  3. πŸ”‹ Battery percentage

This gives a clear understanding of the gateway battery status πŸ“ˆ.

Then you can also see:

  1. 🌐 Your IP address
  2. ⏱️ Device uptime
  3. πŸ“Ά LoRa packet received status
  4. πŸ“‘ 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

412171dc-eb5b-4766-89f9-a9f37ea5b0ef.jpg
97ba93f4-d9cf-4cd1-9177-0218390cb191.jpg

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 πŸŒ‘οΈπŸ’§.

  1. 🌑️ Temperature range is set between 25 – 35
  2. πŸ’§ Humidity range is set between 20 – 85
  3. πŸ”‹ 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 πŸ“‘:

  1. πŸ“Ά LoRa signal strength
  2. 🌑️ Temperature
  3. πŸ’§ 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 πŸ”‹:

  1. ⚑ Battery voltage
  2. πŸ“Š Current
  3. ❀️ 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

f367c3a0-0b4c-4114-a016-c60ff3df7d20.jpg
c13c60da-0d82-4c8c-84d3-a80276de6767.jpg

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

90df564b-61d1-40ed-9b8a-d13a4180bc7b.jpg

So this is the end of our project. πŸŽ‰πŸ“‘

My idea was to build two more nodes πŸ”§πŸ“¦:

  1. One with a COβ‚‚ + MQ2 gas sensor 🌫️πŸ”₯
  2. 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 ⚑:

  1. Turn ON a fan πŸŒ€ when temperature rises
  2. 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. πŸ’¬πŸ˜Š