I have a little problem with the sleep mode.
I'm working with the 2.1.5 version and I'm working with the dynamic approach.
I'm measuring the current absorbed by the device and I see that it's constantly at 32 mA , even I place the zunoSendDeviceToSleep() command.
Note that I'm using an oscilloscope with a current probe very sensible.
I don't understand how could I put my device in sleep in order to reduce the current consumption...
Here is my code... what's wrong?
Code: Select all
#include <Wire.h>
#define MAP_TO_ZEROCHANNEL 0x80
//MICS
#define MICS_VZ_89TE_ADDR 0x70 //0x70 default I2C address
//registers
#define MICS_VZ_89TE_ADDR_CMD_GETSTATUS 0x0C // This command is used to read the VZ89 status coded with 6 bytes:
#define MICS_VZ_89TE_DATE_CODE 0x0D
ZUNO_DYNAMIC_CHANNELS(3);
ZUNO_ENABLE(WITH_CC_SENSOR_MULTILEVEL);
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);
void setup(){
delay(1000);
// DEFINIZIONE DELLA GESTIONE DINAMICA DEI CANALI
ZUNO_START_CONFIG();
ZUNO_SET_ZWCHANNEL(MAP_TO_ZEROCHANNEL| 1); // <- this channel will be provided via 1 & 0 channels
ZUNO_ADD_CHANNEL(ZUNO_SENSOR_MULTILEVEL_CHANNEL_NUMBER, ZUNO_SENSOR_MULTILEVEL_TYPE_CO2_LEVEL, SENSOR_MULTILEVEL_PROPERTIES_COMBINER( SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS));
ZUNO_SET_ZWCHANNEL(2);
ZUNO_ADD_CHANNEL(ZUNO_SENSOR_MULTILEVEL_CHANNEL_NUMBER, ZUNO_SENSOR_MULTILEVEL_TYPE_CO2_LEVEL, SENSOR_MULTILEVEL_PROPERTIES_COMBINER( SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS));
ZUNO_COMMIT_CONFIG();
//...
Wire.begin();
Serial.begin(115200);
}
void loop(){
int i=0;
int data[7];
unsigned int CO2=0;
unsigned int VOC=0;
float CO2f=0.0;
float VOCf=0.0;
float statoS;
/*
Wire.requestFrom(0x70,7);
i=0;
while(Wire.available()){
data[i++] = Wire.read();
}
*/
Wire.beginTransmission((uint8_t)MICS_VZ_89TE_ADDR);
Wire.write((uint8_t)MICS_VZ_89TE_ADDR_CMD_GETSTATUS); //This send the command to get data
Wire.write(0x0);
Wire.write(0x0);
Wire.write(0x0);
Wire.write(0x0);
Wire.write(0x0);
Wire.endTransmission();
Wire.beginTransmission(0xE1);
Wire.endTransmission();
Wire.requestFrom((uint8_t)0x70, (byte)7);
for (i=0; i<7; i++) {
data[i] = Wire.read();
}
//VOC = ((data[0]) - 13)*(1000/229); // ppb: 0 .. 1000
//CO2 = (data[1] - 13)*(1600/229)+400; // ppm: 400 .. 2000ù
statoS = data[5];
CO2f = (data[1] - 13) * (1600.0 / 229) + 400; // ppm: 400 .. 2000
VOCf = (data[0] - 13) * (1000.0/229); // ppb: 0 .. 1000
//CO2 = (data[1] - 13) * (1600.0 / 229) + 400; // ppm: 400 .. 2000
//VOC = (data[0] - 13) * (1000.0/229); // ppb: 0 .. 1000
CO2=(unsigned int) CO2f;
VOC=(unsigned int) VOCf;
if(VOC<0) VOCf=0;
if(CO2<400) CO2f=400;
if(VOC>1000) VOC=1000;
if(CO2>2000) CO2=2000;
if(VOCf<0.0) VOCf=0.0;
if(CO2f<400.0) CO2f=400.0;
if(VOCf>1000.0) VOC=1000.0;
if(CO2f>2000.0) CO2=2000.0;
Serial.print(CO2f);
Serial.print(",");
Serial.println(VOCf);
Serial.println();
g_channels_data[0].wParam = CO2;
zunoSendReport(1);
g_channels_data[1].wParam = VOC;
zunoSendReport(2);
delay(2000);
zunoSendDeviceToSleep();
}