[LoRaWAN/TTN] Arduino Pro Mini / RFM95W examples for different sensors

Thomas Telkamp and Matthijs Kooijman are reporting about their progress building a “cheapest possible [TTN] node useful for relatively simple use cases”. For communicating with The Things Network (TTN), being able to talk LoRaWAN is obligatory. Enjoy reading:



Thomas Telkamp and Matthijs Kooijman originally adapted the IBM LMiC (LoraMAC-in-C) library to run under the Arduino environment, see:


Do you know what RFM library they are using? Would be nice if we could use a common radio RFM95 / RFM69 lib and switching TTN as option on or off. So we can use similar code in case we have TTN available or sending packages to a “'private” gateway only.

Yes, it’s all about the open source IBM LoRaMAC-in-C (LMiC) library ported to Arduino Core by Thomas Telkamp and Matthijs Kooijman, as outlined above. See also:

Please don’t hesitate to ask any further questions. Contributions are also very welcome.

Sorry to disappoint you: Unfortunately, we can’t do it on this lower level you might be imagining by relying on the same common radio library like the RadioHead Packet Radio library and “just” sticking LoRaWAN on top. As the LMiC library also talks directly to the radio device, the adapter would have to be in the layer above.

P.S.: Due to this anomaly on the communication path, i’d consider it as yet another handler for the TerkinTelemetry library in spe, orthogonal to GSM, WiFi, RFM69 or vanilla LoRa (RFM95). Besides the transport layer, message formats might have to be considered as well when transmitting data through the TTN infrastructure.

Ok, so we should have in mind

GitHub - matthijskooijman/arduino-lmic: ⚠ This library is deprecated, see the README for alternatives.

This library an be quite heavy, especially if the fairly small ATmega 328p (such as in the Arduino Uno) is used. In the default configuration, the available 32K flash space is nearly filled up (this includes some debug output overhead, though). By disabling some features in config.h (like beacon tracking and ping slots, which are not typically needed), some space can be freed up. Some work is underway to replace the AES encryption implementation, which should free up another 8K or so of flash in the future, making this library feasible to run on a 328p microcontroller.

So the topic subject is a bit misleading because it’s more a showcase that it is possible than a working example for us (with additional librarys we need).

So it seems to be no option for the Arduino Pro Mini or the Seeeduino Stalker or Uno (same MC). Perhaps it is working on an Cortex M0 so we have more options.

yes, see here:

It will work for sure on a larger MCU, but there’s still a chance. Have a look at “tiny” variant mentioned by @weef, here’s an excerpt from its documentation:

This library implements the LoRaWAN stack for a LoRa network. It contains the full LoRa stack and works on Teensy platform, ESP8266 and the Ardino Atmega328.


AES Encryption library

After analysing the existing LMIC-1.5 code of IBM for AES encryption I came to the conslusion that the encryption part of LMIC-1.5 is far too complex and too large. And as I did not fit in the Atmega 328 another AES library was ported to the environment. Of course there are several AES implementations available, but since I already had experience with the library of Ideetron, I decided to give that a try. The result should be that the complete LMIC stack would be running on a regular Atmega 328 based MCU and there still be some room left for sensor sketches.

The port was successful, and the sketch now fits on the Arduino Pro-Mini leaving some room for a DALLAS or I2C ibrary and sensor. Simpler interfaces making direct use of the GPIO pins will probably fit as well

Still, after all optimizations the code is large for the small Arduino Nano or ProMini, so there probably is a practical limit to what you can do there.

A post was merged into an existing topic: [LoRaWAN/TTN] Arduino with Microchip RN2483