hello i made an air quality monitor using the aircasting model. With an Arduino Mega and it transmits the sensor data to the aircasting mobile app via the BlueSmirf Silver bluetooth module. for now i just attached the CO sensor (Figaro TGS2442).
my problem is that it worked at first but now it isn't. The bluetooth module connected well and the data was displayed properly for a couple of days.
then sudenly one day it wasn't powering up for awhile. however i didn't have to change anything but it randomly powered up when i reuploaded the sketch. it also connects to the mobile. the red light turns green. but seems like it is not transmitting the data even though it is connected cause the app does not receive any data. Any idea on what's going on? should i reset the bluetooth module? if so how should i do that?
The schematic diagram is according to this :http://habitatmap.org/habitatmap_docs/HowToBuildAnAirCastingAirMonitor.pdf
and the code is as follows:
#include <SoftwareSerial.h> //Header for software serial communication
SoftwareSerial mySerial(2, 3); //Assign 2 as Rx and 3 as Tx
float maxv, CO;
int circ = 5, heat = 6;
void setup()
{
Serial.begin(115200); //Serial communication for Arduino Serial Monitor
mySerial.begin(115200); //Serial communcation for Aircasting Application
pinMode(circ, OUTPUT);
pinMode(heat, OUTPUT);
}
void loop()
{
//call up the calculation functions
GetCO();
//Display of CO gas sensor
mySerial.print(CO);
mySerial.print(";InsertSensorPackageName;TGS2442;CO Gas;CO;response indicator;RI;0;25;50;75;100");
mySerial.print("\n");
Serial.print("CO Gas: ");
Serial.print(CO);
Serial.print("% ");
//Display of temperature in K, C, and F
/*
mySerial.print(kelv);
mySerial.print(";InsertSensorPackageName;TMP36;Temperature;K;kelvin;K;273;300;400;500;600");
mySerial.print("\n");
mySerial.print(cel);
mySerial.print(";InsertSensorPackageName;TMP36;Temperature;C;degrees Celsius;C;0;10;15;20;25");
mySerial.print("\n");
*/
}
void GetCO()
{
digitalWrite(circ, LOW);
analogWrite(heat, 245);
delay(14);
analogWrite(heat, 0);
delay(981);
digitalWrite(circ, HIGH);
delay(3);
float val1 = analogRead(A1);
CO = map(val1, 0 , 1023, 0, 100);
}
float map(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}