A Wireless Telemetry System which consists of a LM35 Temperature Sensor, A BMP085 Barometric Pressure Sensor, A DHT22 Humidity Sensor, An LDR, A DS1307 RTC and a Air Quality Sensor.
Transmitter Side Code:
int ledPin = 12;
int buzzerPin = 13;
int tempC;
int tempPin = 0;
int ldrPin = 1;
int brightness = 0;
int light_intensity = 0;
int pressure = 0;
int altitude = 0;
int humidity = 0;
int air_quality_sensor_pin = 2;
int toxicity = 0;
#include "Wire.h"
#include "Adafruit_BMP085.h"
Adafruit_BMP085 bmp;
#include "dht22.h"
#define DHT22_PIN 3 //DHT22 Sensor pin Connected to pin 3 of Arduino
DHT22 myDHT22(DHT22_PIN);
#include "RTClib.h"
RTC_DS1307 RTC;
void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
bmp.begin();
RTC.begin();
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
tempC = analogRead(tempPin); //read the value from the sensor
delay(20);
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0) / 1024.0; //convert the analog data to temperature
brightness = analogRead(ldrPin);
delay(20);
brightness = analogRead(ldrPin);
light_intensity = map(brightness, 0, 1023, 99, 0);
toxicity = analogRead(air_quality_sensor_pin);
delay(20);
toxicity = analogRead(air_quality_sensor_pin);
toxicity = map(toxicity, 150, 800, 0, 100);
pressure = bmp.readPressure(); //get the Pressure from the BMP085 Sensor
altitude = bmp.readAltitude(); //Calculate Altitude based on the Pressure Reading
DHT22_ERROR_t errorCode;
errorCode = myDHT22.readData();
humidity = myDHT22.getHumidity(); //Get the Humidity Reding from Humidity Sensor
DateTime now = RTC.now();
int current_year = now.year();
int current_month = now.month();
int current_day = now.day();
int current_hour = now.hour();
int current_minute = now.minute();
int current_second = now.second();
Serial.write('<');
Serial.print(tempC);
//Serial.print(" *C");
Serial.write('>');
Serial.print(light_intensity);
//Serial.print(" % Bright");
Serial.write(']');
Serial.print(bmp.readPressure() / 1000);
//Serial.print(" KPascal");
Serial.write('[');
Serial.print(int(bmp.readAltitude()));
//Serial.print(" Meter");
Serial.write('}');
Serial.print(humidity);
//Serial.print(" % RH");
Serial.write('{');
Serial.print(toxicity);
//Serial.print(" % Toxic");
Serial.write('+');
Serial.print(current_year);
Serial.write('-');
Serial.print(current_month);
Serial.write('*');
Serial.print(current_day);
Serial.write('/');
Serial.print(current_hour);
Serial.write('!');
Serial.print(current_minute);
Serial.write('@');
Serial.print(current_second);
Serial.write('#');
delay(2000); //wait one second before sending new data
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(50);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
long int uptime = millis();
if (uptime > 20000) {
if (toxicity > 50 ) {
digitalWrite(buzzerPin, HIGH);
}
else {
digitalWrite(buzzerPin, LOW);
}
}
}
Receiver Side Code:
#include "LiquidCrystal.h"
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define IDLE 0
#define RECEIVING1 1
#define RECEIVING2 2
#define RECEIVING3 3
#define RECEIVING4 4
#define RECEIVING5 5
#define RECEIVING6 6
#define RECEIVING7 7
#define RECEIVING8 8
#define RECEIVING9 9
#define RECEIVING10 10
#define RECEIVING11 11
#define RECEIVING12 12
int remote_temp = 0;
int remote_light_intensity = 0;
int remote_pressure = 0;
int remote_altitude = 0;
int remote_humidity = 0;
int remote_toxicity = 0;
int current_year = 0;
int current_month = 0;
int current_day = 0;
int current_hour = 0;
int current_minute = 0;
int current_second = 0;
byte status = IDLE;
void setup()
{
// initialize serial communication:
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
// following line sets the RTC to the date & time this sketch was compiled
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
void loop() {
long int uptime = millis();
if (Serial.available()) {
int c = Serial.read();
if (status == RECEIVING1 && c >= '0' && c <= '9') {
remote_temp = remote_temp * 10 + (c - '0');
} else if (status == RECEIVING2 && c >= '0' && c <= '9') {
remote_light_intensity = remote_light_intensity * 10 + (c - '0');
}
else if (status == RECEIVING3 && c >= '0' && c <= '9') {
remote_pressure = remote_pressure * 10 + (c - '0');
}
else if (status == RECEIVING4 && c >= '0' && c <= '9') {
remote_altitude = remote_altitude * 10 + (c - '0');
}
else if (status == RECEIVING5 && c >= '0' && c <= '9') {
remote_humidity = remote_humidity * 10 + (c - '0');
}
else if (status == RECEIVING6 && c >= '0' && c <= '9') {
remote_toxicity = remote_toxicity * 10 + (c - '0');
} else if (status == RECEIVING7 && c >= '0' && c <= '9') {
current_year = current_year * 10 + (c - '0');
current_year = current_year % 2000;
} else if (status == RECEIVING8 && c >= '0' && c <= '9') {
current_month = current_month * 10 + (c - '0');
} else if (status == RECEIVING9 && c >= '0' && c <= '9') {
current_day = current_day * 10 + (c - '0');
} else if (status == RECEIVING10 && c >= '0' && c <= '9') {
current_hour = current_hour * 10 + (c - '0');
} else if (status == RECEIVING11 && c >= '0' && c <= '9') {
current_minute = current_minute * 10 + (c - '0');
} else if (status == RECEIVING12 && c >= '0' && c <= '9') {
current_second = current_second * 10 + (c - '0');
}
else if (status == RECEIVING1 && c == '>') {
status = RECEIVING2;
} else if (status == RECEIVING2 && c == ']') {
status = RECEIVING3;
} else if (status == RECEIVING3 && c == '[') {
status = RECEIVING4;
} else if (status == RECEIVING4 && c == '}') {
status = RECEIVING5;
} else if (status == RECEIVING5 && c == '{') {
status = RECEIVING6;
} else if (status == RECEIVING6 && c == '+') {
status = RECEIVING7;
} else if (status == RECEIVING7 && c == '-') {
status = RECEIVING8;
} else if (status == RECEIVING8 && c == '*') {
status = RECEIVING9;
} else if (status == RECEIVING9 && c == '/') {
status = RECEIVING10;
} else if (status == RECEIVING10 && c == '!') {
status = RECEIVING11;
} else if (status == RECEIVING11 && c == '@') {
status = RECEIVING12;
} else if (c == '#') {
status = IDLE;
// remote value received completely, do something with it
if (uptime < 5000)
{
lcd.setCursor(0, 0);
lcd.print("Wireless Telemetry");
lcd.setCursor(0, 1);
lcd.print("By Debashish M. ");
} else if (uptime > 5000 && uptime < 20000) {
lcd.setCursor(0, 0);
lcd.print("System Starting.");
lcd.setCursor(0, 1);
lcd.print(current_day);
lcd.setCursor(2, 1);
lcd.print('/');
lcd.setCursor(3, 1);
lcd.print(current_month);
lcd.setCursor(5, 1);
lcd.print('/');
lcd.setCursor(6, 1);
lcd.print(current_year);
lcd.setCursor(8, 1);
lcd.print(' ');
lcd.setCursor(9, 1);
lcd.print(current_hour);
lcd.setCursor(11, 1);
lcd.print(':');
lcd.setCursor(12, 1);
lcd.print(current_minute);
lcd.setCursor(14, 1);
lcd.print(':');
lcd.setCursor(15, 1);
lcd.print(current_second);
}
else if (uptime < 25000 && uptime > 20000)
{
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
}
else {
lcd.setCursor(0, 0);
lcd.print(remote_temp);
lcd.setCursor(2, 0);
lcd.print((char)223);
lcd.setCursor(3, 0);
lcd.print("C");
lcd.setCursor(5, 0);
lcd.print(remote_light_intensity);
lcd.setCursor(7, 0);
lcd.print("%L");
lcd.setCursor(10, 0);
lcd.print(remote_pressure);
lcd.setCursor(13, 0);
lcd.print("KPa");
lcd.setCursor(0, 1);
lcd.print(remote_altitude);
lcd.setCursor(3, 1);
lcd.print("m");
lcd.setCursor(5, 1);
lcd.print(remote_humidity);
lcd.setCursor(7, 1);
lcd.print("RH");
lcd.setCursor(10, 1);
lcd.print(remote_toxicity);
lcd.setCursor(12, 1);
lcd.print(" %Txc");
}
} else if (c == '<') {
status = RECEIVING1;
remote_temp = 0;
remote_light_intensity = 0;
remote_pressure = 0;
remote_altitude = 0;
remote_humidity = 0;
remote_toxicity = 0;
current_year = 0;
current_month = 0;
current_day = 0;
current_hour = 0;
current_minute = 0;
current_second = 0;
}
}
}
The Report is given Here:
{pdf}http://iportal.mohapatra.rocks/images/stories/projects/Wireless Telemetry More Sensors.pdf|app:google {/pdf}