LMIC FOR STM32CubeMX in 15 minutes

Hi @descartes,

Indeed, we could say once a day or even spontaneously. Multiple opening/closing of the valve in a short time is not required. So one message will be sent to the device per day or even none at all.
If the valve remains closed nothing important will happen. However, if it were to remain open, water would be wasted. It is a school project but I would like to adapt it as much as possible to reality.

I am aware that maybe LoRa would not be the best solution for this, as there are other, possibly easier options. However, the key to the project is to use LoRa.

My project actually has two devices, one is dedicated exclusively to the reading of humidity, temperature and soil moisture sensors, while the second one opens or closes the valve, this is the one I am talking about. All the data is sent through LoRa.

To be completely honest, I didn’t know anything about LMIC. I am trying to learn about LMIC, hence my initial question. After talking to you, exposing my project to you, it has left me uncertain as to whether it will be able to work without too many problems, knowing that I will only be sending one value to the device.

I’m sorry if my questions may seem unlogical or unintelligent. Thank you very much for your time, patience and help.

We don’t do LoRa - we do LoRaWAN.

It’s very simple - you read the docs and look at the examples - it pretty much tells you where to code. If you can’t get it going with LMIC, you won’t have much joy with the more complex setups. But mostly it’s about mindset, it’s not trivial stuff, there are many moving parts, but if you look at each section individually and not worrying about the whole overall, you’ll build the systems.

You may want to look at LMIC-node which is the most documented & gift-wrapped version ever. You’d have to look at using the Blue/Black Pill setup with some modifications.

Thank you for the information link @descartes

Now, Im testing my end node with the code from @skovholm. I can see it on my GW but it cannot join on TTN console. I got a MIC Mismatch error. I checked my DEVEUI, APPEUI, and former devdeky (now APPKEY). Im using LoRaWAN version 1.0.1 but I tried with 1.0.3 too, but I have the same problem.

What could be the problem?

Regards.

Check the docs for the endian-ness of the EUIs.

The AppKey is not end sensitive.

Hi @descartes

I reversed the bytes of APPKEY, but it doesn’t work. I was reanding about endian-ness. Are you trying to tell me that I should enter my numbers without inverting because APPKEY is in Big Endian, and DEVEUI and APPEUI are on little endian?

No, I was pretty clear that the AppKey is not end sensitive. Whereas the EUI’s are endian specific which is why you need to check the docs. So pretty much the reverse of your interpretation.

If you are using the ancient code base of the IBM LMIC of 2016 it may not be clear. More recent versions are clear. More recent versions are far more compatible with pretty much everything LoRaWAN so you may get the code base at the top of this thread working, it wasn’t a good choice, which is why I directed you to LMIC-node which has gold-plated documentation with gift-wrapping.

In the meanwhile, if you’ve had your EUI’s MSB, try them LSB. DO NOT try to mix & match - it’s either BOTH MSB or BOTH LSB.

1 Like

hello everybody

i have used this lib and project last day and every thing was ok. it joins to ttn very fast by sending just 1 or 2 request join

but i test it today and it takes 20min to connect successfully

and this is my gateway log and rssi


my distance from gateway is about 30m with couple of brick wall

Referencing your duplicate post, this is by design - you are likely recycling the DevNonce and duplicates are rejected by the LNS. For development work you can turn this off in the console or you can make your version aligned with LMIC which does NOT support v1.0.4 incrementing Nonces.

Edit 11 Jan: failed to include NOT in the last sentence - LMIC doesn’t support incrementing DevNonces as required for v1.0.4 so you MUST use v1.0.3

actually i need to have deep undrestand of concept of lorawan
but i only study “the thing network” document could you give me road map to have better undrestand of it
i didnt found anything with this title in forum does it exist?

thank you my friend
i test it and this is result
Screenshot from 2024-01-11 10-03-39

i found somewhere in my code that devNonce variable initialize with a random number and i comment it and asign a fix value to that

please give more detail I’m too much beginer

That will guarantee it gets re-used…which is the problem. :frowning: You want a value (preferably random?) that increments each time and isnt re-used. Note any given device has a limited pool of DevNonces (actually quite a lot!) which under normal use & life time operation should not become exhausted, but if joining regularly (some badly witten s/w joins every time before 1st data TX and is a waste of space/should be avoided like the plague) such that you run out in the working life of the device then only option is to delete device in LNS and start again!

How about the Learn link at the top of the every forum page? And the link bottom right to the documentation on every console page?

And then there is the LoRaWAN specification on the LoRa Alliance website.

There is an error in my post above - I missed a not - I’ve edited this now - LMIC does NOT support v1.0.4 so if you’ve selected that as your device version, it will need to be changed to v1.0.3

1 Like

Screenshot from 2024-01-13 12-49-11
I have enabled reset join nonces and reset used DevNonces
you mean this steps?

i did them but still reJoining time is around 15min

We’d need some more info on what it’s doing for those 15 minutes - serial logs from the device as text formatted with the </> tool plus screen shots at a reasonable “old person” resolution of the exact same time from the device console in verbose mode.

sorry for big delay
i am posting console log as you say
and notice that it is first join attemp takes 20min to join
serial log:

============== DEBUG STARTED ==============
JOINING
try joining
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
JOINED
val = 000000DF
EV_TXSTART
Unknown event
TXCOMPLETE
EV_TXCOMPLETE (includes waiting for RX windows)
val = 000000DF
EV_TXSTART
Unknown event
val = 000000DF
TXCOMPLETE
EV_TXCOMPLETE (includes waiting for RX windows)

console log:




after i enabled Reset join nonce
and press Reset used DevNonce




A summary of what you see would help speed up feedback. And please format serial logs with the </> tool

in summery I’m using lmic in stm32 and testing otaa joining method
but there is 2 problem:

  1. it takes to much time to join something around 20min
  2. and when i reset the device or reprogram it connecting takes to much time although i heve “reset used devnonce” key in console setting

my first pictures is console log for first time joining
and second pictures is console log after reseting device

main question is how i can reduce this time buecaus i’m in developing and i need to test many times???

device log(even dont have any thing helpfull):

============== DEBUG STARTED ==============
JOINING
try joining
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
EV_TXSTART
Unknown event
JOINED
val = 000000DF
EV_TXSTART
Unknown event
TXCOMPLETE
EV_TXCOMPLETE (includes waiting for RX windows)
val = 000000DF
EV_TXSTART
Unknown event
val = 000000DF
TXCOMPLETE
EV_TXCOMPLETE (includes waiting for RX windows)

This!

I meant a summary of any differences you may have seen after you’d done the reset

actually no defferences after reset!
do you have any idea what should i do? :man_facepalming: