loading

This is an at home device to assess damage done to your home while you are not there.

You will need:

1 Intel Edison board

2 Seeed Base board

3 Seeed dust sensor

4 Seeed Gas sensor

5 Seeed water sensor

6 Seeed temperature sensor

7 Seeed flame sensor

8 AT&T M2X account (Free)

Step 1: Set Up Your Intel Edison

Follow the instructions on this link https://software.intel.com/en-us/assembling-intel-edison-board-with-arduino-expansion-board

Step 2: Set Up Your AT&T M2X Account

follow the simple instructions here https://m2x.att.com/developer/get-started

Step 3: Connect the Parts

Plug dust sensor into D4

Plug gas sensor into A0

Plug temperature into A1

Plug vibration sensor into A3

Plug water sensor into D2

Plug flame sensor into D5

Step 4: Copy Code and Run!

Copy this code into your arduino IDE, then run and you are ready to go!

Be sure to add your own wifi and api keys

#include
#include #include #include "M2XStreamClient.h" #include #define WATER_SENSOR 2 #define BUZZER 12 #define FLAME_SENSOR 5 //connect SENSOR to digital pin3 int a; float temperature; int B=3975; //B value of the thermistor float resistance;

int pin = 8; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 30000;//sampe 30s ; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; char ssid[] = "Intel 2.4 GHz"; // your network SSID (name) char pass[] = "wifipass here"; int status = WL_IDLE_STATUS; char feedId[] = "your feed here"; char deviceId[] = "your device here"; // Device you want to push to

char m2xKey[] = "your key here"; // Your M2X access key const int temperaturePin = 0;

WiFiClient client; M2XStreamClient m2xClient(&client, m2xKey);

void setup() { Serial.begin(115200); pinMode(8,INPUT); starttime = millis();//get the current time; if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); while(true); } while ( status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); } Serial.println("Connected to wifi"); printWifiStatus(); }

void loop() {

EarthQuake();

}

void GasSensor(){ float vol; int sensorValue = analogRead(A0); vol=(float)sensorValue/1024; Serial.print("The gas density is "); Serial.println(vol); delay(100); int response = m2xClient.updateStreamValue(deviceId, "gas", vol); Serial.print("M2x client response code: "); Serial.println(response); }

void tempSensor() { a=analogRead(1); resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor; temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;//convert to temperature via datasheet ; delay(1000); Serial.print("Current temperature is "); Serial.println(temperature*1.8+32); int response = m2xClient.updateStreamValue(deviceId, "temp", temperature*1.8+32); Serial.print("M2x client response code: "); Serial.println(response); }

void DustSensor() { duration = pulseIn(pin, LOW); lowpulseoccupancy = lowpulseoccupancy+duration;

if ((millis()-starttime) > sampletime_ms)//if the sampel time == 30s { ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve // Serial.print(lowpulseoccupancy); // Serial.print(","); // Serial.print(ratio); Serial.print("Dust concentration is: "); Serial.println(concentration); lowpulseoccupancy = 0; starttime = millis(); int response = m2xClient.updateStreamValue(deviceId, "dust", concentration); Serial.print("M2x client response code: "); Serial.println(response); } }

void myFlame() { if(isFlameDetected()) { int response = m2xClient.updateStreamValue(deviceId, "Fire", "1"); Serial.print("M2x client response code: "); Serial.println(response); turnOnLED(); } else turnOffLED(); int response = m2xClient.updateStreamValue(deviceId, "Fire", "0"); Serial.print("M2x client response code: "); Serial.println(response); }

void pinsInit() { pinMode(FLAME_SENSOR, INPUT); pinMode(WATER_SENSOR, INPUT); pinMode(BUZZER, OUTPUT); } void turnOnLED() { //digitalWrite(LED,HIGH); Serial.println("Flame Detected!!!"); } void turnOffLED() { //digitalWrite(LED,LOW); Serial.println("No flame detected"); } boolean isFlameDetected() { if(digitalRead(FLAME_SENSOR)) return false; else return true; }

boolean isExposedToWater() { if(digitalRead(WATER_SENSOR) == LOW) return true; else return false; }

void MyWater() { if(isExposedToWater()){ Serial.println("Water is detected!!!"); int response = m2xClient.updateStreamValue(deviceId, "water", "1"); Serial.print("M2x client response code: "); Serial.println(response);} else { Serial.println("No water is being detected."); int response = m2xClient.updateStreamValue(deviceId, "water", "0"); Serial.print("M2x client response code: "); Serial.println(response);} }

void soundAlarm() { for(uint8_t i = 0;i < 20;i ++) { digitalWrite(BUZZER, HIGH); delay(50); digitalWrite(BUZZER, LOW); delay(50); } }

void EarthQuake() { { int sensorValue = analogRead(A3); Serial.println(sensorValue); delay(1000); if(sensorValue>=1008) { Serial.println("Tremor detected!"); GasSensor(); tempSensor(); DustSensor(); myFlame(); isExposedToWater(); MyWater(); } else { } } } void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your WiFi shield's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); // print the received signal strength: long rssi = WiFi.RSSI(); Serial.print("signal strength (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); } //float getVoltage(int pin) //{ //return (analogRead(pin) * 0.004882814); //} void waitMicros(int val) { unsigned long a = micros(); unsigned long b = micros(); while((b-a) < val) { b = micros(); if(a>b) { break; } } }

<p>Nice edison project. Thanks for sharing. </p>

About This Instructable

312views

6favorites

More by JustinZ1:At-home Earthquake Damage Assessment  
Add instructable to: