Hi
We've been experimenting with a Gas Board connected to a Waspmote with also a GPS and GPRS module attached. Generally we've found it to be quite unstable, particulary during the Gas Sensor Section - see the code below:
Code:
char data[250];
int state;
int node_id;
int count;
int humidity, pressure, c02, n02, temperature;
boolean errorFlag = false;
void setup()
{
//** Start the clock **
RTC.begin(); // Executes the init process
//USB.begin();
//** Set up the GPS **
// set GPS on
GPS.setMode(GPS_ON);
// open the uart
GPS.begin();
// Inits the GPS module
GPS.init();
// waiting for GPS is connected to satellites
//while( !GPS.check() ) delay(1000);
Utils.blinkLEDs(1000); //1 blink shows that node is on and GPS is working
//USB.println("GPS Setup");
//Set up params
node_id = 55;
count = 0;
//** Set up the gas board **
SensorGas.setBoardMode(SENS_ON);
// setup for GPRS seial port
GPRS.begin();
GPRS.setMode(GPRS_ON);
//USB.println("GPRS Setup");
// waiting while GPRS connects to the network
while(!GPRS.check());
//USB.println("GPRS Connected to the network");
// configure SMS and Incoming Calls
if(!GPRS.setInfoIncomingCall()) errorFlag = true;
if(!GPRS.setInfoIncomingSMS()) errorFlag = true;
if(!GPRS.setTextModeSMS()) errorFlag = true;
Utils.blinkLEDs(1000); //2 blinks shows that the GPRS is connected and setup
Utils.blinkLEDs(1000);
delay(1000);
}
void loop()
{
//USB.println("Start Loop");
Utils.blinkLEDs(500); //3 blinks indicate start of loop
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
//** Obtain GPS coords **
GPS.getLatitude();
GPS.getLongitude();
Utils.blinkLEDs(500); //4 blinks for getting GPS Coords
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
//** Take gas readings **
humidity = (int)(1000*SensorGas.readValue(SENS_HUMIDITY));
delay(500);
SensorGas.setSensorMode(SENS_ON, SENS_PRESSURE);
delay(30);
pressure = (int)(1000*SensorGas.readValue(SENS_PRESSURE));
delay(500);
SensorGas.configureSensor(SENS_CO2, 100);
SensorGas.setSensorMode(SENS_ON, SENS_CO2);
delay(500);
c02 = (int)(1000*SensorGas.readValue(SENS_CO2));
SensorGas.setSensorMode(SENS_ON, SENS_NO2);
delay(500);
n02 = (int)(1000*SensorGas.readValue(SENS_NO2));
delay(500);
temperature = (int) (1000*SensorGas.readValue(SENS_TEMPERATURE));
//USB.println("Data gathered");
Utils.blinkLEDs(500); //5 blinks = sensor reading gathered
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
sprintf(data,"@@%d,C%d,T%d,B%d,X%s,Y%s,H%d,P%d,A%d,N%d##", node_id, count, temperature, PWR.getBatteryLevel(), GPS.longitude, GPS.latitude, humidity, pressure, c02, n02);
Utils.blinkLEDs(500); //6 blinks indicate data formatted correctly
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
if(GPRS.sendSMS(data,"0783234137"))
//USB.println("Sending SMS");
{ //Send message to gateway
Utils.blinkLEDs(500); //7 blinks indicate that SMS was sent
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
Utils.blinkLEDs(500);
//USB.println("SMS sent");
}
delay(20000);
count++;
}
Are we trying too much? Is there something we're doing wrong in the code?