LMIC FOR STM32CubeMX in 15 minutes

open project properties → settings, under MCU GCC Compiler select Miscellaneous. Click add flag -fcommon

reason cubeide 1.9.0 update

best regards
Hjalmar

Hi skovholm,

First of all, thank you for solving me this problem. It works now. I appreciate you for the help.

But now, I want to ask you something. With this project, we can receive data from TTN? Or send it to TTN only?.

Thank you.

Any compliant LoRaWAN device can receive data but in very limited quantities and on TTN there is a Fair Use Policy that restricts things further.

If you prime goal is to send data to the device it is likely that you have picked the wrong technology - a LoRaWAN device may send an uplink every two hours and typically receive a housekeeping or settings update once a fortnight.

If you can say how much data you are thinking is needed sending to TTN and how much back down and how often we can give better advice.

You would benefit from reading the Learn section that is linked top-right of this page as it will give you a lot more detail on the fundamentals.

Hi @descartes,

My goal is to send just a value. I want to open a solenoid valve and Im trying to send a open/close data to my end node. No more data will be send to it, and the device won’t send anything to TTN.

For more information, I created a Node Red application which send the open/close value to the end device via TTN. The end node device will open/close the solenoid valve according to the Node Red command.

I think that I could make it work with one value, right @descartes?

Thank you!. Regards

Sort of, did you see what I said about the device receiving something very rarely but sending frequently? And there is so much you need to learn because most devices can only receive when they send. And you haven’t said how often you want to control the valve. And you should consider what would happen if a message didn’t get through - because LoRaWAN is not the best system for command and control.

But you’d learn all this if you read the Learn section. The volunteers answering here can’t do training by drip feed.

So you want to send a command to operate the valve.

Is it of no consequence whatsover if the node supposed to receive the command does not receive the command or when it does and tries to operate the valve it fails to do so ?

Yes, thats my main goal. Send a commansd to operate the valve.

The valve is going to operate when I gave the word. So it is going to be just a “true or false” value.
It will not be sent cyclically, only when I decide. I just wish that when I decided, it would arrive correctly on my device, with no delivery errors.

Regards.

So you actually want to send the command to the valve and not only have the receipt confirmed and also for the command to be sent until its acknowledged ?

And, importantly, you did not answer the question about the consequnces of the ‘command’ to the node not working.

LoRaWAN is not a remote control system …

Please carefully read the responses and answer the questions otherwise the volunteers will lose interest in helping you.

  • How often do you need to control the valve?
  • What would happen if it didn’t close when you want it to?
  • What would happen if it didn’t open when you want it to?

And from reading the learning section as suggested above, what level of packet loss should you plan for on a LoRaWAN network?

And how might you work around that packet loss?

And what would be the impact on the network because of it?

As you’ve not mentioned owning a gateway, what will you do if the one you are using goes offline?

Hi guys,

First of all sorry for not respond all the comments, I’m new on the forum.

@descartes Answering your questions:

  1. Like I said in my last post, I only want to control de valve when I need to, whitout any frecuency. It doesn’t a cyclical task. When I decide to open or close the valve, that’s when I want the data to be sent.
  2. If it doesn’t close when I want, it will continue watering a flower. I create a watering control system. It just for a school project.
  3. Same answer that point 2.

The packet loss that I should expect up to 10% according to Learn Section. If I think on just 1 value, I believe that it will be a low packet loss. I don’t know how to work if I have packet loss with one value.

I don’t know about the impact on the network, sorry.

I own a milesight UG67 gateway, so it isn’t a problem for me.

@LoRaTracker Thanks for your respond.

I just want to receive my command on my device like any other value. Then I will code that command for the valve to performance the opening.

I know LoRa isn’t a remote control system. I developed a Node Red project where I send my open/close decision to TTN.

Like I said on the point 2, if the command doesn’t work, the valve will continue watering my flower.

I hope both understand me. I’m trying my best, and answering you the best way I can.

Thank you for your help and patience. I hope that answered all of your questions.

Your last post didn’t help, this doesn’t help as there are always numbers, even if they are a guess - you could be talking 10 times a minute or once a year - but the fact it is a watering project gives us context to know that it won’t be that often - once a day if that - and you can live with valve not opening, not sure if value left open is an issue.

It’s still a very poor implementation of LoRaWAN - you could use any number of more reliable radios over a short range as a proof that you can control a valve remotely. What would be suitable for LoRaWAN would be automating the watering with a soil moisture sensor and sending updates on that & the water reserve level. Downlinks would be to change the settings.

Now that you’ve read the Learn section and you’ve presumably read the docs for LMIC and you are student that should be used to researching a topic, what is holding you back? The LMIC code has the placeholders for when a downlink arrives, add the code there.

As, by forum policy, we don’t do student homework, feel free to ask questions but you will have to show a lot of detail & prior research to inspire assistance.

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?