LowPowerLab Forum

Hardware support => RF - Range - Antennas - RFM69 library => Topic started by: ursm on May 19, 2016, 06:03:43 AM

Title: LMIC-library and Moteino Mega
Post by: ursm on May 19, 2016, 06:03:43 AM
Hi
in TheThingsNetwork https://thethingsnetwork.org/ (https://thethingsnetwork.org/) we often use the LMIC-Library https://github.com/tftelkamp/arduino-lmic-v1.5 (https://github.com/tftelkamp/arduino-lmic-v1.5)
Unfortunately the MoteinoMega misses 3 wires to make it directly usable.
Question: do you plan to build a LoRaWAN compatible board with the needed wires?
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on May 19, 2016, 01:24:50 PM
UPDATE: the LMIC variant of MoteinoMEGA can now be ordered from here (choose LMIC variant option): https://lowpowerlab.com/shop/product/119

I think someone else asked a similar question but I'm sure the wiring was different, in their app they needed one extra wire. So i'm puzzled, should I start planning to make a different board every time a new library uses different wiring?
Is it not reasonable to wire the extra pins like we see in the photo above?
I already have a dozen variants of Moteinos, one yet to be released and it feels like I spread my wings very far already. The problem is the more variants I try to stock the larger stocks of chips and parts I have to have on hand, and the days of hand assembly are gone when I could make 5 units at a time if that's all I wanted. Sorry if that sounds like complaining  ;)
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on May 19, 2016, 05:09:05 PM
hi Felix
thanks for answering so fast. Yes, I could anticipate what your answer would be;
but like a lot of your customers using RadioHead for their 'private' network, there will be a huge community use (the sole) LMIC library for their sensors on LoRaWan (TTN).
And it's fun, we get some of your LoRa-boards, because they fulfilled (except the needed wires) most of our requirements for a solid basic infrastructure building our sensors on top of it.
The connections of the additional (3 or 4) wires are, as from my opinion, not crucial. I made it so because it was convenient.
The definition in the program is as:
// Pin mapping
const lmic_pinmap lmic_pins = {
  .nss = 4,
  .rxtx = LMIC_UNUSED_PIN,      // (5) should be foreseen for later release (ok for A, needed for C)
  .rst = 3,
  .dio = {2, 1, 0},
};

I would not enforce you to build a new version, but probably you should listen to the LoRa community before making you decision.
Thanks in advance, urs
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on May 20, 2016, 08:13:36 AM
Thanks for the suggestion.
I'd like to see more requests at the very least. And consistency.
Title: Re: LMIC-library and Moteino Mega
Post by: gonzalocasas on May 20, 2016, 08:59:55 AM
Hi Felix,

I'm also on the things network community and I agree with @ursm in that it would be great to have the moteino work without having to make changes to it. Maybe something along the lines of what Dragino v1.3 LoRa shield does with jumpers could work for moteino as well?

Cheers
Gonzalo
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on May 20, 2016, 09:23:49 AM
Maybe solder jumpers?
Title: Re: LMIC-library and Moteino Mega
Post by: dbrgn on May 20, 2016, 09:38:10 AM
I'm also interested in building nodes for the things network, and the Moteino Mega looks great to get started.

I'd like to order a few of them, but would also be happy if the soldering jumper wires wouldn't be required.
Title: Re: LMIC-library and Moteino Mega
Post by: lukas on June 02, 2016, 10:49:16 AM
I've sodered up 15 so far, and would certainly order a couple more of a "LMIC" version :-)

lukas
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on June 28, 2016, 04:58:23 PM
How imperative are the wirings to D0 and D1?
For instance I am wondering if routing DIO1 and DIO2 to D21 and D22 which are much closer by.

This is what it looks like for D0 and D1, these are solder jumpers, you'd have to still solder them but it allows the use of the board without hardwired LMIC:
(http://i.imgur.com/9Jg8pdp.png)
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on June 29, 2016, 05:19:09 AM
Hi Felix
That sample looks great.   :)
1.) I put your question to Thomas, the creator of the LMIC library. He should know it best.
     Hopefully I get an answer quickly.
2.) I'm a little confused, looking at the  \MoteinoMEGA\pins_arduino.h. There a DIL40 package is shown and that package does not correspond to the QFN package you're using.
so to what signals/pins do D20/D21 be assigned?
3.) It would be nice having closed solder bridges, but that's a minor issue.
4.)  .nss = 4 & .rst = 3  are connected too? (It's not clear on the sample)

regards, Urs
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on June 29, 2016, 11:37:36 AM
@ursm:

2) Don't worry about the pins declaration, that is based on an older pins file, nothing has changed. The package used on the MEGA is TQFP44, not QFN.
3) I followed your first post/photo wiring where you soldered DIO1=>D0, DIO2=>D1, RST => D3.
My proposal is to change these to: DIO1=>D22, DIO2=>D21, RST => D3. The reason is much shorter routing which helps with signal integrity.
4) Yes, NSS => D23 (as before) and RST => D3 as you proposed.

Also, someone else suggested I add a SOT23 footprint for this I2C device which allows EUI64 unique global addressing: http://ww1.microchip.com/downloads/en/DeviceDoc/20002124F.pdf
This one would require more work so are you familiar with this type of chip and whether the LMIC lib supports something like that or how it would be used?
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on June 29, 2016, 03:03:13 PM
@Felix
I got an answer from Thomas, so you can do it as you suggested.
about the topic of EUI64: I don't think, that it's no need having a hardware based EUID. It's possible to get some of them as "soft bulk"
It's not supported by the library and must be programmed in user space and then given to the LMIC to work with it.
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on June 29, 2016, 10:23:36 PM
@Felix
I got an answer from Thomas, so you can do it as you suggested.
about the topic of EUI64: I don't think, that it's no need having a hardware based EUID. It's possible to get some of them as "soft bulk"
It's not supported by the library and must be programmed in user space and then given to the LMIC to work with it.

Great, so I rewired them this way, more obvious labels also:
(http://i.imgur.com/vNHDQGT.png)

How is this library different than things-network: http://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html
That supposedly supports EUI64, hence the other request to add a pad for that device. Trying to figure that one out then this LMIC variant would be ready for fabbing.
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on June 30, 2016, 04:54:45 AM
That supposedly supports EUI64, hence the other request to add a pad for that device.
Please use this https://github.com/matthijskooijman/arduino-lmic (https://github.com/matthijskooijman/arduino-lmic) updated library.
The DEVEUI must be changed in the user program (example/ttn.ino)
   static const u4_t DEVADDR = 0x03FF0001 ; // <-- Change this address for every node!
and the SX variant in /src/lmic/config.h, which is newerdays set to SX1276 = RFM95W    #define CFG_sx1276_radio 1

Good luck!
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on June 30, 2016, 09:31:05 PM
Ok here are the latest changes.

Pin mappings (through non-bridged solder jumpers):
DIO1=>D22, DIO2=>D21, RST => D3

This also includes the EUI-64 chip footprint for those interested.

(http://i.imgur.com/hz634FT.png)
(http://i.imgur.com/grNuC7M.png)
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on July 03, 2016, 04:31:36 AM
very well made!
thanks for picking up our ideas

looking forward seeing it in the store  :)
Title: Re: LMIC-library and Moteino Mega
Post by: Charly86 on July 04, 2016, 07:00:23 PM
Guys,

I proposed a software fix for LIMC to works without connecting DIO0/DIO1 and DIO2, since LIMC does not put device in sleep mode and just scan port change, device is wot waked by hardware IRQ
So all can be done in soft just pooling RFM IRQ register, works fine on my ESP8266 and should be the case for Moteino Mega ;-)

See https://github.com/matthijskooijman/arduino-lmic/issues/24/

But your EUI64 chip on board rocks !!!
Title: Re: LMIC-library and Moteino Mega
Post by: lukas on July 13, 2016, 09:41:22 AM
Great work, Felix, looking forward to the new Moteinos! RE library: this one https://github.com/matthijskooijman/arduino-lmic just uses 20k, when you disable JOIN, PING and BEACONS in config.h. So the R4 ones work great now, just in case you wan to upgrade that pcb as well :)
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on July 29, 2016, 08:38:54 AM
PCBs arrived and I assembled a panel.

UPDATE: the LMIC variant of MoteinoMEGA can now be ordered from here (choose LMIC variant option): https://lowpowerlab.com/shop/product/119

If you want to order these before they become "official" just order the MoteinoMEGA-LoRa and mention in the comments you want the LMIC/EUI variant and I will send you this, and I will include the EUI chip for you to solder if you want the EUI64 MAC.

(https://i.imgur.com/8Gtf51Q.png)
Title: Re: LMIC-library and Moteino Mega
Post by: Charly86 on July 29, 2016, 08:51:22 AM
Hey, nice boards Felix, Love the silk pin indication of RFM module, much easier to place it ;-)
Title: Re: LMIC-library and Moteino Mega
Post by: TomWS on July 29, 2016, 09:58:15 AM
Nice configurability with very clearly marked options.  I like that you put the serial eeprom on it also. 

So this board will accept an RFM69HCW?  Probably will be my go to Mega if that's the case.

Tom
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on July 29, 2016, 10:01:57 AM
Thanks Tom,
Yes it will take the RFM69HCW (equivalent to 69HW but with LoRa pinout - the "C" in HCW meaning "pin backwards compatible").
Basically this board will be the new MoteinoMEGA-LoRa R2.

I need some extra logistics before I can pick & place the EUI on there so until then the EUI64 chip & 4.7k resistors come separately in a bag  ;)
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on July 29, 2016, 01:38:40 PM
PCBs arrived and I assembled a panel.
If you want to order these before they become "official" just order the MoteinoMEGA-LoRa and mention in the comments you want the LMIC/EUI variant and I will send you this, and I will include the EUI chip for you to solder if you want the EUI64 MAC.

Hi Felix
It would be a pleasure testing two of the "preshop" boards.
You get an order from me.
Please RFM95 , flash and EUI64

Thanks for finishing our ideas to a new version
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on July 29, 2016, 03:27:09 PM
You're welcome and thanks for the order.
Below's a sample native code that will read the MAC address from the included Microchip 24AA02E64 EEPROM (http://ww1.microchip.com/downloads/en/DeviceDoc/20002124F.pdf):

Code: [Select]
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire

void setup(void)
{
  Serial.begin(115200);
  Serial.print("wire init...");
  Wire.begin();
  Serial.println("done");
}

void loop(void)
{
  Serial.println("Loop...");
  readEEPROM_MAC(0x50, 0xF8);  //0x50 is the I2c address, 0xF8 is the memory address where the read-only MAC value is
  delay(2000);
}
 
void readEEPROM_MAC(int deviceaddress, byte eeaddress)
{
  Wire.beginTransmission(deviceaddress);
  Wire.write(eeaddress); // LSB
  Wire.endTransmission();
  Wire.requestFrom(deviceaddress, 8); //request 8 bytes from the device

  while (Wire.available()){
    Serial.print("0x");
    Serial.print(Wire.read(), HEX);
    Serial.print(" ");
  }
  Serial.println();
}

Should produce this output:


wire init...done
Loop...
0x0 0x4 0xA3 0xB 0x0 0x19 0x7F 0xB7


The bold part is the MICROCHIP identifier (constant), the italic part is the variable part (unique with each chip).
Title: Re: LMIC-library and Moteino Mega
Post by: galluta on August 26, 2016, 12:32:01 PM
@Felix

Just got a new Moteino Mega. I followed the this thread but I am not sure what pins to soder.

Should I soder these?

Pin mappings (through non-bridged solder jumpers):
DIO1=>D22, DIO2=>D21, RST => D3


Also on the RFM95 shouldn't it be DIO0 and DIO1?

Thanks
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on August 26, 2016, 01:25:47 PM
Should I soder these?

Pin mappings (through non-bridged solder jumpers):
DIO1=>D22, DIO2=>D21, RST => D3

Also on the RFM95 shouldn't it be DIO0 and DIO1?

Should you? It's up to you. The board works exactly the same as before, but it offers you an easy way to connect those DIOs/RST to given pins without using wires.
DIO0 is always hardwired to D2 already.
Title: Re: LMIC-library and Moteino Mega
Post by: ursm on August 26, 2016, 02:16:22 PM
Just got a new Moteino Mega.
sorry that I was so lazy replying here.
we made good experience with the new board and used for the LMIC library

Code: [Select]
/* Pin mapping                           for the new Moteino Mega R2 with solder bridges*/
const lmic_pinmap lmic_pins = {
  .nss = 4,
  .rxtx = LMIC_UNUSED_PIN,
  .rst = 3,
  .dio = {2, 22, 21},                      // DIO0, 1, 2
};

thanks Felix for the new board layout
Title: Re: LMIC-library and Moteino Mega
Post by: johnmiddleton on October 09, 2016, 12:23:31 PM
Hi - what do the marked solder bridges do - sorry for the noob question
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on October 10, 2016, 08:23:02 AM
Hi - what do the marked solder bridges do - sorry for the noob question

They are SMD 0805 pads for adding passives. Generally you don't need to worry about those. They are marked with || which would suggest they are for capacitors.
Title: Re: LMIC-library and Moteino Mega
Post by: perky on October 10, 2016, 02:37:09 PM
They are SMD 0805 pads for adding passives. Generally you don't need to worry about those. They are marked with || which would suggest they are for capacitors.

Interesting, the 3.3V one is obvioulsy for a decoupler, but a cap on the antenna? Was that some attempt at matching (or using 915MHz modules for 868MHz or something)?
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on October 10, 2016, 02:39:52 PM
Interesting, the 3.3V one is obvioulsy for a decoupler, but a cap on the antenna? Was that some attempt at matching (or using 915MHz modules for 868MHz or something)?
I put a cap pad cause that felt appropriate in Eagle. Could be used with a cap or inductor for matching I guess. I never used these myself, someone asked for these pads a while back.
Title: Re: LMIC-library and Moteino Mega
Post by: perky on October 10, 2016, 02:54:50 PM
I put a cap pad cause that felt appropriate in Eagle. Could be used with a cap or inductor for matching I guess. I never used these myself, someone asked for these pads a while back.
OK. I suppose one possible use for that footprint might be to fit a 50R load resistor and not fit the antenna, that'll protect the output during development. Also the small stub would radiate a very little possibly simulating a distant transmitter.
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on October 10, 2016, 03:06:27 PM
@perky, great ideas. I like the distant node one especially.
With the 50R I could use a pogo pin to a permanently fixed 50R but I guess the pogo pin could act as an antenna too perhaps. Not a huge deal though since in my post production testing I do a conditional output test with ATC as well so the output is very brief just enough to ensure there's TX/RX working.
Title: Re: LMIC-library and Moteino Mega
Post by: alexsh1 on October 13, 2016, 05:47:48 AM
@Felix - outstanding work! I have just place an order for the LMIC Mega
Title: Re: LMIC-library and Moteino Mega
Post by: lafleur on November 24, 2016, 09:41:13 AM
Felix

Can you post the schematic in PDF for the Mega-LoRa board...

Thanks
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on November 25, 2016, 08:52:58 AM
Here:

(http://i.imgur.com/6WlKtrX.png)
Title: Re: LMIC-library and Moteino Mega
Post by: kreeve on March 06, 2018, 03:35:42 PM
I realize this this is a old thread, but I could use some insights.

I am familiar with LoRa as implemented on the Moteino boards, and have used it successfully.  I now have a Things Network Gateway running and connected.  My next project is to get a node connected. I do not have any experience with Nodes for the Things Network.  I have read through this thread, and I think I understand what I need to do.

#1  solder the three pads to connect the pins from LoRa module for use with LMIC library

#2 use this LMIC Library.   https://github.com/matthijskooijman/arduino-lmic

#3 change settings in the library settings file.

My main question is do I need the EUI-64?  What is it for?

Thanks for any insights.


Is there anything thing that has changed since this thread?
Kevin
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on March 07, 2018, 10:11:47 AM
My main question is do I need the EUI-64?  What is it for?

Is there anything thing that has changed since this thread?
If you have to ask, my opinion is either you have to ask the LMIC library creators to make sure you have the best accurate answer, or you don't need it.
Nothing has changed from a hardware perspective since this thread has last posted.
The LMIC is simply an option that was added because of the request from that thread, and you can get the parts if you need them directly from LowPowerLab ($1 per unit) rather than buy/ship them from a separate location.
Title: Re: LMIC-library and Moteino Mega
Post by: kreeve on March 22, 2018, 06:10:57 PM
I am using this code on a Moteino Mega USB and the code loads and runs.  I see the Loop...   but not getting any value back.  Nothing of the wire.read.
I am basically trying to figure out how to get the Device EUI from the Moteino to use with the LMIC library stuff for the things network.   



You're welcome and thanks for the order.
Below's a sample native code that will read the MAC address from the included Microchip 24AA02E64 EEPROM (http://ww1.microchip.com/downloads/en/DeviceDoc/20002124F.pdf):

Code: [Select]
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire

void setup(void)
{
  Serial.begin(115200);
  Serial.print("wire init...");
  Wire.begin();
  Serial.println("done");
}

void loop(void)
{
  Serial.println("Loop...");
  readEEPROM_MAC(0x50, 0xF8);  //0x50 is the I2c address, 0xF8 is the memory address where the read-only MAC value is
  delay(2000);
}
 
void readEEPROM_MAC(int deviceaddress, byte eeaddress)
{
  Wire.beginTransmission(deviceaddress);
  Wire.write(eeaddress); // LSB
  Wire.endTransmission();
  Wire.requestFrom(deviceaddress, 8); //request 8 bytes from the device

  while (Wire.available()){
    Serial.print("0x");
    Serial.print(Wire.read(), HEX);
    Serial.print(" ");
  }
  Serial.println();
}

Should produce this output:


wire init...done
Loop...
0x0 0x4 0xA3 0xB 0x0 0x19 0x7F 0xB7


The bold part is the MICROCHIP identifier (constant), the italic part is the variable part (unique with each chip).
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on March 23, 2018, 08:30:05 AM
I am using this code on a Moteino Mega USB and the code loads and runs.  I see the Loop...   but not getting any value back.  Nothing of the wire.read.
I am basically trying to figure out how to get the Device EUI from the Moteino to use with the LMIC library stuff for the things network.

First make sure to verify the chip is soldered correctly along with the I2C pullups (4.7k SMD chip resistors provided with the LMIC option). If you show me a photo of the board/setup I can see if anything looks out of order.
The example code you quoted should work just fine. Once that works, then you are probably ready to use it with the ThingsNetwork (not sure how that is done though).
Title: Re: LMIC-library and Moteino Mega
Post by: JohnO on June 15, 2018, 06:17:48 AM
Thank you for your work Felix. I would like to try to build a Moteino MEGA USB with the LMIC chip. Are there any Eagle files for the MEGA USB with LMIC?
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on June 18, 2018, 02:45:51 PM
Not shared at this time, but you will have a lot of trouble doing this manually, it's a complex board.
Unless maybe if you plan to use a stainless steel stencil and reflow oven?
Title: Re: LMIC-library and Moteino Mega
Post by: JohnO on June 21, 2018, 12:19:23 PM
Thank you for the advice Felix. I don't have a reflow oven and don't plan to get into stencils anytime soon.
Title: Re: LMIC-library and Moteino Mega
Post by: flok on August 24, 2018, 04:18:39 PM
Please use this https://github.com/matthijskooijman/arduino-lmic (https://github.com/matthijskooijman/arduino-lmic) updated library.
The DEVEUI must be changed in the user program (example/ttn.ino)
   static const u4_t DEVADDR = 0x03FF0001 ; // <-- Change this address for every node!
and the SX variant in /src/lmic/config.h, which is newerdays set to SX1276 = RFM95W    #define CFG_sx1276_radio 1

Hi,

I've got one of these red lora usb moteino boards - lora-r5-usb it says.

Now when I change all the required addresses (been there before with an other type of board and there I got it right  :)) it starts up with:

Starting                                                                                                   
FAILURE                                                                                                     
/home/folkert/Projects/sketchbook/libraries/arduino-lmic/src/lmic/radio.c:689                               

What should I do?
(I've got 2 of these boards and both give this error)
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on August 25, 2018, 06:40:34 PM
Maybe ask whoever made the lmic library why this would happen?
Title: Re: LMIC-library and Moteino Mega
Post by: everhamme on February 14, 2019, 05:43:10 PM
Note:  I got LMIC working with Moteino Mega..

0. solder bridges for DIO1, DIO2, and RST
1. use LMIC library from here https://github.com/matthijskooijman/arduino-lmic
2. open src/lmic/config.h and set correct configuration (US915 for me)..  i also set
3. for ABP example set your keys..   use this pinmap

Code: [Select]
const lmic_pinmap lmic_pins = {
    .nss = 4,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 3,
    .dio = {2, 22, 21},
};

4.  for OTAA example set your keys (make sure to REVERSE order for APPEUI and DEVEUI)
5. for OTAA also after the LMIC_reset();  add these lines

Code: [Select]
  LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);
  LMIC_selectSubBand(1);
  LMIC.dn2Dr = DR_SF9;
  LMIC_setLinkCheckMode(0);
  LMIC_setDrTxpow(DR_SF7,14);
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on February 14, 2019, 09:41:33 PM
everhamme,
Great, thanks for sharing that!

So no other hardware needed? Like the EUI64 chip for MACID?
Someone else was suggesting the FLASH-MEM (which incidentally also has a hardcoded 64bit ID) could be used the same way.
Title: Re: LMIC-library and Moteino Mega
Post by: everhamme on February 15, 2019, 01:07:31 PM
everhamme,
Great, thanks for sharing that!

So no other hardware needed? Like the EUI64 chip for MACID?
Someone else was suggesting the FLASH-MEM (which incidentally also has a hardcoded 64bit ID) could be used the same way.

Not needed unless you want to programatically use the built in chip to reference/store  keys to allow for faster joining or if you're rolling out a product that uses hard-wired keys......  The LoRaWAN 1.1 spec does require that NSK and ASK keys get stored so if you restart/power down the device you don't need to initiate another OTAA join, which consumes resources and needs more bandwidth. But this isn't enforced yet.. so you can initiate as many OTAA joins as you'd like.     

I do like the implementation of this "provisioning" feature that MCCI uses on their LoRa devices ...https://github.com/mcci-catena/Catena-Sketches/tree/master/catena4450m101_sensor#lorawan-provisioning.  You don't need to compile and upload custom keys.. you can just use a terminal window to copy/paste keys.

MCCI takes their products a little further down the firmware/library side to ensure easy implementation for folks. 
Title: Re: LMIC-library and Moteino Mega
Post by: Felix on February 15, 2019, 01:18:00 PM
Thank you for these extra details, I appreciate it.