Full Arduino Mini LoraWAN below 1uA Sleep Mode


#41

Took a minute to wrap up this code in a example and it works out of the box. Many thanks for sharing. :thumbsup:


#42

Yeah forgot this one, in default example I changed debug output to use flash memory.

Serial.PrintLn("EV_TXCOMPLETE (includes waiting for RX windows)");

this is not using Flash space but RAM (if not let me know, something changed) so it won't optimize flash in any way, you need to use F() macro as follow to place string in flash. But @lex_ph2lb advice if correct, to reduce size, reduce print strings lenght (as far as they stored in flash)

Serial.PrintLn( F("EV_TXCOMPLETE (includes waiting for RX windows)") );

@lex_ph2lb thanks for antenna reference, nice graph and interesting


#43

Oeps indeed, forgot to mention the F() macro. :sweat:

You're welcome. This week I want to setup some field trails to test it against a stock antenna. But for now it looks really good.


#44

Guys

Just to let you know I've integrated for testing some tweaked BME280 code in my library. I need to take time to test but, as reference, it fit with TSL2561 code sensor even on Mini without Optiboot Bootloader
With no debug leaving space

With some debug activated, as you can see, still fit :wink:


(Gig) #45

Remove the bootloader entirely and get a cheap ISP AVR programmer from eBay, you'll be able to use the full 32KB of progmem.


#46

Time for a new antenne experiment. Now with the SMA chassis part and a single wire mounted in the SMA connector pin.


#47

@Gig
For sure, but don't forget that ICSP connector is not present on the board, so you need to wire the ICSP once the Mini is soldered on the board PCB, so, big pain in perspective.

That's why I'm flashing with Optiboot my Arduino Mini once received with this custom ICSP/FTDI programmer shield and PogoPins.

You can get it there on PCBs.io, tested and working :wink:
github repo of the adapter with build files, schematics and bootloaders


#48

nice work.
could you please tell us what PogoPins you used (link?) and it would be nice seeing a picture of an assembled board
thanks


#49

I'm using Pogo Pin P75-E2 or P75-LM2
Plenty of them on ebay :wink:

I'll take a picture, I'm at the office right now :wink:


#50

@ursm
Updated the github repo for the ICSP programmer with some pictures, but looks like this

In the meantime, I've just received V1.1 of MiniLora PCB, classic and groove, need some testing


#51

Just to let you know I've just released the Mini-LoRa files (Schematics, boards, pictures,..) on github.
Check this out here
If you like, don't hesitate to star :grinning:


#52

with matthijskooijman/arduino-lmic, the BME280 (Glenn Tyler) and Voltage measurement published above (thanks @Charles) and low power sleep I'm at 29126 bytes (94%).
It's sad not able to add the Multichannel Gas Sensor (MiCS-6814) which library needs at least 8kB


Next will be running it on battery (clips just arrived) and measuring current.


#53

For information, adding BME280 code to my lib increased 700 bytes (including sending BME280 payload to TTN). Of course I already got I2C sharing reading/writing register functions for other I2C devices, so I'm cheating a little.

without BME280

Sketch uses 29822 bytes (97%) of program storage space. Maximum is 30720 bytes.
Global variables use 1339 bytes (65%) of dynamic memory, leaving 709 bytes for local variables. Maximum is 2048 bytes.

with BME280

Sketch uses 30522 bytes (99%) of program storage space. Maximum is 30720 bytes.
Global variables use 1339 bytes (65%) of dynamic memory, leaving 709 bytes for local variables. Maximum is 2048 bytes.

8Kb for a sensor library is just amazing, just took a look onto it, using float calculation and math pow function are consuming. Library fitted with also lot of print, I'm pretty sure you can tweak it by a 2 factor, I could try but does not have this sensor to test
A good sensor for Mini Lora grove version :wink:


#54

8kB is with stripping all Serial.prints :frowning:
squeezing the multisensor gas library is something for experts - not for me


#55

Your device sensor (very interesting) has an Arduino (ATMega168) on board with a firmware (updatable).
When I compile the firmware, 32% of sketch size

Sketch uses 4612 bytes (32%) of program storage space. Maximum is 14336 bytes.
Global variables use 439 bytes (42%) of dynamic memory, leaving 585 bytes for local variables. Maximum is 1024 bytes.
  • This mean a huge part of the library code should have been done on the sensor itself which makes sense from my point of view :wink:
  • Take care that firmware on the board is far from Low Power, no sleep mode used when sensor is doing nothing

#56

it consumes 48mA forever :wink:
the command powerOff does not reduce current.

//-------------------------------------------------------------------------------------
// get some data from the sensor
*include "Wire.h"
*include "MutichannelGasSensor.h"
*define SENSOR_ADDR 0X04 // default to 0x04

void setup()
{
Serial.begin(115200);
gas.begin(SENSOR_ADDR);
gas.powerOn();
}

void loop()
{
delay(5000);
float c;
c = gas.measure_NH3();
Serial.print("NH3 is ");
if(c>=0) Serial.print(c);
c = gas.measure_CO();
Serial.print(" CO is ");
if(c>=0) Serial.print(c);
c = gas.measure_NO2();
Serial.print(" NO2 is ");
if(c>=0) Serial.println(c);
}
//-------------------------------------------------------------------------------
Sketch uses 8246 bytes (26%) of program storage space. Maximum is 30720 bytes. :frowning:


#57

@ursm
this size if for total sketch not only the library, since it contains float management and arduino core, it's not only library.

Look this basic sketch

void setup() {    
  Serial.begin(115200);
}
void loop()  {
  static float f = 1.0;
  Serial.print(f);
  delay(1000);
  f += 0.1;
}

and compilation

Sketch uses 3148 bytes (10%) of program storage space. Maximum is 30720 bytes.
Global variables use 200 bytes (9%) of dynamic memory, leaving 1848 bytes for local variables. Maximum is 2048 bytes.

3148 bytes used by Arduino core, so may be lib is more like 4K than 8K, but still too much for an I2C device


#58

And for fun, adding I2C library (wire), 4642 bytes, so definitively Gas lib should fit with some tweaking

#include <Wire.h>

void setup() {    
  Serial.begin(115200);
  Wire.begin();
  Wire.beginTransmission(0xff); 
  Wire.write(0x00);    
  Wire.write(0x01);           
  Wire.endTransmission(); 
}

void loop() {
  static float f = 1.0;

  Serial.print(f);
  delay(1000);
  f += 0.1;
}

Sketch uses 4642 bytes (15%) of program storage space. Maximum is 30720 bytes.
Global variables use 378 bytes (18%) of dynamic memory, leaving 1670 bytes for local variables. Maximum is 2048 bytes.

#59

Do you have some examples of how you are entering and resuming from sleep in the LMIC library between measurements?

Doesn't necessarily need to be with your cut down code but I'd be interested to see an example even with the base library. Thanks for all the great boards!


#60

@tkerby

All is done in loop, with LMIC events callback and a global flag (timetosleep) to indicate the sleep mode needed.

I'm sleeping x time of watchdog 8s in loop, once max time is triggered, I set timetosleep to false and I send LMIC data and refreshing LMIC in loop
on EV_TXCOMPLETE event I set timetosleep to true, then, loop() go back sleeping until x time of 8S watchdog occurs.

Of course setup need to start lmic and join, on joined I fire a LMIC timer to send first packed 10ms later. then on packet sent (EV_TXCOMPLETE ) loop will go to sleep