Smart Environment - incorrect measurements

dareid
Posts: 5
Joined: Thu Mar 26, 2015 1:34 pm

Smart Environment - incorrect measurements

Post by dareid » Thu Mar 26, 2015 1:48 pm

Hi,

We have set up a smart environment plug & sense with the following configuration:
Socket A : Temperature
Socket B : Humidity
Socket C : CO2
Socket D : NO2
Socket E : VOC
Socket F : NH3

We used the auto code generator to create the code to read the sensor readings, this was tweaked slightly to send the data to thingspeak. The mote was deployed in a field in the UK and we have been receiving very incorrect readings. In addition, all the sensor readings appear to have similar trends with the same peaks and troughs. The data can be seen at https://thingspeak.com/channels/31255. Most noticeably the temperature and humidity are incorrect, I can assure you it is not 40 degrees in the UK at the moment :) .

The code we are using is below. I have excluded the code which we send to thingspeak, we have verified that the values being sent to thingspeak match those being reported over USB.
In addition, we have tested gathering two sensor readings per sensor and disposing of the first (like in the auto generated code) however that made no difference. We have also experimented with starting all the sensors at the start of the loop instead of just when they are needed - this also made no difference.

I suspect there is a hardware issue with the mote as the sensor readings are so incorrect. We have deployed the smart agriculture and smart agriculture pro and have not seen any problems like this.

Code: Select all


#include <WaspSensorGas_v20.h>
              
char  nodeID[10] = "SPADE001";
// ~2 minutes spent waiting during recording
char* sleepTime = "00:00:13:00";  

char  CONNECTOR_A[3] = "CA";             
char  CONNECTOR_B[3] = "CB";          
char  CONNECTOR_C[3] = "CC";
char  CONNECTOR_D[3] = "CD";
char  CONNECTOR_E[3] = "CE";
char  CONNECTOR_F[3] = "CF";

long  sequenceNumber = 0;  
                                       
char data[100]; 
char logdata[100];

float connectorAFloatValue;          
float connectorBFloatValue;         
float connectorCFloatValue;          
float connectorDFloatValue;        
float connectorEFloatValue;
float connectorFFloatValue;

char  connectorAString[10];          
char  connectorBString[10];      
char  connectorCString[10];
char  connectorDString[10];
char  connectorEString[10];
char  connectorFString[10];

int   batteryLevel;
char  batteryLevelString[10];
char  BATTERY[4] = "BAT";

char  TIME_STAMP[3] = "TS";

void setup() 
{
    USB.ON(); 
    USB.println(F("Starting up.."));
    
    RTC.ON();
    RTC.clearAlarmFlag();
    RTC.OFF();
    
    sprintf(logdata, "Waspmote node %s start", nodeID);
    USB.println(logdata);
    USB.OFF();
}

void loop()
{
    SensorGasv20.ON();
    RTC.ON();
    //supply stabilization delay
    delay(100);
    
    //wait for humidity and temp sensors
    delay(15000);

    // Getting Battery Level
    batteryLevel = PWR.getBatteryLevel();
    itoa(batteryLevel, batteryLevelString, 10);

    // Temperature
    connectorAFloatValue = SensorGasv20.readValue(SENS_TEMPERATURE);
    Utils.float2String(connectorAFloatValue, connectorAString, 2);

    // Humidity
    connectorBFloatValue = SensorGasv20.readValue(SENS_HUMIDITY);
    Utils.float2String(connectorBFloatValue, connectorBString, 2);

    // C02   
    SensorGasv20.configureSensor(SENS_CO2, 7);   
    SensorGasv20.setSensorMode(SENS_ON, SENS_CO2);   
    delay(50000);
    connectorCFloatValue = SensorGasv20.readValue(SENS_CO2);  
    SensorGasv20.setSensorMode(SENS_OFF, SENS_CO2);        
    Utils.float2String(connectorCFloatValue, connectorCString, 2);

    // NO2 
    SensorGasv20.configureSensor(SENS_SOCKET3B, 1, 2);
    SensorGasv20.setSensorMode(SENS_ON, SENS_SOCKET3B);    
    delay(40000);
    connectorDFloatValue = SensorGasv20.readValue(SENS_SOCKET3B);    
    SensorGasv20.setSensorMode(SENS_OFF, SENS_SOCKET3B);
    Utils.float2String(connectorDFloatValue, connectorDString, 2);

    // VOC
    SensorGasv20.configureSensor(SENS_SOCKET2B, 1, 100);
    SensorGasv20.setSensorMode(SENS_ON, SENS_SOCKET2B);
    delay(40000);
    connectorEFloatValue = SensorGasv20.readValue(SENS_SOCKET2B);  
    SensorGasv20.setSensorMode(SENS_OFF, SENS_SOCKET2B);  
    Utils.float2String(connectorEFloatValue, connectorEString, 2);

    // NH3
    SensorGasv20.configureSensor(SENS_SOCKET4NH3, 1, 10);
    delay(20);
    connectorFFloatValue = SensorGasv20.readValue(SENS_SOCKET4NH3);  
    Utils.float2String(connectorFFloatValue, connectorFString, 2);

    //Data payload composition
    sprintf(data,"I:%s;N:%li;%s:%s;%s:%s;%s:%s;%s:%s;%s:%s;%s:%s;%s:%s;%s:%s",
	nodeID ,
	sequenceNumber,
	BATTERY, batteryLevelString,
	TIME_STAMP, RTC.getTimestamp(),
	CONNECTOR_A , connectorAString,
	CONNECTOR_B , connectorBString,
	CONNECTOR_C , connectorCString,
	CONNECTOR_D , connectorDString,
	CONNECTOR_E , connectorEString,
	CONNECTOR_F , connectorFString);

    USB.ON();
    USB.println(data);
    
    USB.OFF();
    RTC.OFF();
    SensorGasv20.OFF();

    // Enter Sleep Mode
    PWR.deepSleep(sleepTime,RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);
    //Increase the sequence number after wake up
    sequenceNumber++;


}

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Smart Environment - incorrect measurements

Post by libelium-dev » Fri Mar 27, 2015 9:09 am

Hello dareid,

try to filter the values by software, measuring it many times and calculating the average value to filter these spikes.
 // read the sensor many times.
  for(uint8_t i; i<NUMBER_OF_SAMPLES; i++)
  {
    connectorAFloatValue = connectorAFloatValue + SensorGasv20.readValue(SENS_TEMPERATURE);
    delay(10);
  }

  // Calculate average value.
  connectorAFloatValue = connectorAFloatValue / NUMBER_OF_SAMPLES;
Regards.

dareid
Posts: 5
Joined: Thu Mar 26, 2015 1:34 pm

Re: Smart Environment - incorrect measurements

Post by dareid » Mon Mar 30, 2015 1:12 pm

The readings we get from the temperature sensor are always incorrect, so I do not think averaging is going to help. You can see from the CA graph in the thingspeak channel that the temperature is always over 20 degrees C which is not correct for UK in March.

The data collected is also extremely correlated - this is very hard to believe.

I have been trying lots of things with the code and having no luck. Could this be a hardware issue?

Dan

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Smart Environment - incorrect measurements

Post by libelium-dev » Mon Mar 30, 2015 4:08 pm

Hello dareid,

we don't know which is the cause of this behaviour, let's check some aspects to find the problem:
please measure only temperature and humidity, disconnect the other sensors and let us know the results.

Thanks.

dareid
Posts: 5
Joined: Thu Mar 26, 2015 1:34 pm

Re: Smart Environment - incorrect measurements

Post by dareid » Wed Apr 01, 2015 11:44 am

Thanks for the suggestion.

I have tried removing all sensors except for the temperature and humidity, including removing the associated code. I am still receiving incorrect readings similar to those seen in the thingspeak link previously.

Dan

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Smart Environment - incorrect measurements

Post by libelium-dev » Wed Apr 01, 2015 12:45 pm

Have you checked the sensors are well connected?

Thanks.

dareid
Posts: 5
Joined: Thu Mar 26, 2015 1:34 pm

Re: Smart Environment - incorrect measurements

Post by dareid » Wed Apr 01, 2015 1:05 pm

Yes the sensors are securely connected

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Smart Environment - incorrect measurements

Post by libelium-dev » Wed Apr 01, 2015 1:40 pm

Hello dareid,

Try with this basic example, not sending data neither sleeping waspmote,only show data in the serial monitor.
#include <WaspSensorGas_v20.h>


char CONNECTOR_A[3] = "CA";
char CONNECTOR_B[3] = "CB";
                                                       
char data[100];

float connectorAFloatValue;
float connectorBFloatValue;

int connectorAIntValue;
int connectorBIntValue;

char connectorAString[10];
char connectorBString[10];


void setup()
{

//  Communication  ON

    USB.ON();
    // Initial message composition

    sprintf(data,"Hello, this is Waspmote Plug & Sense!\r\n");

//  Initial message transmission

    USB.println(data);
    
    //Turn on the sensor board
    SensorGasv20.ON();
    
    //supply stabilization delay
    delay(5000);

}


void loop()
{


//  Read the sensors

    //First dummy reading for analog-to-digital converter channel selection
    SensorGasv20.readValue(SENS_TEMPERATURE);
    //Sensor temperature reading
    connectorAFloatValue = SensorGasv20.readValue(SENS_TEMPERATURE);
    //Conversion into a string
    Utils.float2String(connectorAFloatValue, connectorAString, 2);

    //First dummy reading for analog-to-digital converter channel selection
    SensorGasv20.readValue(SENS_HUMIDITY);
    //Sensor temperature reading
    connectorBFloatValue = SensorGasv20.readValue(SENS_HUMIDITY);
    //Conversion into a string
    Utils.float2String(connectorBFloatValue, connectorBString, 2);

//  Turn off the sensors

//  Message composition

    //Data payload composition
    sprintf(data,"I:%s#N:%li#%s:%s#%s:%s\r\n",
nodeID ,
sequenceNumber,
CONNECTOR_A , connectorAString,
CONNECTOR_B , connectorBString);


//  Message transmission

    USB.println(data);

}
Let us know the results.

Thanks.

dareid
Posts: 5
Joined: Thu Mar 26, 2015 1:34 pm

Re: Smart Environment - incorrect measurements

Post by dareid » Wed Apr 01, 2015 2:14 pm

I had to edit your code slightly as node and sequence ID was not defined. The results we got are incorrect, it seemed to spend a couple of seconds stabilising, then the readings were consistently :

Code: Select all

CA:-38.38#CB:-19.73
Dan

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Smart Environment - incorrect measurements

Post by libelium-dev » Mon Apr 06, 2015 1:43 pm

Hello dareid,

It seems that there could be a hardware issue on your device. Please contact our colleagues of technical support to start a RMA process to repair your device.

http://www.libelium.com/contact/#RMA

Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest