Arduino LMIC library updated


I don't think the number of available pins would be an issue soon, but it would simplify things because it leaves the arduino's default interrupt pins unused. I'm looking forward to give it a try.

Is my understanding correct that FSK is not used in TTN context?


in LMIC, pin interrupt are not used, pins are just pooled in loop, in term of optimization, using real IRQ would be great improvement but platform dependent :wink:


Many LMIC nodes around use a wiring that occupies the arduino's default interrupt pins with RFM DIO pins :wink:

Would be great to remove those.


Hi Paul, same issue here after updating Teensyduino. But i saved my previous patch: This is my /hardware/teensy/avr/platform.txt, working correct with Teensy and LMIC!


compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O ihex -R .eeprom
compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD

## Preprocessor Includes
recipe.preproc.includes="{compiler.path}{build.toolchain}{build.command.g++}" -M -MG -MP -x c++ -w {build.flags.cpp} {build.flags.cpu} {build.flags.defs} -DARDUINO={runtime.ide.version} -DF_CPU={build.fcpu} -D{build.usbtype} -DLAYOUT_{build.keylayout} {includes} "{source_file}"

## Preprocessor Macros
recipe.preproc.macros="{compiler.path}{build.toolchain}{build.command.g++}" -E -CC -x c++ -w {compiler.cpp.flags} {build.flags.common} {build.flags.cpp} {build.flags.cpu} {build.flags.defs} -DARDUINO={runtime.ide.version} -DF_CPU={build.fcpu} -D{build.usbtype} -DLAYOUT_{build.keylayout} {includes} "{source_file}" -o "{preprocessed_file_path}"

## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{build.toolchain}{build.command.g++}"  -std=gnu++11 -c {build.flags.optimize} {build.flags.common} {build.flags.dep} {build.flags.cpp} {build.flags.cpu} {build.flags.defs} -DARDUINO={runtime.ide.version} -DF_CPU={build.fcpu} -D{build.usbtype} -DLAYOUT_{build.keylayout} {includes} "{source_file}" -o "{object_file}"

## Compile c files
recipe.c.o.pattern="{compiler.path}{build.toolchain}{build.command.gcc}" -std=gnu99 -c {build.flags.optimize} {build.flags.common} {build.flags.dep} {build.flags.c} {build.flags.cpu} {build.flags.defs} -DARDUINO={runtime.ide.version} -DF_CPU={build.fcpu} -D{build.usbtype} -DLAYOUT_{build.keylayout} {includes} "{source_file}" -o "{object_file}"

## Compile S files
recipe.S.o.pattern="{compiler.path}{build.toolchain}{build.command.gcc}" -c {build.flags.optimize} {build.flags.common} {build.flags.dep} {build.flags.S} {build.flags.cpu} {build.flags.defs} -DARDUINO={runtime.ide.version} -DF_CPU={build.fcpu} -D{build.usbtype} -DLAYOUT_{build.keylayout} {includes} "{source_file}" -o "{object_file}"

## Create archives"{compiler.path}{build.toolchain}{}" rcs "{build.path}/core/{archive_file}" "{object_file}"

## Link
recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.gcc}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" {build.flags.libs}

## Patch ELF - TODO: not supported by Arduino 1.6.6 builder
recipe.elfpatch.pattern="{compiler.path}/hardware/tools/{build.elfpatch}" -mmcu={build.mcu} "{build.path}/{build.project_name}.elf" "{sketch_path}/disk"

## Create eeprom
recipe.objcopy.eep.pattern="{compiler.path}{build.toolchain}{build.command.objcopy}" {compiler.objcopy.eep.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"

## Create hex
recipe.objcopy.hex.pattern="{compiler.path}{build.toolchain}{build.command.objcopy}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

## Post Build - inform Teensy Loader of new file
recipe.hooks.postbuild.1.pattern="{compiler.path}/teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={compiler.path}" "-board={build.board}"

## Compute size
recipe.size.pattern="{compiler.path}{build.toolchain}{build.command.size}" -A "{build.path}/{build.project_name}.elf"

## Teensy Loader
tools.teensyloader.upload.pattern="{cmd.path}/teensy_post_compile" -test "-file={build.project_name}" "-path={build.path}" "-tools={cmd.path}" "-board={build.board}" -reboot

## Export hex

# TODO: missing patch in 1.6.6...

# documentation on this file's format

(Hemalchevli) #66

I'm also using the same sx1276mb1mas board with arduino UNO and I got it working yesterday.
I too got the same error, but its was just a connection issue.
Here is my pin defs and hardware connections.
const lmic_pinmap lmic_pins = {
.nss = 10,
.rxtx = A4,
.rst = A0,
.dio = {2, 3, 4},

Hardware connections:
uno | sx1276mb1
(13)SCK ->SCK(via voltage divider)
(11)MOSI ->MOSI(via voltage divider)
(12)MISO <- MISO (no voltage divider)
(10)SS -> NSS(via voltage divider)
D2 -> DIO0(via voltage divider)
D3 -> DIO1(via voltage divider)
D4 -> DIO2(via voltage divider)
A4 -> RXTX(via voltage divider)

NRESET on sx1276 is left unconnected.

I'm having an gateway from orbiwise borrowed from the my client, I'm still having some issues in connecting to my gateway.

Here is my output on serial port
219: engineUpdate, opmode=0x808
624: TXMODE, freq=868100000, len=14, SF=7, BW=125, CR=4/5, IH=0
Packet queued
66065: RXMODE_SINGLE, freq=868100000, SF=7, BW=125, CR=4/5, IH=0
128853: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
346169: EV_TXCOMPLETE (includes waiting for RX windows)
346214: engineUpdate, opmode=0x800
4096212: engineUpdate, opmode=0x808
4096630: TXMODE, freq=868300000, len=14, SF=7, BW=125, CR=4/5, IH=0
Packet queued
4162072: RXMODE_SINGLE, freq=868300000, SF=7, BW=125, CR=4/5, IH=0
4224859: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
4526566: EV_TXCOMPLETE (includes waiting for RX windows)
4526614: engineUpdate, opmode=0x800
8276613: engineUpdate, opmode=0x808
8277031: TXMODE, freq=868500000, len=14, SF=7, BW=125, CR=4/5, IH=0
Packet queued
8342471: RXMODE_SINGLE, freq=868500000, SF=7, BW=125, CR=4/5, IH=0
8405259: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
8644616: EV_TXCOMPLETE (includes waiting for RX windows)
8644664: engineUpdate, opmode=0x800



Got that error today when I tried to compile in Arduino IDE 1.6.8. and in 1.8.1 on Windows864b


error: 'for' loop initial declarations are only allowed in C99 or C11 mode

         for (u1_t i = 0; i < len; i += 16)

For those who get this error:

  • close Aduino IDE,
  • rename or delete your platform.txt (C:\Users\Marco\Documents\Arduino\hardware\arduino\avr)
  • restart your Arduino IDE.
  • compile without the error :wink:

That worked for me!

(Arjan) #68

A post was split to a new topic: Send and receive data using node to node or p2p communication

(Amarsanaa) #69

dear mattijis

when LMIC library can support 433Mhz band? 433Mhz lora module is cheapest on market it is around 2.5 to 3.5 dollar. also 433Mhz sx1278 chips are more common that others in market. could you please urgently update your library to support 433Mhz?

many thanks

(Moebius L) #70

Hello, I'm going through lots of documentation and code to get my head around the LoRaWAN based on RFM95 on an atmega328p. I can see great improvement has been done last year about the code size, specially in the AES space.

Now, looks like the alternative AES library is based on the "Ideetron" one but looking at the @matthijs AES performance tests on a previous post (, the AVR-AES offer much better performance, which is quite important for low-power nodes....

I couldn't find any other topic related to the AES or if the AVR-AES integration still part of the plan. Does anyone have an update on that?


(Matthijs Kooijman) #71

The problem with AVR-AES was that its license was incompatible with the LMIC license. In het last update from IBM, the LMIC license was changed (on my request) to be more liberal, which should solve this. I'm still planning to build a new port of the library, based on the last LMIC release by IBM, which is less Arduino-centered and can serve as the new upstream for all LMIC ports out there. Integrating AVR-AES would be something to do as part of that new version. I've made a start already, but I need to dedicate some more time to wrap it up and be a good starting point for further development.

TTN Node Receive problem Convert the received value to int or long