I am working on a project with the DISCO_L072CZ_LRWAN1 board. I would like to use the Lora funcionality from this board and although I came across the Sandeep Mistry’s LoRa library, this is not enough. I would like to use the full LoraWAN stack, so that I am compliant with networks like The Things Network. The stack can be found here: http://stackforce.github.io/LoRaMac-doc/index.html
It contains some examples, including one of an endnode and it works as long as I use it within Keil IDE. But I would like to use this stack as well inside the Arduino IDE, but don’t know how to include is. Any advice, or resources that would bring me closer to a solution would be greatly appreciated!
Thanks,
David
the next release will provide pins for driving lora module of the B-l072.
I’ve made some LoRa radio with Sandeep Arduino-Lora library.
https://github.com/stm32duino/Arduino_C … 2/pull/221
For LoraWan, with this board I did no test with Arduino, only with http://www.st.com/en/embedded-software/ … lrwan.html
Anyway, we’ve just release the https://github.com/stm32duino/I-NUCLEO-LRWAN1
allowing to make LoRaWan using the http://www.st.com/en/evaluation-tools/i … rwan1.html
Maybe it could be possible to use it with b-l072 or at least as a base.
Had a closer look to your suggestions. When I add the pin definitions you suggest to be used with the Sandeep library and try to compile an example sketch with the Arduino IDE, I run into error messages: error: 'class SPIClass' has no member named 'setMISO'
https://github.com/stm32duino/Arduino_C … /2018.1.18
which provide
setMISOMy mistake: I was using an older version of the library, which was missing these methods. I am installing the new one right now, that will solve the problem.
I was trying to cherrypick the Endnode implementation today, but I keep running into all sorts of compile errors. It’s a bit overwhelming. It would help if I had more information about the structure and workings of the abstraction layers, all I have now is this: http://stackforce.github.io/LoRaMac-doc/index.html.
Maybe stripping it all to the bare bones will make it work. Let’s try. ![]()
Thanks for your input!
Cheers,
David
It was originally developed by IBM, but unfortunately they dropped it, so it is a bit outdated, but it was working very well for me with Adafruit Feather with RFM95W, whcich is basically SX127x radio. With the examples provided I just had to define some GPIO pins and network keys an it was working right away with LORIOT.
Thanks for the suggestion. I actually looked into that library today. But when I was compiling it, I ran into _FDEV_SETUP_WRITE' was not declared in this scope
So the questions remains which lib I should invest my time in to make it work.
David
I tried (quick and dirty) to drop all the files into one directory, but I keep running into errors. I have the impression that the Arduino IDE is somehow shielding definitions and declarations made in the ST HAL. (But it’s all relatively new form me, so I may be mistaken).
I publish junk a lots and I attempt to combine libraries into the sketch simply to avoid having to have the user given instructions to download and install same. In doing this, I eliminate tons of Q&A from novices about compile errors from non-installed libs. The big issues that have to be faced is that automatic prototyping by the ArduinoIDE can (and will) break and global variables often need to be made local to functional TABS, that is made private.
Tabs with no designated file extension become .INO files and are concatenated at compile time with automatic function prototype declarations. Tabs that are .cpp and .h do not enjoy such automation… back to having to do things the correct C way. You must also include the “xxx.h” file in the xxx.cpp file source.

- Arduino-MultiTab.png (11.6 KiB) Viewed 962 times
Having said this, I haven’t tried your suggestion with the LMIC. It may be possible to solve my problems with your suggestions. I will try later. ![]()
Cheers,
David
[davidb – Wed Mar 14, 2018 3:34 pm] –
Ray, Thanks for your feedback! I will certainly keep this in mind. But unfortunately it won’t solve the whole problem: I also run into redeclarations of functions and variables. And it’s now always clear whether they actually mean the same.Having said this, I haven’t tried your suggestion with the LMIC. It may be possible to solve my problems with your suggestions. I will try later.
Cheers,
David
It may not help right now. It’s alpha, and I have not yet had time to add a B-L072Z-LRWAN1 variant:
https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0
The LoRaWAN class is here:
I will have a closer look at it tomorrow. Thanks for your help!
Cheers,
David
[davidb – Wed Mar 14, 2018 9:44 pm] –
Mr. Pizza, that looks very promising!![]()
I will have a closer look at it tomorrow. Thanks for your help!
Cheers,
David
Added officially support for B-L072Z-LRWAN1 to the repository. The LoRaWAN examples see to work fine on my end for US915 and EU868. So maybe worth a look.
I have all ready for testing.
With I-CUBE-LRWAN consumtion is around 4uA in sleep.
This is old setup with wires, now it is all on board, and have one more module on test…

- LoRaSTM32L051.jpeg (29.6 KiB) Viewed 671 times
I am not sure about the F1 core being converted. I susoect it’s too differnt
[goran.mahovlic – Wed May 02, 2018 1:27 pm] –
Do you know a arduino code that could work with STM32L051 MCU?I have all ready for testing.
With I-CUBE-LRWAN consumtion is around 4uA in sleep.This is old setup with wires, now it is all on board, and have one more module on test…
LoRaSTM32L051.jpeg
4uA.jpeg
Not sure, but I wanted to add STM32L052 support to this here (if it ever goes non-alpha): https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0
[RogerClark – Wed May 02, 2018 9:19 pm] –
STM32GENERIC Core can probably be ported to that processor.I am not sure about the F1 core being converted. I susoect it’s too differnt
STM core too…
[GrumpyOldPizza – Thu May 03, 2018 12:08 pm] –[goran.mahovlic – Wed May 02, 2018 1:27 pm] –
Do you know a arduino code that could work with STM32L051 MCU?I have all ready for testing.
With I-CUBE-LRWAN consumtion is around 4uA in sleep.This is old setup with wires, now it is all on board, and have one more module on test…
LoRaSTM32L051.jpeg
4uA.jpegNot sure, but I wanted to add STM32L052 support to this here (if it ever goes non-alpha): https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0
Great, it could work. I will test it with L082 when I get time. Then I can switch to L051 ….
Now two more problems are left If you can help?
After fixing missing lib got lot of errors probably related with .a file ![]()
/home/mistery/Arduino/hardware/TleraCorp/stm32l0/system/STM32L0xx/Lib/libstm32l051xx.a(timer.o): In function `TimerGetCurrentTime’:
/home/mistery/Arduino/hardware/TleraCorp/stm32l0/system/STM32L0xx/Source/LoRa/System/timer.c:71: undefined reference to
`stm32l0_rtc_timer_reference’
collect2: error: ld returned 1 exit status
second problem is stm32l0_gpio.h
Where do I find those no. for L051 I have just copy pasted L072 but need to check what will be wrong now…
[goran.mahovlic – Wed May 09, 2018 4:24 pm] –
I did add L051 as variant and “fixed pinout I want to use”Now two more problems are left If you can help?
After fixing missing lib got lot of errors probably related with .a file
/home/mistery/Arduino/hardware/TleraCorp/stm32l0/system/STM32L0xx/Lib/libstm32l051xx.a(timer.o): In function `TimerGetCurrentTime’:
/home/mistery/Arduino/hardware/TleraCorp/stm32l0/system/STM32L0xx/Source/LoRa/System/timer.c:71: undefined reference to
`stm32l0_rtc_timer_reference’
collect2: error: ld returned 1 exit statussecond problem is stm32l0_gpio.h
Where do I find those no. for L051 I have just copy pasted L072 but need to check what will be wrong now…
In general, I would just declare the board to be a STM32L072 and be done. Just looked at your github, and saw quite a few issues:
startup_stm32l051.s is not really gonna work, as it uses the ST HAL’s semantics (actually the Atollic Toolchain). This will not work with the linker scripts and the rest of the infrastructure. Same goes for the linker script.
stm32l0_rtc_timer_reference is defined in stm32l0_rtc.c. So that’s really odd that this one would be missing.
stm32l0_gpio.h: Those are in the datasheet for STM32L051. So it’s kind of some tedious work.
Think about this another way around. STM32L0x1 is a STM32L0x2 without USB. STM32L0x2 is a STM32L0x3 without LCD peripheral. STM32L08x is a STM32L07x with AES peripheral. And STM32L05x is a cut down STM32L07x. All of this from the users perspective, probably not from real silicon.
BTW, does your board have HSE connected to PH0/PH1 ?
I have startup_stm32l051.s from generated code for Makefile.
What do I need to chose to get right one if I generate files from cubeMX?
Ok I will check datasheet It should not be to much difference …
I have just soldered Low Speed crystal on board, and L051 does not have HSE nor Port H … Just two pins on Port C for LSE
So I will probably need to change HSE to HSI but that can be last part before uploading ![]()
I have just copy paste L072 .S .ld and library file to L051
And now it compiles – So now blink LED on PA0 could work – I just need to check if you are using HSE
Blink LED on PA8 – I did define it as A0 is working …
LoRa code is doing steps – I have add blink LED after packet send and led is blinking if I put one module.
But LoRa does not sends anything.
With DORJI module it code stops at beginning and it does not blink.
I first need to check if every pin blinks on scope, and then check if SPI is working…
This is my pinout for now, but if I get it work I will try to use your pinout on new board…

- STM32L051_Arduino_LoRa.png (146.01 KiB) Viewed 523 times
[goran.mahovlic – Thu May 10, 2018 4:30 pm] –
NiceeeeeBlink LED on PA8 – I did define it as A0 is working …
LoRa code is doing steps – I have add blink LED after packet send and led is blinking if I put one module.
But LoRa does not sends anything.
With DORJI module it code stops at beginning and it does not blink.
I first need to check if every pin blinks on scope, and then check if SPI is working…
This is my pinout for now, but if I get it work I will try to use your pinout on new board…
STM32L051_Arduino_LoRa.png
I have tested TimerMillis and works.
And STOP mode with timer is working
DownTo2uAFromArduino.jpgSo for now only SPI problem remains, or maybe some pin miss defined by me
![]()
I see. Next step. The code as of right now for LoRaWAN is hardcoded for CMWX1ZZABZ (want to do this more generically, but time is a problem here).
https://github.com/GrumpyOldPizza/Ardui … 76-board.h
You need to change the GPIOs for your module (is it this here: https://www.tindie.com/products/DORJI_C … -drf1276g/).
You don’t have a TCXO, so you might want to comment the code that is using that pin.
Then you need to mess with https://github.com/GrumpyOldPizza/Ardui … 76-board.c:
Throw out the TCXO code, have SX1276GetWakeupTime() return 1 (no TCXO wakeup time). The RX/TX switch is hooked up rather differently for your module. CMWX1ZZABZ uses 3 GPIOs to route RFI/RFO/PABOOST. The datasheet says (assuming again it’s the DORJI module):
“The switch of TX/RX is realized by controlling the levels of RXTX/RFMOD and DIO4 pins in
Lora mode. When RXTX/RFMOD=VHIGH and DIO4=0, TX is enabled and RX is disabled. When RXTX/RFMOD=0 and DIO4=VHIGH, the RX is enabled and TX is disabled. The level change of DIO4 is controlled by the related register”
So DIO4 has to be configured as DIO4_01 (PllLock) for RX, and DIO4_11 (undefined) for TX. Just odd, but not a biggy. For FSK (EU868, DR_5 I think), this has to be DIO4_01 and DIO4_11 as well (the 11 mapping is undefined for anything by RX) …
Lastly you need to patch SX1276GetPaSelect() to always return RF_PACONFIG_PASELECT_PABOOST.
Guess to make that more portable I needed to add a stm32l0_sx1276.c and stm32l0_sx1272.c piece that messes with the SPI/RESET/DIO0/DIO1/DIO2/DIO3/DIO4/DIO5 pins, TXCO enable/disable, the antenna switch and the RFO/PABOOST selection.
N.b that the SPI code in there bypasses the Arduino SPI stuff. So please make sure that the instance that controls this module is not mapped as SPI or GPIOs in variant.cpp. All the pins are exclusive, so there is no point to have them in the Arduino sandbox exposed as well. The code plays quite a few tricks with low power settings there …
For your board, you do not need HSE. I was just curious.
Since you are using SWD to debug. There is STM32L0.enableSWD() and STM32L0.disableSWD(). During debugging I would recommed to set STM32L0.enableSWD(). This blocks some clocks to be shut off during SLEEP/STOP, at the expense of power. When ready to really use this design, I’d put it STM32L0.disableSWD(). Saves a few uA in STOP mode.
Will check it out when I get home.
I have those two modules already tested with cube 115 stack, and there CMWX1ZZABZ works to.
So I should probably copy paste some stuff from there into your code…
[goran.mahovlic – Fri May 11, 2018 1:33 pm] –
Tnx,Will check it out when I get home.
I have those two modules already tested with cube 115 stack, and there CMWX1ZZABZ works to.
So I should probably copy paste some stuff from there into your code…
Pretty much. Don’t know about the DIO4 yet. IMHO that should perhaps be integrated into sx1276.c (mainly because this is where the Radio driver controls the DIO mappings). On the other hand perhaps sx1276.c should Set DIO4 to PllLock and DIO5 to ModeReady at init time, and then not touch them anymore (unlike Semtech’s code which is all over the place with this).
How did you do this with cube 115 ? N.b. ST’s code is missing a good number of fixes. It also assumes DIO3 is used for CadDetect. The code in ArduinoCore-stm32l0 does not use DIO3. So simple copy and paste will not work.
I will fix receive in 115 and try after that.
How do you use debug from arduino?
Or I just load code and use gdb
As for 115 i am uploading it:
https://github.com/goran-mahovlic/stm32l051_test
I have only fixed for ABP join for DORJI
So I have fixed transmit, but for receive I still need to check datasheet and set registers…
And after transmit lora module goes into SLEEP
I use 112 on filed for a 6 months and did not noticed any real problems.
And I have 114 is working 3 months and seams OK
I did fix some issues at begin but did not notice to many critical problems
[goran.mahovlic – Fri May 11, 2018 5:36 pm] –
I did try all you have described, but still did not manage to get sending work.
I will fix receive in 115 and try after that.
How do you use debug from arduino?
Or I just load code and use gdbAs for 115 i am uploading it:
https://github.com/goran-mahovlic/stm32l051_testI have only fixed for ABP join for DORJI
So I have fixed transmit, but for receive I still need to check datasheet and set registers…
And after transmit lora module goes into SLEEPI use 112 on filed for a 6 months and did not noticed any real problems.
And I have 114 is working 3 months and seams OK
I did fix some issues at begin but did not notice to many critical problems
I just load code and use gdb ![]()
