Early Detection For Forest Fire Risk

1574642285172.png

1574642292511.png

1574642306254.png

1574642312503.png

Introduction
The aim of the project is to detect early risk of forest fires and to inform the forestry department to do prevention before the risk became a disaster. The sensors will sense the flammable gas in the air, rain intensity, temperature and humidity of both soil and air, it will also measure the wind speed and wind direction. All of the measurement will be transmitted through wireless module to the base station (due to limited time, I only transmitted the result to my computer through serial port). And the data will be processed in the server side and will be uploaded in our website and sent also to the department of forestry for their analysis purposes (not done yet).

BOM
The anemometer to sense speed and wind direction.
LM35 for sensing the soil temperature.
Ultrasonic sensor HC-SR04 for sensing water heights.
2 metal rod tube (i'm using stainless steel rod tube to slow down the corrosion) for sensing the soil humidity.
The Methane/LPG sensor or smoke sensor.
Rain sensor.
DHT22 for sensing air humidity and temperature.
Serial wireless module.
Battery 12V 8Ah.
Charge controller module.
LM7805 for voltage regulator.
USB Female socket for 5V output
USB Power cable
a few capacitors.
a few terminal block
cables and connectors.
PCB.
FeCl3`
Toner transfer paper and toner printer.

Schematics

Instructions
The project was built with single layer home made PCB using transfer paper and feCl3 to etch the PCB.
The MAXIM Board was wired to the PCB and sensors. The power source is from a solar cell and controlled by a charging controller module.
The power supply was regulated using LM7805 after the output of charge controller and the 5V output will be connected to the MAXIM Board using USB power cable. All of the sensors VCC-IN attached to this 5V and the GND attached to GND.

The anemometer attached to pin AIN_3 for Wind Direction and P5_0 for Wind Speed.

The wind direction sensor is built from a potensio meter with full 360 degree. So, in order to sense the direction we must read the voltage from the output of the sensor, 0 degree means that the voltage is zero, and 359 degree will output VCC voltage which is 5V.

The wind speed is built using 3 cup and a reed switch, so whenever the wind blows it will rotate the cup. each 360 degree rotation will cause the reed switch to close. so in order to get the wind speed we must count the total switch closed in a period of time. I used interrupt routines to count the speed.
From the datasheet we have to divide the counter results by (2.25/5)*1.60934 in order to get the speed in meters/second. I sample the result every 5 seconds.

LM35 for sensing the soil temperature attached to pin AIN_0 which submerged into the soil using metal rod tube, I have to make it waterproof by covering them with resin. The LM35 will output 10mV for each degree celcius.

2 pcs (50cm) metal rod tube (i'm using stainless steel rod tube to slow down the corrosion) for sensing the soil humidity and replace the PCB to sense the soil, I attached it to the module, I planted it into the soil with 5cm space between each rod.The result will be in analog value. We will have to experiment with the result from totally wet until dry.

Ultrasonic sensor HC-SR04 for sensing water height attached to pin P5_3 for TRIG and P5_4 for ECHO. This sensor capable to sense from 3cm to 4m range so it will be perfect for sensing water above the ground. the result is taken after the ECHO pin pulled High by the sensor, and as long as the ECHO pin High we count the time taken in microseconds until the ECHO pin pulled LOW by the sensor. And to get the result in centimeters we have to divide the result by 58.

The Methane/LPG sensor attached to pin AIN_2, I'm using the analog output so it will determine the percentage of Methane concentration in the air.
Rain sensor attached to pin P3_4, I used interruption rain sensor which is only a magnetic reed switch that will close for a short period of time every 2.95mm cubic droplets of water.

DHT22 attached to pin P4_0, it is a single wire communication sensor. So we have to make the pin as output when we need to trigger start measurement and as Input to read the results. The results will be transmitted serially and consisted of 40 bits of data, 32 bits as humidity and temperature data, and last 8 bits as the CRC data to check if the data is valid.

All of the measurement results are transmitted through wireless module to my computer from serial output Pin P3_1.

1574642334488.png

1574642344267.png

1574642352283.png

1574642359736.png

1574642366730.png

1574642372945.png

1574642383222.png

1574642390457.png


Video
I will attach the link to the video tomorrow in syaa Allaah.

Source Code
#include "mbed.h"
#include "max32630fthr.h"
#include "Serial.h"
#include <Timer.h>
#include <AnalogIn.h>
#include <DigitalIn.h>
#include <DigitalInOut.h>
#include <InterruptIn.h>

MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);

Timer timer;
Timer bouncer;
Serial PC(P3_1, P3_0);
DigitalOut rLED(LED1);
DigitalOut gLED(LED2);
DigitalOut TRIG(P5_3);
DigitalInOut DHTs(P4_0);
DigitalIn ECHO(P5_4);

AnalogIn temperature(AIN_0);
AnalogIn moisture(AIN_1);
AnalogIn gas(AIN_2);
AnalogIn wind_direction(AIN_3);

InterruptIn wind_speed(P5_0);
InterruptIn rain(P3_4);

uint8_t speed;
uint8_t raindrops;
int begin, end, range, rain_bounce, wind_bounce, last_wind, last_rain;

int sensor_disconnect = 0;
uint32_t dataTH = 0;

uint8_t Byt_dT= 0;
uint8_t Byt_iT= 0;
uint8_t Byt_dRH = 0;
uint8_t Byt_iRH = 0;


void wind_trigger()
{
wind_bounce = bouncer.read_ms()-last_wind;
if (wind_bounce>50)
{
speed++;
last_wind = wind_bounce;
}
}

void raining()
{
rain_bounce = bouncer.read_ms()-last_rain;
if (rain_bounce>100)
{
raindrops++;
last_rain = rain_bounce;
}
}

void ultrasonic()
{
TRIG.write(1); //trigger ultrasonic sensor for 1mS
Thread::wait(1);
TRIG.write(0);
while(ECHO == 0);
timer.start();
begin = timer.read_us();
end = timer.read_us();
while(ECHO)
{
end = timer.read_us();
if (end>11600) break;
}
timer.stop();
range = end - begin;
range = range / 58;
if (range > 200)
{
range = 200;
}
}

void checkDHT()
{
char total = 0;
char total1 = 0;
char total2 = 0;
while(DHTs.read() == 0);
while(DHTs.read());
while(total<32)
{
total = total + 1;
while(DHTs.read()==0);
timer.reset();
while(DHTs.read())
{
begin = timer.read_us();
}
if (begin>30)
{

dataTH = dataTH<<1;
dataTH = dataTH | 1U;
}
else
{
dataTH = dataTH<<1;
}
}
total = 0;
while(total<8)
{
total = total + 1;
while(DHTs.read()==0);
timer.reset();
while(DHTs.read())
{
begin = timer.read_us();
}
if (begin>30)
{

total1 = total1<<1;
total1 = total1 | 1U;
}
else
{
total1 = total1<<1;
}
}
Byt_dT= dataTH & 0x000000ffUL;
Byt_iT= dataTH >> 8;
Byt_dRH = dataTH >> 16;
Byt_iRH = dataTH >> 24;
dataTH = 0;
total2 = Byt_iRH + Byt_dRH + Byt_iT + Byt_dT;

if (total1 == total2)
{
uint16_t temporary = 0;
uint8_t result;
temporary = Byt_iT & 0x80;
if (temporary == 0xF0)
{
//put your code here for negative temperature
}
temporary = Byt_iT & 0x7F;
temporary *= 256;
temporary += Byt_dT;
result = temporary/10;
PC.printf("Air temperature %d", result);
result = temporary%10;
PC.printf(".%dC\n", result);

temporary = Byt_iRH * 256;
temporary += Byt_dRH;
result = temporary/10;
PC.printf("Air humidity %d", result);
result = temporary%10;
PC.printf(".%dRH\n", result);
}
}

void DHT()
{
sensor_disconnect = 0;
DHTs.output();
DHTs.write(0);
Thread::wait(1);
DHTs.write(1);
DHTs.input();
DHTs.mode(PullUp);
timer.reset();
timer.start();
while(DHTs.read())
{
begin = timer.read_us();
if (begin>200)
{
sensor_disconnect=1;
PC.printf("DHT sensor not found\n");
break;
}
}
if (sensor_disconnect == 0)
{
checkDHT();
}
timer.reset();
timer.stop();
}

// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main()
{
gLED = LED_ON;
rLED = LED_ON;
TRIG.write(0);

Thread::wait(100);
rLED = LED_OFF;
Thread::wait(2000);
wind_speed.mode(PullUp);
wind_speed.fall(&wind_trigger);
rain.mode(PullUp);
rain.fall(&raining);
bouncer.start();
PC.printf("Forest and PeatLand Sensors\n");

while (true)
{
gLED = !gLED;
Thread::wait(5000);
speed = speed*0.724203; //for 5s count, from the datasheet of the anemometer used
PC.printf("Wind speed %dm/s\n", speed);
speed = 0;
PC.printf("Rain %dcc\n", raindrops);
raindrops = 0;
PC.printf("Soil temperature= %.2fC\n", temperature.read()*100);
PC.printf("Soil moisture= %.2f\n", moisture.read()*100);
PC.printf("Gas concentration= %.2f\n", gas.read()*100);
PC.printf("Wind direction %.2fdegree\n", wind_direction.read()*360);

ultrasonic();
PC.printf("Water column %dcm\n", range);
DHT();
bouncer.reset();
}
}


Attach or link to any CAD files if relevant to your project.

Blog entry information

Author
julian160784@gmail.com
Views
401
Last update

More entries in General

More entries from julian160784@gmail.com

Share this entry

Top