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.

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

 

Transmitter Side Code:

Arduino Code:
  1.  
  2.  
  3. int ledPin = 12;
  4. int buzzerPin = 13;
  5.  
  6. int tempC;
  7. int tempPin = 0;
  8. int ldrPin = 1;
  9. int brightness = 0;
  10. int light_intensity = 0;
  11.  
  12. int pressure = 0;
  13. int altitude = 0;
  14.  
  15. int humidity = 0;
  16.  
  17. int air_quality_sensor_pin = 2;
  18. int toxicity = 0;
  19.  
  20. #include "Wire.h"
  21. #include "Adafruit_BMP085.h"
  22. Adafruit_BMP085 bmp;
  23.  
  24. #include <DHT22.h>
  25.  
  26. #define DHT22_PIN 3 //DHT22 Sensor pin Connected to pin 3 of Arduino
  27. DHT22 myDHT22(DHT22_PIN);
  28.  
  29. #include "RTClib.h"
  30. RTC_DS1307 RTC;
  31.  
  32. void setup()
  33. {
  34. Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
  35. bmp.begin();
  36. RTC.begin();
  37. pinMode(ledPin, OUTPUT);
  38. pinMode(buzzerPin, OUTPUT);
  39.  
  40. }
  41.  
  42. void loop()
  43. {
  44.  
  45.  
  46. tempC = analogRead(tempPin); //read the value from the sensor
  47. delay(20);
  48. tempC = analogRead(tempPin); //read the value from the sensor
  49. tempC = (5.0 * tempC * 100.0) / 1024.0; //convert the analog data to temperature
  50.  
  51. brightness = analogRead(ldrPin);
  52. delay(20);
  53. brightness = analogRead(ldrPin);
  54. light_intensity = map(brightness, 0, 1023, 99, 0);
  55.  
  56. toxicity = analogRead(air_quality_sensor_pin);
  57. delay(20);
  58. toxicity = analogRead(air_quality_sensor_pin);
  59.  
  60. toxicity = map(toxicity, 150, 800, 0, 100);
  61.  
  62.  
  63. pressure = bmp.readPressure(); //get the Pressure from the BMP085 Sensor
  64.  
  65. altitude = bmp.readAltitude(); //Calculate Altitude based on the Pressure Reading
  66.  
  67. DHT22_ERROR_t errorCode;
  68. errorCode = myDHT22.readData();
  69. humidity = myDHT22.getHumidity(); //Get the Humidity Reding from Humidity Sensor
  70.  
  71. DateTime now = RTC.now();
  72. int current_year = now.year();
  73. int current_month = now.month();
  74. int current_day = now.day();
  75. int current_hour = now.hour();
  76. int current_minute = now.minute();
  77. int current_second = now.second();
  78.  
  79. Serial.write('<');
  80. Serial.print(tempC);
  81. //Serial.print(" *C");
  82. Serial.write('>');
  83. Serial.print(light_intensity);
  84. //Serial.print(" % Bright");
  85. Serial.write(']');
  86. Serial.print(bmp.readPressure() / 1000);
  87. //Serial.print(" KPascal");
  88. Serial.write('[');
  89. Serial.print(int(bmp.readAltitude()));
  90. //Serial.print(" Meter");
  91. Serial.write('}');
  92. Serial.print(humidity);
  93. //Serial.print(" % RH");
  94. Serial.write('{');
  95. Serial.print(toxicity);
  96. //Serial.print(" % Toxic");
  97. Serial.write('+');
  98.  
  99. Serial.print(current_year);
  100. Serial.write('-');
  101. Serial.print(current_month);
  102. Serial.write('*');
  103. Serial.print(current_day);
  104. Serial.write('/');
  105. Serial.print(current_hour);
  106. Serial.write('!');
  107. Serial.print(current_minute);
  108. Serial.write('@');
  109. Serial.print(current_second);
  110. Serial.write('#');
  111.  
  112.  
  113.  
  114. delay(2000); //wait one second before sending new data
  115. digitalWrite(ledPin, HIGH);
  116. delay(50);
  117. digitalWrite(ledPin, LOW);
  118. delay(50);
  119. digitalWrite(ledPin, HIGH);
  120. delay(50);
  121. digitalWrite(ledPin, LOW);
  122.  
  123. long int uptime = millis();
  124. if (uptime > 20000) {
  125. if (toxicity > 50 ) {
  126. digitalWrite(buzzerPin, HIGH);
  127. }
  128. else {
  129. digitalWrite(buzzerPin, LOW);
  130. }
  131. }
  132. }
  133.  

Receiver

 

Receiver Side Code:

Arduino Code:
  1.  
  2. #include "LiquidCrystal.h"
  3. LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
  4.  
  5. #define IDLE 0
  6. #define RECEIVING1 1
  7. #define RECEIVING2 2
  8. #define RECEIVING3 3
  9. #define RECEIVING4 4
  10. #define RECEIVING5 5
  11. #define RECEIVING6 6
  12. #define RECEIVING7 7
  13. #define RECEIVING8 8
  14. #define RECEIVING9 9
  15. #define RECEIVING10 10
  16. #define RECEIVING11 11
  17. #define RECEIVING12 12
  18.  
  19. int remote_temp = 0;
  20. int remote_light_intensity = 0;
  21. int remote_pressure = 0;
  22. int remote_altitude = 0;
  23. int remote_humidity = 0;
  24. int remote_toxicity = 0;
  25.  
  26. int current_year = 0;
  27. int current_month = 0;
  28. int current_day = 0;
  29. int current_hour = 0;
  30. int current_minute = 0;
  31. int current_second = 0;
  32.  
  33.  
  34. byte status = IDLE;
  35.  
  36. void setup()
  37. {
  38. // initialize serial communication:
  39. Serial.begin(9600);
  40. lcd.begin(16, 2);
  41. lcd.clear();
  42. // following line sets the RTC to the date & time this sketch was compiled
  43. //RTC.adjust(DateTime(__DATE__, __TIME__));
  44. }
  45.  
  46. void loop() {
  47. long int uptime = millis();
  48. if (Serial.available()) {
  49. int c = Serial.read();
  50. if (status == RECEIVING1 && c >= '0' && c <= '9') {
  51. remote_temp = remote_temp * 10 + (c - '0');
  52.  
  53. } else if (status == RECEIVING2 && c >= '0' && c <= '9') {
  54. remote_light_intensity = remote_light_intensity * 10 + (c - '0');
  55.  
  56. }
  57. else if (status == RECEIVING3 && c >= '0' && c <= '9') {
  58. remote_pressure = remote_pressure * 10 + (c - '0');
  59.  
  60. }
  61. else if (status == RECEIVING4 && c >= '0' && c <= '9') {
  62. remote_altitude = remote_altitude * 10 + (c - '0');
  63.  
  64. }
  65. else if (status == RECEIVING5 && c >= '0' && c <= '9') {
  66. remote_humidity = remote_humidity * 10 + (c - '0');
  67.  
  68. }
  69. else if (status == RECEIVING6 && c >= '0' && c <= '9') {
  70. remote_toxicity = remote_toxicity * 10 + (c - '0');
  71.  
  72. } else if (status == RECEIVING7 && c >= '0' && c <= '9') {
  73. current_year = current_year * 10 + (c - '0');
  74. current_year = current_year % 2000;
  75. } else if (status == RECEIVING8 && c >= '0' && c <= '9') {
  76. current_month = current_month * 10 + (c - '0');
  77. } else if (status == RECEIVING9 && c >= '0' && c <= '9') {
  78. current_day = current_day * 10 + (c - '0');
  79. } else if (status == RECEIVING10 && c >= '0' && c <= '9') {
  80. current_hour = current_hour * 10 + (c - '0');
  81. } else if (status == RECEIVING11 && c >= '0' && c <= '9') {
  82. current_minute = current_minute * 10 + (c - '0');
  83. } else if (status == RECEIVING12 && c >= '0' && c <= '9') {
  84. current_second = current_second * 10 + (c - '0');
  85. }
  86.  
  87.  
  88.  
  89. else if (status == RECEIVING1 && c == '>') {
  90. status = RECEIVING2;
  91. } else if (status == RECEIVING2 && c == ']') {
  92. status = RECEIVING3;
  93. } else if (status == RECEIVING3 && c == '[') {
  94. status = RECEIVING4;
  95. } else if (status == RECEIVING4 && c == '}') {
  96. status = RECEIVING5;
  97. } else if (status == RECEIVING5 && c == '{') {
  98. status = RECEIVING6;
  99. } else if (status == RECEIVING6 && c == '+') {
  100. status = RECEIVING7;
  101. } else if (status == RECEIVING7 && c == '-') {
  102. status = RECEIVING8;
  103. } else if (status == RECEIVING8 && c == '*') {
  104. status = RECEIVING9;
  105. } else if (status == RECEIVING9 && c == '/') {
  106. status = RECEIVING10;
  107. } else if (status == RECEIVING10 && c == '!') {
  108. status = RECEIVING11;
  109. } else if (status == RECEIVING11 && c == '@') {
  110. status = RECEIVING12;
  111. } else if (c == '#') {
  112. status = IDLE;
  113.  
  114. // remote value received completely, do something with it
  115. if (uptime < 5000)
  116. {
  117.  
  118. lcd.setCursor(0, 0);
  119. lcd.print("Wireless Telemetry");
  120. lcd.setCursor(0, 1);
  121. lcd.print("By Debashish M. ");
  122. } else if (uptime > 5000 && uptime < 20000) {
  123. lcd.setCursor(0, 0);
  124. lcd.print("System Starting.");
  125.  
  126. lcd.setCursor(0, 1);
  127. lcd.print(current_day);
  128. lcd.setCursor(2, 1);
  129. lcd.print('/');
  130. lcd.setCursor(3, 1);
  131. lcd.print(current_month);
  132. lcd.setCursor(5, 1);
  133. lcd.print('/');
  134. lcd.setCursor(6, 1);
  135. lcd.print(current_year);
  136.  
  137. lcd.setCursor(8, 1);
  138. lcd.print(' ');
  139.  
  140. lcd.setCursor(9, 1);
  141. lcd.print(current_hour);
  142. lcd.setCursor(11, 1);
  143. lcd.print(':');
  144. lcd.setCursor(12, 1);
  145. lcd.print(current_minute);
  146. lcd.setCursor(14, 1);
  147. lcd.print(':');
  148. lcd.setCursor(15, 1);
  149. lcd.print(current_second);
  150.  
  151. }
  152. else if (uptime < 25000 && uptime > 20000)
  153. {
  154. lcd.setCursor(0, 0);
  155. lcd.print(" ");
  156. lcd.setCursor(0, 1);
  157. lcd.print(" ");
  158. }
  159. else {
  160. lcd.setCursor(0, 0);
  161. lcd.print(remote_temp);
  162. lcd.setCursor(2, 0);
  163. lcd.print((char)223);
  164. lcd.setCursor(3, 0);
  165. lcd.print("C");
  166. lcd.setCursor(5, 0);
  167. lcd.print(remote_light_intensity);
  168. lcd.setCursor(7, 0);
  169. lcd.print("%L");
  170. lcd.setCursor(10, 0);
  171. lcd.print(remote_pressure);
  172. lcd.setCursor(13, 0);
  173. lcd.print("KPa");
  174.  
  175. lcd.setCursor(0, 1);
  176. lcd.print(remote_altitude);
  177. lcd.setCursor(3, 1);
  178. lcd.print("m");
  179. lcd.setCursor(5, 1);
  180. lcd.print(remote_humidity);
  181. lcd.setCursor(7, 1);
  182. lcd.print("RH");
  183. lcd.setCursor(10, 1);
  184. lcd.print(remote_toxicity);
  185. lcd.setCursor(12, 1);
  186. lcd.print(" %Txc");
  187. }
  188.  
  189. } else if (c == '<') {
  190. status = RECEIVING1;
  191.  
  192. remote_temp = 0;
  193. remote_light_intensity = 0;
  194. remote_pressure = 0;
  195. remote_altitude = 0;
  196. remote_humidity = 0;
  197. remote_toxicity = 0;
  198.  
  199. current_year = 0;
  200. current_month = 0;
  201. current_day = 0;
  202. current_hour = 0;
  203. current_minute = 0;
  204. current_second = 0;
  205. }
  206. }
  207. }
  208.  

Report


The Report is given Here: