ujjval rathod
Published

ML based Wildfire detection and early warning system

Sensor and location based system for wildfire preditions

BeginnerProtip261
ML based Wildfire detection and early warning system

Things used in this project

Story

Read more

Code

Sensor testing

Arduino
It is an Arduino code to interface sensors such as Air Quality and temperature together to send data further to the cloud platform
#include <Arduino.h>
#include "Adafruit_SHT4x.h"
#include "SparkFun_SGP30_Arduino_Library.h"
#include <Wire.h>
#include <rpcWiFi.h>


SGP30 AirQ;
Adafruit_SHT4x Weather = Adafruit_SHT4x();

long t1, t2;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin();
  Wire.setClock(400000);
  
  while (!Serial){
    delay(10);
    }
    
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  
  
  
  if(AirQ.begin() == false){
    Serial.println("No SPG30 detected. Check connections. ");
    while(1);
    }
  AirQ.initAirQuality();
  t1 = millis();
  
  if(! Weather.begin()) {
    Serial.println("Could't find Weather sensor");
    while (1) delay(1);
    }

    Weather.setPrecision(SHT4X_HIGH_PRECISION);
    Weather.setHeater(SHT4X_NO_HEATER);
    
}

void loop() {
  // put your main code here, to run repeatedly:

  int n = WiFi.scanNetworks();
  Serial.println("scan done");

  if (n==0) {
    
    }
  else{
    Serial.println(n);
    for (int i=0; i< n; i++)
    {
      Serial.print(WiFi.SSID(i));
    }
    }
  
  
  //First AirQ measures
  t2 = millis();

  if ( t2 >= t1 + 1000)
  {
    t1 = t2;
    AirQ.measureAirQuality();

    Serial.print("CO2 ");
    Serial.print(AirQ.CO2);
    Serial.print("ppm\tTVOC: ");
    Serial.print(AirQ.TVOC);
    Serial.println(" ppb"); 
    
    //get raw values for H2 and Ethanol

     AirQ.measureRawSignals();
     Serial.print("Raw H2: ");
     Serial.print(AirQ.H2);
     Serial.print(" \tRaw Ethanol: ");
     Serial.println(AirQ.ethanol);    
    
  }

  sensors_event_t humidity, temp;
  Weather.getEvent(&humidity, &temp);

  Serial.print("Temprature:  "); Serial.print(temp.temperature); Serial.println(" degree C");
  Serial.print("Humidity:  "); Serial.print(humidity.relative_humidity); Serial.println(" % rH");

  delay(1000);

}

Credits

ujjval rathod

ujjval rathod

10 projects • 19 followers

Comments