Sorry for the confusion. The button release function in the original coude should provide the duration that the button was pressed. It now alwas says “0”. It seems as if the rise or fall is not detected correctly in processing the interrupt.
PS. I just read your comment on Github about this issue.
Thansk @BoRRoZ but still too much for me, got some other ideas, if you have time to help for measurement I’m your man, I’ll take care of Low Power Code optimization
What about trying with sensors enabled? Would you mind trying CayenneLPP.ino just to see?
@BoRRoZ and @Charles thanks for your work! You were just a bit faster than I. Today I also started to investigate into current consumption of the ttn node and found out, that the RN2483 is not put into sleep! But the code to put the uC into Sleep works.
Above the left top DMM shows the total current consumption (3.97mA). The left lower one shows the current of the RN2483 (2.96mA) and the right one shows the current of the uC (~13µA). The DMM measurement is not super precise, because it is in mA Mode (µA would mean to much drop, 100Ohm Shunt)
Was measured with standard LPP sketch.
Than I loaded the Passthrough sketch an put the RN2483 manually into sleep. The current of the RN2483 went nicely down (~4µA). So as you mentioned above, it’s really about putting the RN2483 into sleep.
The remaining 900µA or in your setup @BoRRoZ 600µA (probably because of lower supply) is probably mainly due to Pulldown Resistors. I think the R11 (10k) and R16 (10k) will contribute with each around 300uA, but I have to check that, to be sure.
Additionally it’s not really nice to have R12 and R13 that low (1k), but it is not that critical, because current (each 3mA) is only drawn during communication.
I will keep you updated.
Thanks,
I tried to wake up the processor by the RN2483, and it works, so we would be able to stop the watchdog to wake up the node every 8 seconds.
yep I didn’t even seen these 1K I2C pullup, what’s these values? You’re right only on communication.
Another thing I’ve done is to sleep the Light sensor after measuring, datasheet says no problem with that.
I need to arrange code and I will publish as PR of course.
the CayenneLPP example from the things node library 2.0.5.
all sensors on and mcu and radiomodule in sleepmode
that’s a big improvement ! thanks @Charles and @johan is this right ? I have some doubt now
all sensors off and wake up after a buttonclick, transmit and back to sleep, this is the lowest current draw possible with this hardware.
would be interesting to see with these 3 func changed in TheThingsNode.cpp, this setup light sensor to low power just after reading even if it’s enabled and of course wake up device before reading
void TheThingsNode::configLight(bool enabled)
{
if (enabled == this->lightEnabled)
{
return;
}
// Ok be sure to set it to low power mode
if (!enabled)
{
digitalWrite(TTN_LDR_GAIN1, LOW);
digitalWrite(TTN_LDR_GAIN2, LOW);
// Just to be sure, see datasheet, at least 1.5ms to enable Low Power
delay(2);
}
this->lightEnabled = enabled;
}
uint16_t TheThingsNode::getLight()
{
uint16_t value = 0;
if ( this->lightEnabled)
{
switch (this->lightGain)
{
case 0:
digitalWrite(TTN_LDR_GAIN1, LOW);
digitalWrite(TTN_LDR_GAIN2, LOW);
break;
case 1:
digitalWrite(TTN_LDR_GAIN1, HIGH);
digitalWrite(TTN_LDR_GAIN2, LOW);
break;
case 2:
digitalWrite(TTN_LDR_GAIN1, LOW);
digitalWrite(TTN_LDR_GAIN2, HIGH);
break;
case 3:
digitalWrite(TTN_LDR_GAIN1, HIGH);
digitalWrite(TTN_LDR_GAIN2, HIGH);
break;
}
// Wait to settle
delay(1);
// Read value
value = analogRead(TTN_LDR_INPUT);
// Go back to sleep mode
digitalWrite(TTN_LDR_GAIN1, LOW);
digitalWrite(TTN_LDR_GAIN2, LOW);
// Just to be sure, see datasheet, at least 1.5ms to enable Low Power
delay(2);
}
return value;
}
yes all is working but the CayenneLPP sketch draws 3.8 mA… so that’s one off the sketches from examples users are going to try first.
batteries in… play a bit and forget about the batteries…
can you get all the sensors automatic to sleep in the library after a certain time waking up after shaking or something ? possibly with a setting ?
Well, that’s what I wanted to do (but need to be sure the sensor consumption worth it).
The light sensor need 1.5ms to go to sleep and less then 1ms to wake up, so yes, we can put it in sleep mode between reading when sensor is enabled
I need to check setup time for temp sensor to see if we can do the same (but in this case will certainly remove the temp alert feature waking up by IRQ) but can be an option.
for the motion can’t do real thing, need to be up to wake up on motion, but once again, we need to check datasheet to see if consumption gain on sensors worth it.
I think this TTN node is mostly used in ‘study situations’, laying around on your desk and not used as a outdoor temp sensor for example.
so taking the batteries out because you don’t have time to play/study for a couple of days, or testing the temp sensor with an 1 hour interval , yes then we can save a lot off battery energy with ‘auto sensor sleep’ in the library