Sleep mode/Read Vcc issue
-
To give you at least a response. I have no clue... ;-) I use a lot of low power nodes and the vcc library. My only guess is that it could have something to do with the supply voltage begin insufficient to get readings from the DHT sensor.
-
I dont use vcc.h i use this code at the bottom of my sketch
long readVcc() { Serial.println("readVcc"); // Read 1.1V reference against AVcc ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA,ADSC)); result = ADCL; result |= ADCH<<8; result = 1126400L / result; // Back-calculate AVcc in mV //return result; //gw.begin(incomingMessage,node_id, false) batteryPcnt = (result - 3300) * 0.111111; batteryVolt = result/1000.000; gw.sendBatteryLevel(batteryPcnt); gw.send(battMsg.set(batteryVolt, 3)); /*Serial.print("battery volt:"); Serial.println(batteryVolt, 3); Serial.print("battery percent:"); Serial.println(batteryPcnt); */ }how does you vcc.h look like
-
I dont use vcc.h i use this code at the bottom of my sketch
long readVcc() { Serial.println("readVcc"); // Read 1.1V reference against AVcc ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA,ADSC)); result = ADCL; result |= ADCH<<8; result = 1126400L / result; // Back-calculate AVcc in mV //return result; //gw.begin(incomingMessage,node_id, false) batteryPcnt = (result - 3300) * 0.111111; batteryVolt = result/1000.000; gw.sendBatteryLevel(batteryPcnt); gw.send(battMsg.set(batteryVolt, 3)); /*Serial.print("battery volt:"); Serial.println(batteryVolt, 3); Serial.print("battery percent:"); Serial.println(batteryPcnt); */ }how does you vcc.h look like
@flopp
You shouldn't need your own readVcc() code like that since you're including the Vcc library in the beginning of the sketch. Make sure you have the vcc-lib in your Arduino folder:
https://github.com/Yveaux/Arduino_Vcc -
If you use the readVcc function in flopp's sketch, remove gw.begin(incomingMessage, NODE_ID, false);
Calling gw.begin several times seems strange.@mfalkvidd
Sorry that line I don't use anymore. Code must be copied from an old sketch where I was using an LDO that I disabled and when power was back I have to run gw.begin again otherwise I could send anything.
I have now comment that row out.
Thanks for noticing -
@flopp
You shouldn't need your own readVcc() code like that since you're including the Vcc library in the beginning of the sketch. Make sure you have the vcc-lib in your Arduino folder:
https://github.com/Yveaux/Arduino_Vcc -
@engy: just a note: the sketch you posted has #include <Vcc.h>
You should either include Vcc.h OR include readVcc() in your sketch. Not both.
-
The problem was faulty NRF24... another batch :(
Just powered sensor in sleep mode is consuming as expected - a few uA.
But later, after while, power consumption is increasing.
Commenting Vcc was just coincidence.Received new NRFs batch from mysensors shop, and all the problems gone.
Thanks!