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.
[New 2023-01-28] Pinout diagram MiniPill LoRa
With the design of the MiniPill LoRa a few major progresses are made:
New design
- 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 pcb and SMT components the pcb 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.
Remarks on compiling with PlatformIO
For using this board you have to add a custom board. This is can easily done by adding some files to you PlatformIO configuration. These files and the instructions are available in this repository: https://gitlab.com/iot-lab-org/minipill_lora_board.
The hardware
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.
Programming
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:
https://gitlab.com/iot-lab-org/minipill_lora_lmic_low_power_node_button_wakeup
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
Low power
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.
sleep power | 1,90E-06 | A |
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) |
Examples | ||
CR2032 | 210 | mAh |
0,4 | Years lifetime | |
LS14250 | 1200 | mAh |
2,0 | Years lifetime | |
LS14500 | 2450 | mAh |
4,1 | Years lifetime |
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:
Network tests
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).
Building costs
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 | |
RFM95W | € 4,60 | + |
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:
https://www.thethingsnetwork.org/forum/t/minipill-lora-stm32-low-power-node
Contact
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.
Congratulations
Is it possible to buy your kit ?
Best regards
stéphane
Good day,
My name is Kobus Steenkamp from South Africa.
I want to congratulate you on this report.
It is one of the best that i have seen!
Keep on with the good things!
Kind regards,
Kobus
Thanks Kobus for you positive response!
With kind regards,
Leo.
Hoi Leo,
Gaaf project! Ik wist niet dat jij ook in die hoek bezig was. Ga de blogs nog even lezen. Zeer interessant allemaal.
Groet, Jan te Lindert
Hello Leo,
after fighting for years with LMIC and Atmega 328’s memory limits, I saw your great project and didn’t resist.
I’ve just received ten partially assembled pcbs from JLCPCB and I’m waiting impatiently for a brand new ST-LINK programmer.
Thank you very much for sharing the project and keep up the good working!
Kind regards,
Fabio
Hallo Fabio,
Thank you for you positive response. Please keep me informed about your experience with the MiniPill LoRa and if you can send some pictures of your project(s).
Kind regards,
Leo.
Hi Leo,
I have purchased some of the boards JLCPCB and soldered the components on it. Unfortunately I am not able to get the power consumption levels you see. With the code provided the lowest Consumption is 330 nA. If I pull off the BME280 the consumption drops to 90 nA.
This was using the Arduino EDI. Later I also used PlatformIO and after some struggles I was able to compile your code (some warning messages during the process). In the end I was able to flash the bin file with STM32Cube programmer. The openocd programmer didn’t work (gave JTAG communication error??).
The power consumption level was however the same (330 nA).
The code is working & I receive the messages via TTN. So what could be wrong? Appreciate any help you can give.
Thx Rob
That are awesome news. Congrats! Would it be possible to use the Minipill also as a receiver? For the 328P connected to a RFM95 there is library that supports CAD mode of the RFM95 and therefore consums just a few µA in RX mode. Works great with a 328P but I’m running out of memory, pins and ram.
Hello Max,
It is possible to use the MiniPill as a receiver, hence its receives LoRaWAN data in the downlink mode.
I have no experience with the CAD mode, but maybe with a few adjustments on the 328P code you can use the same code when it does not use low level ATMEL code.
Indeed the problem with the 328P is the memory!
Regards,
Leo.
I thought I’d answered this question in private mail.
Now you can buy some kits (max 2) for experimenting for transportation and production cost.
You can also use the JLCPCB project and copy this and order your own.
Kind regards,
Leo.
Answered this comment in private (Dutch) mail.
With kind regards,
Leo.
Pingback: Co2 and environment meter with LoRa capability | iot-lab.org
Das Board wird nur mit 3,3v betreiben oder?
Ich sehen keine Pullups für den Sensor oder sind die auf der Sensor Platine.
Was für einen LDO würdest du empfehlen um von Liion zu betreiben?
Ich versuche in Deutsch zu beantworten, aber meine English oder Niederländisch ist besser.
* Das Board wird nur mit 3,3v betreiben oder?
Das stimmt, aber 2.8-3.6V is also möglich. Ich brauch auch Lithium Batterien (Saft LS 14500) ohne LDO.
* Ich sehen keine Pullups für den Sensor oder sind die auf der Sensor Platine.
Die Pullups sind auf der Sensor Platine. Ein “resistor” auf der Sensor Platine ist gelöscht, so weniger Leistung werde gebraucht.
* Was für einen LDO würdest du empfehlen um von Liion zu betreiben?
Ich wurde die MCP1700-330 empfehlen. Er hatte ein “Low-Quiescent-Current”. Das ist die elektrischer strom die gebraucht wurde durch die LDO wenn die Elektronik kein Strom verbraucht.
https://ww1.microchip.com/downloads/en/DeviceDoc/MCP1700-Low-Quiescent-Current-LDO-20001826E.pdf
Fiel Geluck mit ihre project!
Mit freundlichen Grüßen,
Leo.
Hi,
sorry that I bother one more time.
There are still a few questions:
1. Can I wake up the STm32 via RTC with the circuit?
I discovered a quartz on some circuits. Isn’t that necessary?
2. They also work without the boot pins. Does the ST-Link do that?
3. Which pins are the SCA SDL for I2C and do I need pullups?
Thank you
Hello Mike,
No problem at all. On most questions I can answer straight away.
1. Can I wake up the STm32 via RTC with the circuit?
Yes I think you can, It is possible to use the RTC interrupt to wake up the processor. I have not done it, so my answer is theoretical.
I think it wil cost you a few uAmps because of the RTC circuit that will be running, but also I am not sure how much this is.
I discovered a quartz on some circuits. Isn’t that necessary?
That’s right, for example the bluepill has a 32.768 kHz external crystal.
Especialy when you have long times to wait (weeks/month) the input clock is very important. That is the reason why you should use an external clock sources like a crystal. When you have to wait for hours this time base is less important and you can use the internal RC clock.
Here is a picture of the clock setup.
2. They also work without the boot pins. Does the ST-Link do that?
I do not understand the question completely, but I think you mean this:
I program the chip with ST-LINK. You can also use serial or USB as programming source. Then you have to load a boatloader on it (With ST-LINK) and set the boot config (boot pins) on another setting. I guess this will cost you some flash memory.
I like to program (and debug) the controller directly.
3. Which pins are the SCA SDL for I2C and do I need pullups?
Here are the pins:
On the pull-up, I can remember that de I2C bus must have two 10k pull up. You can enable the internal pull-up, but they are typical 45kOhm:
So for optimal performance I should use external pull-up.
Have fun with your project.
With kind regards,
Leo.
Good job on the board. I can’t seem to get the board to go to into deepsleep. It wakes up right after deepsleep is called. I even tried the basic timed sleep code in the STM32LowPower folder. What am I missing?
Hi,
I just noticed that you have used the Serrriel outputs PA9 PA10.
Then how do you do this to check?
Usually you do this via serial output.
Thank you
Hello Mike,
I do not understand your question completely, but I think the next example will help you:
You can use both serial ports on the MiniPill LoRa and even alternative pins for those ports.
With kind regards,
Leo.
/*
Serial test and clock speed check
Remember serial speed not at 115200 or higher when clock on 1MHz.
*/
#include
// by default UART1 (Serial or Serial1) is enabled (PA10 = Rx, PA9 = Tx)
// due to setup in variant.cpp
// HardwareSerial Serial1a(PB7, PB6); // Using Alternative pins for Serial 1
HardwareSerial Serial2(USART2); // or HardWareSerial Serial2(PA3, PA2) // (Rx, Tx);
void setup()
{
Serial.begin(9600);
Serial2.begin(9600);
}
void loop()
{
Serial.println(“Hello Serial1”);
Serial.println(F_CPU);
Serial2.print(Serial.readString());
Serial2.println(“Hello Serial2”);
delay(1000);
}
After some mail exchange, Haimiko figured out that the problem was his Windows 10 cross-compiler. On an Ubuntu machine it worked fine.
He tested also a different Windows 10 machine, without succes of a good binary.
Thanks Haimiko, for the testing and sharing this information.
Leo.
Hey Leo, just starting to play around with some of this stuff so please excuse this noob questino. However if I was only monitoring 1 or 2 inputs for open or closed condition do I still require an MCU or can I just the RFM95? I noticed there are DIO pins on the RFM modules and was just wondering if I could report these as open or closed on a periodic bases without requiring an MCU at all.
Hi
Is EasyEda project suitable for ordering with SMT assembly? i mean are parts used from JLCPCB assembled library?
Or maybe you have a few boards to sell? would be a way of donation for your great work.
Hello Mike,
Thank you very much for all your contributions, I am following everything step by step.
At the stage of programming with PlatformIO I have a problem that I can’t get out of.
When I use platform = ststm32@13.0.0 or platform = ststm32@ , I get errors related to STM32RTC and STM32LowPower.
If I use platform = ststm32@15.0.0 it gives me HAL problems.
How could I solve this problem to test the code? Thanks in advance,
Hi Leo,
I am trying to reuse your code in one of my project, whereas I am getting the below error. I guess it has something to do with variant header file which needs to be added. Can you please guide with me the details.
Attaching the error details for your reference.
Processing minipill_l051c8_lora (platform: ststm32; board: minipill_l051c8_lora; framework: arduino)
————————————————————————————————————————Verbose mode can be enabled via `-v, –verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/minipill_l051c8_lora.html
PLATFORM: ST STM32 (15.4.1) > MiniPill L051C8 LORA
HARDWARE: STM32L051C8T6 32MHz, 8KB RAM, 64KB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink, stlink)
PACKAGES:
– framework-arduinoststm32 @ 4.20200.220530 (2.2.0)
– framework-cmsis @ 2.50700.210515 (5.7.0)
– toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
Warning! Cannot find linker script for the current target!
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 21 compatible libraries
Scanning dependencies…
Dependency Graph
|– STM32IntRef
|– STM32duino Low Power @ 1.1.1
| |– STM32duino RTC @ 1.1.1
|– LMIC-Arduino @ 1.5.0+arduino-2
| |– SPI @ 1.0
|– SPI @ 1.0
Building in release mode
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_adc.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_adc_ex.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_can.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_cec.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_comp.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_comp_ex.c.o
Compiling .pio\build\minipill_l051c8_lora\SrcWrapper\src\HAL\stm32yyxx_hal_cordic.c.o
: fatal error: variant_MINIPILL_L051C8_LORA.h: No such file or directory
*************************************************************************************
Regards,
Elavarasi
Answered by PM.
Leo.
Answered by PM a while ago.
Leo.
Answered a while ago by PM.
Yes it is possible to order the MiniPill LoRa with SMT assembly. Please leave a message and I will answer you by PM.
Leo.
Answered by PM a while ago.
Leo.
Hello Leo, I hope you’re doing well.
Your project has helped me a lot with missing details in a lab I’m doing.
I would like to ask you for help, because I’m using the ST32L432KC and I couldn’t reduce the consumption below 380uA in sleep mode. Did you use any different clock configuration for the ST? My project has exactly the same components as you are using in your PCB, with the only difference being that I’m using the L4 and you are using the L0.
Thank you and I hope to speak with you soon.
Thiago
Pingback: Plain and Simple LoraWan (LowPower) Library for STM32 - iot-lab.org