Easy LoRa Node - Low Power (With STM32L072CZT6, LoRa and battery)
Low-Power Easy LoRa Node with STM32L0 and LoRa SX1278
- Hardware is Dragino LSN50 v1.0: https://wiki.dragino.com/index.php?title=Lora_Sensor_Node-LSN50
- Internal LoRaST module: https://wiki.dragino.com/index.php?title=LoRa_ST
STM32DUINO liraries
- Code is written in Arduino style from stm32duino https://github.com/stm32duino/Arduino_Core_STM32
- Other stm32duino libraries: https://www.arduinolibraries.info/authors/stm32duino
- Noted issue with stm32duino and SPI LoRa: stm32duino/Arduino_Core_STM32#279
- Updated 2020-06-12: Can add STM32 via Board Manager and use B-L072Z-LRWAN1 directly https://github.com/stm32duino/Arduino_Core_STM32#getting-started
- Release note: https://github.com/stm32duino/Arduino_Core_STM32/releases
Referenced B-L072Z-LRWAN1: It is actually STM32L072CZT6
- I-CUBE-LRWAN: https://www.st.com/en/embedded-software/i-cube-lrwan.html
- Specs: https://www.st.com/resource/en/data_brief/b-l072z-lrwan1.pdf
1. Hardware
1.1 Pin locations
1.2 Pin mapping for STM32L072CZT6 (used by LSN50)
Original at https://github.com/dragino/Lora/blob/master/LoRaST/v1.0/LoRa%20ST%20v1.0_Sch.pdf
2. Connect to hardware
2.1 Use STLink v2 to upload code
STLink v2 USB
Driver is at https://www.st.com/en/development-tools/st-link-v2.html#tools-software
Pin mapping
- LSN50 -> STLink v2
- PA14 -> SWCLK
- PA13 -> SWDIO. NOTE: NEXT TO PA13 is PB14. WE NEED PA14!!!
- VCC -> 3.3+
- GND -> GND
Switch of LSN50 is ISP to upload code. It's recommended to remove UART TTL USB before uploading code via STLink
STLink v2 will show up in USB Device, not Ports (COM & LPT)
2.2 Use UART to debug
- LSN50 -> CP1202 USB TTL
- GND -> GND
- PA2 -> RX
- PA3 -> TX
3. Programming guides
3.1 Installation of stm32duino to Arduino IDE
Additional Boards Manager URLs: https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
3.2 Add STM32 variant
- Updated 2020-06-12: Can add STM32 via Board Manager and use B-L072Z-LRWAN1 directly https://github.com/stm32duino/Arduino_Core_STM32#getting-started
Outdated steps
- Instruction to add variants https://github.com/stm32duino/wiki/wiki/Add-a-new-variant-(board)
- STM32 Source file location: https://github.com/stm32duino/wiki/wiki/Where-are-sources#stm32-core-sources-files-location
- Genpinmap for STM32L072CZT6 (used by LSN50) https://github.com/stm32duino/Arduino_Tools/tree/master/src/genpinmap/Arduino/STM32L072C(B-Z)Tx
- QUICK START - Custom variant for LSN50 by EASY LORA team) Copy and modify these file in C:\Users\(USERNAME)\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.5.0 https://github.com/IoTThinks/EasyLoRaNode_LowPower/tree/master/stm32duino
3.3 Compilation of Arduino code using Arduino IDE on STM32 board
Port COM4 in the picture is for UART. This is for debugging purpose.
The port is blank when we use STLink to upload code and UART USB is not plugged in
4. Reference
- User manual for v1.0 LSN50_LoRa_Sensor_Node_UserManual_v1.0.pdf
- AT Manual for stock firmware DRAGINO_STM_AT_Commands_v1.3.pdf
- SHT1x library https://github.com/practicalarduino/SHT1x
- Arduino LoRa STM32 https://github.com/armtronix/arduino-LoRa-STM32
- I2C for STM32 and Arduino https://circuitdigest.com/microcontroller-projects/stm32-stm32f103c8-i2c-communication-tutorial