The Things Node : new low power library development


Charles, I suggest maybe to contact Phang, because his node with the RN2483 interrupt works flawless… but probably not easy to implement without a separate wire

I checked yesterday for a few minutes, did the current meassurement and thought everything worked fine :roll_eyes:

  • timing after waking up… reinitialize uart connection / delay ?


I look at the data in the console (app, data) there I get

In Cayenne also… there I get

and in node red where I also log it to a file
{ “accelerometer_7”: { “x”: -0.006, “y”: 0.006, “z”: 1.022 }, “analog_in_4”: 3.31, “digital_in_1”: 1, “digital_in_2”: 0, “digital_in_3”: 0, “luminosity_6”: 123, “temperature_5”: 22.4 }
and in the log written bei node red:

its, everywhere the same data I see…right now the node is behaving normally, except the doigital 3 value always zero.


@BoRRoZ Phang use an ATmega 328p that do not have USB, so it’s less tricky, I can just try to disable USB totally (but you need to reset the node to upload sketch). Anyway for low power I will try to disable totally USB, and may be activate it back only for example if button is pressed longer than 2s, I need to add some features depending on button press :wink:

(Phang Moh) #123

Rob and Charles, take a look at my guidelines here. The 32U4 external interrupt itself is already on the RX pin, so no need extra wires.


Interesting looking at the Arduino source code so see detach() emtpy !!

anyway attach() do all the trick even powering back on UVREGE so something like that should do the trick

void TheThingsNode::deepSleep(void)
  // We want to be awake by LoRa module ?
  if (this->pttn) {
    // watchdog Not needed, avoid wake every 8S

    // Set LoRa module sleep mode
    // This one is not optionnal, remove it
    // and say bye bye to RN2483 or RN2903 sleep mode

    // Module need to wake us with interrupt

    // switch all interrupts off while messing with their settings  
    bitSet(EIFR,INTF2); // clear any pending interrupts for serial RX pin (INT2 D0)

  } else {
    // watchdog needed for wakeup

  MCUCR |= (1 << JTD);
  USBCON |= (1 << FRZCLK); // Disable USB clock 
  PLLCSR &= ~_BV(PLLE); // Disable USB PLL
  USBCON &= ~_BV(USBE); // Disable USB
  UHWCON &= ~_BV(UVREGE); // Disable USB Regulator
  sleep_mode(); //Sweet dreams!

  //wake up, after ISR we arrive here ->
  ADCSRA |= (1 << ADEN);

The file to look at in Arduino IDE is this one


Hi there,

Major update, just to let you know I’ve pushed a bug fix (almost it seems) version with optimized Low Power (disable USB regulator) mode.
Sounds like working fine on my side, please note that for now, only sketch BatteryMonitorLPP is so optimized.
So If it’s okay on your side, I will include these optimization on the others examples and do a pull request

Please note that for advanced Ultra Low Power techniques, all unneeded peripherals are disable during sleep mode, including USB Management. This means you won’t be able to upload anymore if the node is sleeping and when wake up, Lora transmission is approx 3s (including receive windows) this means that you have 3 seconds windows to upload, so unless you’re lucky, it’s almost impossible to sync Arduino compilation and upload.
But to avoid this, you can press the node button for more than 2s, then the led will yellow blink quickly for 60s, letting you time to upload

@BoRRoZ, I’m interested in some sleep mode measurement of this sketch :wink:


OK you did it again Charles… ca 31 uA deepsleep now ! :sunglasses:

(BatteryMonitorLPP set to 30 s and tested with batteries)


wooooow love it :wink:
thanks for your help, and I love your scope…


TTN node with CH2I mod :wink:


I am running the newest LPP sketch also. Seems to work ok… also the yellow led blinking mode.
But why a second button?? What is the CH21 mod?


Yeah, why did you add the reset button @BoRRoZ ?


syncing after deepsleep


You just need to press the original button for over 2s and the release it, you’ll have 60seconds (led blink yellow) then to sync :wink:


and what if things are completely messed up during dev/playing ?
I never want to open that thing again … so have to make an usb connector to the outside to


During dev I use USB cable, and just uplug/plug it :wink:
But having a reset btn is also an option when you play a lot :wink:


I’ve just pushed the updated version with the original cayenneLPP sketch (the one with sensors activated) and updated the documentation also.
Here is the Pull Request #15
@johan, it’s now up to you :wink:


Why didn’t you add a reed switch?
(use a strong magnet to reset)


@Charles I am not sure if the code of the cayenne Ultra LPP has problems.
channel 3 is always zero, I do not know how long the node has to be kept moving until this is triggered. But more important my ttn node is stuck on the blue light after having worked ok for some events but suddenly no more message from the node and blue light forever. Only disconnecting batteries resets the node…
Measured battery voltage is 3.7V. Also again strange temperature value of 25.1 degreeC in reality 22.5 outside the ttn box… maybee the ttn node heats up inside…?


good idea, but that would void my warranty :innocent:


Fixed blue led is a bug, I’m investigated on it, I saw it also and only way is to reset, I light the LED just before calling send, so I suspect lora module not responding or whaever, but it happened to me when moving the module so with motion detection
Just reproduced again, moving again just after a send and blocked