Full Arduino Mini LoraWAN below 1uA Sleep Mode

hello, i mean the arduino sketch.

In the git for this, only the board schematics, no code to drive the the pcb.

The other git, works but no LPP kompatible.

Or i dont find the korrekt git, or i cant use correct cayenne…

thanks for help…

Ah check, indeed correct. LoRaWAN_TTN_Env_Node isn’t LPP compatible.

When you use the code from the LoRaWAN_TTN_Env_Node, this is what you need to do :

Include CayenneLPP.h with :

#include <CayenneLPP.h>

Init the CayenneLPP buffer with :

CayenneLPP lpp(51);   // create a buffer of 51 bytes to store the payload

Then replace :

    int t = (int)((temp + 40.0) * 10.0);  
    int p = (int)(pressure);  
    int h = (int)(humidity);

    unsigned char mydata[6];
    mydata[0] = batvalue;      
    mydata[1] = h & 0xFF; 
    mydata[2] = t >> 8;
    mydata[3] = t & 0xFF;
    mydata[4] = p >> 8;
    mydata[5] = p & 0xFF; 
    
    LMIC_setTxData2(1, mydata, sizeof(mydata), 0);

With :

    lpp.reset();                            // clear the buffer
    lpp.addTemperature(1, temp);            // on channel 1, add temperature 
    lpp.addBarometricPressure(2, pressure); // channel 2, pressure
    lpp.addRelativeHumidity(3, humidity);   // channel 3, pressure

    LMIC_setTxData2(1, lpp.getBuffer(),  lpp.getSize(), 0); 

Then it should be LPP compatible.

let me know if it works for you.

2 Likes

Hello… perfekt… thats the way :slight_smile:
One little question.
the variable “batvalue” in the old sketch block, can i send like?

many thanks

Good point there.

You could send it like

https://www.thethingsnetwork.org/docs/devices/arduino/api/cayennelpp.html#methods-add

 uint8_t addAnalogInput(uint8_t channel, float value);

You need to add :

 float fbatt = batt / 10.0;
 lpp.addAnalogInput(4, fbatt);
1 Like

Hello, thanks.
It works all.
i understand more and more…

Good work… :+1:

1 Like

Anyone using the minilora boards may be interested in taking a look at my code here: https://github.com/tkerby/minilora-test

I’ve been testing a few features including

  • Low power sleep of arbitrary length in seconds
  • Restoration of millis() counter allowing sleep to be considered within the duty cycle limits for LMIC
  • OTAA with full datarate checking
  • Adaptive timing based on the current spreading factor - a node that ends up on higher SF values will automatically send less often. Ideal with ADR

All these features are very new so I’d love some others to test and provide feedback. It’s really difficult to test in Edinburgh now we have good gateway coverage!

Big thanks to Charles, Matthijs and Arjan for getting me this far!

Note there is a keys.h file needed containing your three keys - see comments in the code

7 Likes

great tnx … will try that this weekend :sunglasses:

Hi Charles,

Referring to your first post:

Any chance we will see this as your 65’th repository on Github soon? :slight_smile:

1 Like

Hi Charles,
sorry for my stupid question: trying to get the node example up and running:

LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino: In function ‘void updateEnvParameters()’:
LoRaWAN_TTN_Env_Node:185: error: no matching function for call to ‘BME280I2C::temp(bool)’
temp = bme.temp(true);
^
I used the right BME 280 library “BME280-master” and not the Arduino IDE lib. Any ideas whats wrong ?
Btw: Many thanks for you and all the contributors for this exciting Lora node.

Br Peter

Hello Peter, which software did you use ?

This one ? https://github.com/ph2lb/LoRaWAN_TTN_Env_Node That project has the BME280 library source in the project tree. So you don’t need to add the BME280 libary to the Arduino library pool.

But when use the new BME280 library, please check the function call. THe function ::temp() now has different parameters.

Taken from : https://github.com/finitespace/BME280/blob/master/src/BME280.h

float BME280::temp
(
TempUnit unit
)

Where TempUnit is defined like :

enum TempUnit {
TempUnit_Celsius,
TempUnit_Fahrenheit
};

So you’re correct call should be :

// OLD CODE temp = bme.temp(true);
temp = bme.temp(TempUnit.TempUnit_Celsius);

Please also check the functions for pressure.

// OLD CODE pressure = bme.pres(1); // 1 = hPa (milliBar)
pressure = bme.pres(PresUnit.PresUnit_hPa);

Hope the above helps.

1 Like

Hi dear,

thanks for your fast response. I simply want to get your example up and running bcs it would be a perfect starting point for my ideas. I deleted the new BME280 llib now and copied the header files from your tree into the directory where the .ino file is located (your complete source tree is now one directory up bcs arduino creates a sub dir in that tree dir.
Now he compiles fine but I got a lot of unresolved references …
/Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:316: undefined reference to BME280I2C::begin()' /var/folders/zg/_ch0sxr910z5mt6j6skz3dz00000gn/T//ccjKsYlH.ltrans1.ltrans.o: In functiondo_send’:
/Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:274: undefined reference to readVcc()' /var/folders/zg/_ch0sxr910z5mt6j6skz3dz00000gn/T//ccjKsYlH.ltrans5.ltrans.o: In function__static_initialization_and_destruction_0’:
/Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:160: undefined reference to BME280I2C::BME280I2C(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, bool, unsigned char)' /var/folders/zg/_ch0sxr910z5mt6j6skz3dz00000gn/T//ccjKsYlH.ltrans0.ltrans.o: In functionupdateEnvParameters()’:
/Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:181: undefined reference to BME280::temp(bool)' /Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:183: undefined reference toBME280::pres(unsigned char)’
/Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:184: undefined reference to BME280::hum()' /var/folders/zg/_ch0sxr910z5mt6j6skz3dz00000gn/T//ccjKsYlH.ltrans0.ltrans.o: In function__vector_21’:
/Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:174: undefined reference to _adc_irq_cnt' /Users/Peter/Projekte/ISY-Box/LoraWeather/Parkett Decke Node/LoRaWAN_TTN_Env_Node-master/LoRaWAN_TTN_Env_Node/LoRaWAN_TTN_Env_Node.ino:174: undefined reference to_adc_irq_cnt’
collect2: error: ld returned 1 exit status

I assume that its because the wrong lib objects path. How I need to handle your source tree (ph2lb/LoRaWAN_TTN_Env_Node) within Arduino ? And once more, sorry for my maybe stupid questions and many thanks for your help !
Br Peter

Peter,

The errors mean that the source compiles ok, but the linker can’t find the referenced functions.
You may have forgotten to copy the Adcvcc.cpp, BME280.cpp and BME28012C.cpp into you’re the project directory.

For a clean start :

Best to do is to download the zipfile : https://github.com/ph2lb/LoRaWAN_TTN_Env_Node/archive/master.zip
And extract it in you’re Arduino Sketch folder. The Directory name will be "LoRaWAN_TTN_Env_Node-master"
so you have to rename it to “LoRaWAN_TTN_Env_Node”. Else the Adruino IDE can’t handle it.

That should compile without a problem. From there you can rebuild you own program.

2 Likes

You are my hero for today !
Rebuild works without any problems.

Many thanks for your help !
Br Peter

1 Like

@PeterKatana, you’re welcome.

Enjoy and please show us you’re end result.

Hi lex,

should I see something on the serial monitor when the prog is running ?
I just see a single “Ly” … not more.

Btw: I have running here an Raspi Dragino hat single channel gw - connect status green in the ttn network console.
Registered the Lora node as application --> device and changed the addresses appropriately in your example code but don’t know, if the node can connect / see the raspi gw. In the ttn portal the node is shown as not connected.

Many many thanks for your help !
Peter

Thanks in advance Peter

Oh when you running Single channel you should change the code to the channel the Raspi Dragiono supports.
It will probably be channel 0 on SF7, so you have to change the line :

// #define CHANNEL0

to

#define CHANNEL0

When you want to debug info you should set the serial terminal to 1115200.
But remember that you have to set the board settings correct (when using a 3.3V mini pro it’s 8Mhz, a 5V mini pro is 16Mhz).

HI lex,
changed to channel 0. Setup serial speed appropriately and got:
FAILURE
/Users/Peter/Google Drive/Mac Documents/Documents/Arduino/libraries/arduino-lmic-master/src/lmic/radio.c:689
Seems that the initialization of the RF chip is not working. Maybe its a wrong one ?
Should be a RF95W bcs of europe …

You mean the board settings in Arduino IDE ? Yes, they are correct.

For Europe the correct chip should be indeed a RFM95W.

The same error … used an new Arduino and also a new RFM95W (different product and outfit).
I used the wiring from:


But there is no magic I assume.
Any ideas ?

There is magic, but did you change the wiring in the source code ? Because when you didn’t there will be no wireless magic :wink:

Below are the correct defines (rows 116 to 121)

#define LMIC_NSS 6
#define LMIC_RXTX LMIC_UNUSED_PIN
#define LMIC_RST LMIC_UNUSED_PIN
#define LMIC_DIO0 2
#define LMIC_DIO1 3
#define LMIC_DIO2 4