Full Arduino Mini LoraWAN below 1uA Sleep Mode

Thanks for the feedback @Charles. Mistakes are easily made with all those different versions of the Arduino’s and clones. 2 small wire-wrap wires will fix the it for my arduino’s. :ok_hand:

@Charles I was wondering If I can use an arduino mega to change the bootlader on my pro mini.
If I understood correctly the process:

  1. Change bootlader to an custom optiboot
  2. Build my own ULPN libray (cause yours is under NDA)
  3. Add any necessary lib for the purpose

Is it Right ?

@Under5hadow
Yeah it could be possible to do with another Arduino following this tutorial.
https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader

But once again it’s not mandatory, just to get more flash size and easy upload speed higher than 57600 :wink:

Ok thanks Charles for the tutorial. I already tried their instructions but I got an error when I tried to burn your bootloader.

Just wondering, If the bootlader can be change with another arduino why use a custom ICSP/FTDI programmer ?

I had some problems with your images too as I had to set them up as custom boards in Arduino and I think something on my end wasn’t right.

Instead, I’ve installed Minicore - all the serial setup works, it’s running Optiboot and integrates with the IDE. It also supports the new optimisation methods during linking and you can select the BOD level - see https://github.com/MCUdude/MiniCore

@tkerby
What image are you talking about? The bootloader files located here?

I use MiniCore also, I even asked the author to add new uart speed in #18 because compiling bootloader can be painfull. But I needed to do it on my own, so that’s why I compiled mine and published them for others.

But you’re right, I did not mention how to flash sketch from Arduino IDE once bootloader is installed. Shame on me, it’s because I already have boards defined with correct UART speed on my Arduino IDE (with ULPNode) so I forgot this step.

image

I need to package back my boards file but in the meantime adding this to your boards.txt of your Arduino IDE should bring you all necessary menu entries (quick and dirty fix, I know)

menu.cpu=Processor

##############################################################
#                Optiboot 16Mhz 115200 BOD 1.8V              #
# bootloader of this board is just UNO running up 115200BPS  #
##############################################################
Optiboot16115.name=Optiboot 328 16MHz 115200BPS 

Optiboot16115.build.f_cpu=16000000L
Optiboot16115.upload.speed=115200
Optiboot16115.bootloader.file=optiboot_atmega328_1152200_16MHz.hex

Optiboot16115.upload.tool=arduino:avrdude
Optiboot16115.upload.protocol=arduino
Optiboot16115.upload.maximum_size=32256
Optiboot16115.upload.maximum_data_size=2048

Optiboot16115.bootloader.low_fuses=0xff
Optiboot16115.bootloader.high_fuses=0xde
Optiboot16115.bootloader.extended_fuses=0x06
Optiboot16115.bootloader.path=optiboot
Optiboot16115.bootloader.unlock_bits=0x3F
Optiboot16115.bootloader.lock_bits=0xCF
Optiboot16115.bootloader.tool=arduino:avrdude

Optiboot16115.build.mcu=atmega328p
Optiboot16115.build.board=AVR_PRO
Optiboot16115.build.core=arduino:arduino
Optiboot16115.build.variant=arduino:standard

##############################################################
#               Optiboot 16Mhz 250000 BOD 1.8V               #
# bootloader of this board is just UNO running up 250000KBps #
##############################################################
Optiboot16250.name=Optiboot 328 16MHz 250KBPS 

Optiboot16250.build.f_cpu=16000000L
Optiboot16250.upload.speed=250000
Optiboot16250.bootloader.file=optiboot_atmega328_250000_16MHz.hex

Optiboot16250.upload.tool=arduino:avrdude
Optiboot16250.upload.protocol=arduino
Optiboot16250.upload.maximum_size=32256
Optiboot16250.upload.maximum_data_size=2048

Optiboot16250.bootloader.low_fuses=0xff
Optiboot16250.bootloader.high_fuses=0xde
Optiboot16250.bootloader.extended_fuses=0x06
Optiboot16250.bootloader.path=optiboot
Optiboot16250.bootloader.unlock_bits=0x3F
Optiboot16250.bootloader.lock_bits=0xCF
Optiboot16250.bootloader.tool=arduino:avrdude

Optiboot16250.build.mcu=atmega328p
Optiboot16250.build.board=AVR_PRO
Optiboot16250.build.core=arduino:arduino
Optiboot16250.build.variant=arduino:standard

##############################################################
#                 Optiboot 8Mhz 57600 BOD 1.8V               #
# bootloader of this board is just UNO running up 57600BPS  #
##############################################################
Optiboot8576.name=Optiboot 328 8MHz 57600BPS 

Optiboot8576.build.f_cpu=8000000L
Optiboot8576.upload.speed=57600
Optiboot8576.bootloader.file=optiboot_atmega328_57600_8MHz.hex

Optiboot8576.upload.tool=arduino:avrdude
Optiboot8576.upload.protocol=arduino
Optiboot8576.upload.maximum_size=32256
Optiboot8576.upload.maximum_data_size=2048

Optiboot8576.bootloader.low_fuses=0xff
Optiboot8576.bootloader.high_fuses=0xde
Optiboot8576.bootloader.extended_fuses=0x06
Optiboot8576.bootloader.path=optiboot
Optiboot8576.bootloader.unlock_bits=0x3F
Optiboot8576.bootloader.lock_bits=0xCF
Optiboot8576.bootloader.tool=arduino:avrdude

Optiboot8576.build.mcu=atmega328p
Optiboot8576.build.board=AVR_PRO
Optiboot8576.build.core=arduino:arduino
Optiboot8576.build.variant=arduino:standard


##############################################################
#                Optiboot 8Mhz 115200 BOD 1.8V               #
# bootloader of this board is just UNO running up 250000KBps #
##############################################################
Optiboot8115.name=Optiboot 328 8MHz 115200BPS 

Optiboot8115.build.f_cpu=8000000L
Optiboot8115.upload.speed=115200
Optiboot8115.bootloader.file=optiboot_atmega328_1152200_8MHz.hex

Optiboot8115.upload.tool=arduino:avrdude
Optiboot8115.upload.protocol=arduino
Optiboot8115.upload.maximum_size=32256
Optiboot8115.upload.maximum_data_size=2048

Optiboot8115.bootloader.low_fuses=0xff
Optiboot8115.bootloader.high_fuses=0xde
Optiboot8115.bootloader.extended_fuses=0x06
Optiboot8115.bootloader.path=optiboot
Optiboot8115.bootloader.unlock_bits=0x3F
Optiboot8115.bootloader.lock_bits=0xCF
Optiboot8115.bootloader.tool=arduino:avrdude

Optiboot8115.build.mcu=atmega328p
Optiboot8115.build.board=AVR_PRO
Optiboot8115.build.core=arduino:arduino
Optiboot8115.build.variant=arduino:standard


##############################################################
#                Optiboot 8Mhz 250000 BOD 1.8V               #
# bootloader of this board is just UNO running up 250000KBps #
##############################################################
Optiboot8250.name=Optiboot 328 8MHz 250KBPS 

Optiboot8250.build.f_cpu=8000000L
Optiboot8250.upload.speed=250000
Optiboot8250.bootloader.file=optiboot_flash_atmega328p_250000_8000000L.hex

Optiboot8250.upload.tool=arduino:avrdude
Optiboot8250.upload.protocol=arduino
Optiboot8250.upload.maximum_size=32256
Optiboot8250.upload.maximum_data_size=2048

Optiboot8250.bootloader.low_fuses=0xff
Optiboot8250.bootloader.high_fuses=0xde
Optiboot8250.bootloader.extended_fuses=0x06
Optiboot8250.bootloader.path=optiboot
Optiboot8250.bootloader.unlock_bits=0x3F
Optiboot8250.bootloader.lock_bits=0xCF
Optiboot8250.bootloader.tool=arduino:avrdude

Optiboot8250.build.mcu=atmega328p
Optiboot8250.build.board=AVR_PRO
Optiboot8250.build.core=arduino:arduino
Optiboot8250.build.variant=arduino:standard

##############################################################
#                Optiboot 8Mhz 1000000 BOD 1.8V              #
#   bootloader of this board is just UNO running up 1MBPS    #
##############################################################
Optiboot81000.name=Optiboot 328 8MHz 1MBPS 

Optiboot81000.build.f_cpu=8000000L
Optiboot81000.upload.speed=1000000
Optiboot81000.bootloader.file=optiboot_flash_atmega328p_1000000_8000000L.hex

Optiboot81000.upload.tool=arduino:avrdude
Optiboot81000.upload.protocol=arduino
Optiboot81000.upload.maximum_size=32256
Optiboot81000.upload.maximum_data_size=2048

Optiboot81000.bootloader.low_fuses=0xff
Optiboot81000.bootloader.high_fuses=0xde
Optiboot81000.bootloader.extended_fuses=0x06
Optiboot81000.bootloader.path=optiboot
Optiboot81000.bootloader.unlock_bits=0x3F
Optiboot81000.bootloader.lock_bits=0xCF
Optiboot81000.bootloader.tool=arduino:avrdude

Optiboot81000.build.mcu=atmega328p
Optiboot81000.build.board=AVR_PRO
Optiboot81000.build.core=arduino:arduino
Optiboot81000.build.variant=arduino:standard

##############################################################
#               Optiboot 16Mhz 1000000 BOD 1.8V              #
#   bootloader of this board is just UNO running up 1MBPS    #
##############################################################
Optiboot161000.name=Optiboot 328 16MHz 1MBPS 

Optiboot161000.build.f_cpu=16000000L
Optiboot161000.upload.speed=1000000
Optiboot161000.bootloader.file=optiboot_atmega328_1000000_16MHz.hex

Optiboot161000.upload.tool=arduino:avrdude
Optiboot161000.upload.protocol=arduino
Optiboot161000.upload.maximum_size=32256
Optiboot161000.upload.maximum_data_size=2048

Optiboot161000.bootloader.low_fuses=0xff
Optiboot161000.bootloader.high_fuses=0xde
Optiboot161000.bootloader.extended_fuses=0x06
Optiboot161000.bootloader.path=optiboot
Optiboot161000.bootloader.unlock_bits=0x3F
Optiboot161000.bootloader.lock_bits=0xCF
Optiboot161000.bootloader.tool=arduino:avrdude

Optiboot161000.build.mcu=atmega328p
Optiboot161000.build.board=AVR_PRO
Optiboot161000.build.core=arduino:arduino
Optiboot161000.build.variant=arduino:standard


##############################################################
#               Optiboot 16Mhz 1000000 BOD 1.8V              #
#        bootloader for  ATMega1284p running up 1MBPS        #
##############################################################

atmega1284p_1M.name=ATmega1284/P 16MHz 1MBPS

atmega1284p_1M.build.f_cpu=16000000L
atmega1284p_1M.upload.speed=1000000
atmega1284p_1M.bootloader.file=optiboot_atmega1284p_1Mbps_D15.hex

atmega1284p_1M.upload.tool=arduino:avrdude
atmega1284p_1M.upload.protocol=arduino
atmega1284p_1M.upload.maximum_size=130048
atmega1284p_1M.upload.maximum_data_size=16384

atmega1284p_1M.bootloader.low_fuses=0xFF
atmega1284p_1M.bootloader.high_fuses=0xDE
atmega1284p_1M.bootloader.extended_fuses=0xFE
atmega1284p_1M.bootloader.path=optiboot
atmega1284p_1M.bootloader.unlock_bits=0x3F
atmega1284p_1M.bootloader.lock_bits=0x0F
atmega1284p_1M.bootloader.tool=arduino:avrdude

atmega1284p_1M.build.mcu=atmega1284p
atmega1284p_1M.build.board=AVR_MOTEINOMEGA
atmega1284p_1M.build.core=arduino:arduino
atmega1284p_1M.build.variant=MoteinoMEGA
1 Like

LoRa

Can someone explain what this is for and do I need for the board to work? Can’t see any component that would fit there in the BOM list.
And also what dose 24AA02E64T do ? It’s something to to with I2C right? Do I really need that? Doesn’t the the arduino handels the I2C signals ?

  • I didn’t see the blue circle so I thought that you asked about the PCB :sunglasses:

If it so obvious what its for why don’t you just tell me then? Anyway downloaded the .brd file and to try to figure out what’s for. Is it a jumper for power and ground for the I2C module?

It’s so you can switch the power and ground in the i2c header as some boards have them the other way round. Cut the trace between the existing pads if you need it.

The other component is for a unique device ID. You could either fit it or alternatively program it direct into the code or store it in eeprom on the Arduino

1 Like

Thanks for the board file Charles - I hadn’t quite got the fuse and serial settings right!

Thank you, that was the response I wanted!

@tkerby won a beer, that is exactly this, to reverse if needed VCC and GND of I2C header :wink:

Does anyone have successfully compile the LMIC Library ? I have this error "\IBM_LMIC_framework\lmic\aes.c.o (symbol from plugin): In function os_aes': (.text+0x0): multiple definition ofos_aes’ "

I can’t figure out what’s wrong :confused:

Hello, i tryed my first steps with LoRa and find this project.
It was a lot help to build the first test node, but without Cayenne LPP.
Where i can donwload this project files?

Thanks for answer. Is there no download, please answer too… :slight_smile:

What do you mean by that ?

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