After successful making a LoRa node with a ATtiny84 and BME sensor (https://www.iot-lab.org/blog/101/), I wanted to reproduce this node with a ARM processor. After 2 years of research and attempts, on an irregular basis, I succeeded.
With the design of the MiniPill LoRa a few major progresses are made:
- Arduino code is still used, combined with a few lines of STM32 HAL code;
- It’s a generic development board, hence the name MiniPill, a wink to the BluePill board. Without the RFM95 chip it can be used for other projects;
- The LMIC library is used for the LoRaWAN protocol with OTAA as connection setup instead of ABP;
NEW: ABP can also be used in the new code. See comments in the code.
- Due to this library it is possible to downlink data to the node and get confirmation of the received data;
- Even lower power is used, 1.9 uA during sleep period.
- With a BME280 sensor temperature, humidity and also pressure can be measured and send through LoRaWAN. VCC voltage is also included in the data.
- Enough pins are available for other sensors or actuators;
- Due to a 4 layer SMT print and SMT components the print is smaller but has an other form-factor. The size is 33.1 mm x 22.9 mm.
- Pinouts are labeled and 4 VCC and GND connectors are available for external sensors.
A few remarks
- To use the code you have to use the PlatformIO toolset;
- A custom board have to be added to the PlatformIO toolset;
- The MiniPill LoRa board have I ordered at JLCPCB and let them put the components on it. It was much easier than solder the SMD on my own;
- To program this board you have to use a ST-LINK V2 or V3 programmer interface. I have tested with the official ones, not a clone. I will try this in a later stadium;
- The most connector pins on this development board has a distance of 2 mm instead of the standard 2.54 mm;
- This board uses a STM32L051C8T6 microcontroller, not all pins are available on this board;
- To reduce cost and space no Ceramic Cristal is used for the clock;
- In version 1.2 drawings and PCB a design error is fixed.
2021-07-03 Remarks on compiling with PlatformIO
Thanks to Andreas a remark on compiling with PlatformIO: “We found this project truly awseome, but when compiling it with PlatformIO we ran into an issue due to a more recent STM32 platform. If you could make a small edit to your platformio.ini of the project this issue will be resolved and maybe will help others to avoid the same problem.
the change is as follows:
– platform = ststm32
+ platform = email@example.com
STM32 version 14.0.0 introduced Arduino Core 2.0.0 which has a tendency to break custom boards… Version 13.0.0 and below are ok :)”
Here is the project on JLCPCB.com: https://easyeda.com/Leo/stm32-minipill-lora-v1-0. Although the link suggest otherwise this is the link is to the latest version: 1.2. The PCB design can be electrical optimised. I do not have very much experience in this.
For the programming I used a ST-LINK v3 programmer with my own made st-link-v3 extender (https://www.iot-lab.org/blog/355/). The programming pins are on the same position as the original STM32 BluePill. You only have to use four pins: GND, SWCLK, SWDIO, VCC-T (for sensing voltage, not to supply power). Power has to be applied on the normal VCC-GND pins. See also the mentioned post for more information on programming STM32.
Remember when the microcontroller is in Sleep mode you cannot program it. So you have to release the RSTn from ground (GND) to reprogram. I achieve that by using a external clamp to shortcut GND and RSTn and release just before the programming is done. Sometimes you have to try this a few times to get the timing right.
You do not have to solder the male header pins on this board. It is quite easy to make a connection with a header without soldering them.
Software: LMIC library
The software is written mostly in Arduino code. For the measurement of the VCC some STM32 HAL code is used. Remember that the code is written with the PlatformIO toolset. A custom board must be added to the toolset. All is explained in the README.md.
The code can be found at https://gitlab.com/iot-lab-org/minipill_lora_lmic_low_power_node
Software: LMIC library and button wakeup
After some items on the Things Network forum about wakeup with a button instead of using a timed wakeup as in the standard examples, I managed to make example code for this. Code can be found here:
Software: Proprietary Library
In my other project on LoRa with a ATtiny84 microcontroller I used an other library for LoRa and RFM95. At the end of November 2020 I ported this code successfully to the MiniPill LoRa node. This code uses only ABP and it is not waiting for downlink data. The lowest power consumption with a BME280 sensor is 1.5uA @20˚C, the same as the LMIC library.
This code can be found at https://gitlab.com/iot-lab-org/minipill_lora_prop_low_power_node
I achieved to power down to 1.9 uA in Sleep mode. I’ve added some evidence :-). At the time of measurement the temperature was 25˚C and more. At 20˚C the current is about 1.5uA in Sleep mode.
Due to the (Arduino) LMIC library the microcontroller runs on full power when the node is sending data and waiting for downlink data. This takes about 8 seconds. I did some measurements with a digital oscilloscope. The power this node uses on sending and waiting for downlink is about
5,46E-06 Ah. For more information on this subject please see my other post on power considerations.
|24||hr per day|
|365,25||days per year|
|0,017||Ah per year|
|16,655||mAh per Year|
|send power||5,46E-06||Ah per measurements|
|288||measurements per day (5 minute timeframe)|
|365,25||days per year|
|0,574||Ah per year|
|574,348||mAh per Year|
|Total||591,0||mAh per Year (5 minute timeframe)|
Please do not forget to remove a 10k resistor on the BME280 module when you use this. This will save you about 300uA (3V/10k). Here is a picture shown of the removed resistor on the BME280 board:
This node is succesfull tested at the The Things Network (TTN) in The Netherlands, as well as on het KPN network (Telecom provider in The Netherlands).
Not unimportant are the cost of this node. Especially when you want to build more than one. I have ordered 10 PCBs for my first tests on version 1.1.
|PCB Prototype||€ 6,12|
|SMT Assembly (includes components)||€ 23,78|
|SMT order discount coupon||-€ 6,99||+|
|Total production||€ 22,91|
|Shipping cost||€ 19,15|
|Import TAX and advance payment fee DHL||€ 26,58||+|
|Total cost for 10 prototypes||€ 68,64|
|Cost per prototype||€ 6,86|
|BME280 (including 6 pins header)||€ 2,99|
|Total cost without battery||€ 14,45|
|ATtiny84 node without battery||€ 14,58|
Discussion at the TTN forum
Luckily some people use my design and use my code. Information and discussions are also available at the Things Network forum:
When you would like to test this MiniPill LoRa yourself, please post a comment on my contact page or below. I will contact you by e-mail in return.