Devices & Components
Arduino Mega 2560 Rev3
Arduino Uno Rev3
Infrared Receiver, 38 kHz
DHT11 Temperature & Humidity Sensor (4 pins)
Gravity: Digital Vibration Sensor
Infrared Emitter, 18 °
Arduino GSM shield V2
Hardware & Tools
Breadboard, 830 Tie Points
Soldering iron (generic)
Software & Tools
Arduino IDE
Project description
Code
FULLSEQUENCE.ino
arduino
1#include "SPI.h" 2#include <IRremote.h> 3#include "DHT.h" 4#define DHTTYPE DHT11 5#include <SoftwareSerial.h> 6#define DHTPIN 2 7 8 9DHT dht(DHTPIN, DHTTYPE); 10 11SoftwareSerial SIM800C(10,9); 12 13int receiverpin = 7; 14int vs =8; 15int buzzer = 5; 16int Buzzer; 17 18IRrecv irrecv(receiverpin); 19decode_results results; 20 21void setup() { 22 SIM800C.begin(9600); 23 dht.begin(); 24 pinMode(receiverpin, INPUT); 25 pinMode(vs, INPUT); 26 pinMode(buzzer,OUTPUT); 27 Serial.begin(9600); 28 irrecv.enableIRIn(); 29 beep(50); 30 beep(50); 31 beep(50); 32 Serial.begin(9600); 33 delay(1000); 34} 35 36 37void loop() { 38 irReceive(); 39 //readTemp(); 40 //vibrationSensor(); 41 if(Buzzer==1){ 42 int i=0; 43 for(i=0; i<=5; i++){ 44 beep(200); 45 } 46 Buzzer=0; 47 results.value=0; 48 } 49} 50void beep(unsigned char delayms){ 51 analogWrite(5, 20); 52 delay(delayms); 53 analogWrite(5, 0); 54 delay(delayms); 55} 56 57void vibrationSensor(){ 58 long measurement =vibration(); 59 measurement/100; 60 if (measurement > 30000){ 61 62 SendVS(); 63 } 64 delay(5000); 65} 66 67long vibration(){ 68 long measurement=pulseIn (vs, HIGH); //wait for the pin to get HIGH and returns measurement 69 return measurement; 70} 71 72void readTemp(){ 73 float t = dht.readTemperature(); 74 Serial.println(t); 75 if (isnan(t)) { 76 Serial.println(F("Failed to read from DHT sensor!")); 77 return; 78 79 } 80if(t>=37){ 81 SendTempmessage(); 82} 83delay(5000); 84} 85 86void irReceive(){ 87 if (irrecv.decode(&results)) 88 {if(results.value==629145||1341165347){ 89 Buzzer=1; 90 irrecv.resume(); 91 delay(2000); 92 }} 93} 94 95void SendTempmessage() 96{ 97 Serial.println ("Sending Message"); 98 SIM800C.println("AT+CMGF=1"); 99 delay(1000); 100 Serial.println ("Set SMS Number"); 101 SIM800C.println("AT+CMGS=\\"+639508788886\\"\ "); 102 delay(1000); 103 Serial.println ("Set SMS Content"); 104 SIM800C.println("Wearer A from Project Site A exceeds normal body temperature!"); 105 delay(100); 106 Serial.println ("Finish"); 107 SIM800C.println((char)26); 108 delay(1000); 109 Serial.println ("Message has been sent"); 110} 111 112void SendVS() 113{ 114 Serial.println ("Sending Message"); 115 SIM800C.println("AT+CMGF=1"); 116 delay(1000); 117 Serial.println ("Set SMS Number"); 118 SIM800C.println("AT+CMGS=\\"+639508788886\\"\ "); 119 delay(1000); 120 Serial.println ("Set SMS Content"); 121 SIM800C.println("Wearer A from Project Site A just had an Accident!"); 122 delay(100); 123 Serial.println ("Finish"); 124 SIM800C.println((char)26); 125 delay(1000); 126 Serial.println ("Message has been sent"); 127} 128
Downloadable files
Automated PPE Code
Automated PPE Code
Comments
Only logged in users can leave comments