Image for post
Image for post
STM32 Blue Pill at right with my custom Wisol Sigfox Breakout Board at left

Connect STM32 Blue Pill to Sigfox

Image for post
Image for post

Prepare The Hardware

Image for post
Image for post
Top to bottom: (1) Blue Pill (2) ST-Link (3) SparkFun BME280 (4) Wisol Sigfox Breakout Board (connected to antenna)
Image for post
Image for post
When browsing Sigfox products, click on the “Zone” box to show only products for your region
Image for post
Image for post
My Custom Wisol Sigfox Breakout Board
Image for post
Image for post
U.FL antennas - I tested the one at the top

Image for post
Image for post
Blue Pill (right) connected to Wisol Sigfox Breakout Board (left) on port UART2, and to BME280 sensor (centre) on port SPI1 https://github.com/lupyuen/send_altitude_cocoos/blob/master/stm32/bme280spi.fzz

Connect The Hardware

Blue Pill Pin PA4  (SS1)   → BME280 Pin !CS
Blue Pill Pin PA5 (SCK1) → BME280 Pin SCK
Blue Pill Pin PA6 (MISO1) → BME280 Pin SDO
Blue Pill Pin PA7 (MOSI1) → BME280 Pin SDI
Blue Pill Pin 3V3 → BME280 Pin 3.3V
Blue Pill Pin GND → BME280 Pin GND
Blue Pill Pin PA2 (TX2) → Wisol Pin RX
Blue Pill Pin PA3 (RX2) → Wisol Pin TX
Blue Pill Pin 3V3 → Wisol Pin 3.3V
Blue Pill Pin GND → Wisol Pin GND
Image for post
Image for post
Connecting Blue Pill to ST-Link USB Debugger
Image for post
Image for post
Connecting Blue Pill to ST-Link USB Debugger
Image for post
Image for post
Both jumpers should be set to the “0” positions

Install The Software

Download The Source Files

git clone https://github.com/lupyuen/send_altitude_cocoos.git
cd send_altitude_cocoos
scripts\linksrc.cmd
chmod +x scripts/*.sh
scripts/linksrc.sh

Install Visual Studio Code and PlatformIO

Image for post
Image for post
Image for post
Image for post
#define CONFIG_ARTICLE5  //  Uncomment to support Article #5
Image for post
Image for post
Our Blue Pill IDE — Visual Studio Code with PlatformIO

How Does The Program Read Sensors?

Image for post
Image for post
Overall Flow of the Blue Pill Program. The Altitude Sensor Task is not shown.
From https://github.com/lupyuen/send_altitude_cocoos/blob/master/main.cpp
https://github.com/lupyuen/send_altitude_cocoos/blob/master/temp_sensor.cpp
Simplified from https://github.com/lupyuen/send_altitude_cocoos/blob/master/sensor.cpp
Image for post
Image for post
Life of a Sensor Task: Read, Send, Sleep
Image for post
Image for post
SPI1 Semaphore prevents two tasks from accessing the SPI1 port connected to BME280

How Do We Transmit Sensor Data To Sigfox?

Image for post
Image for post
Overall Flow of the Blue Pill Program. The Altitude Sensor Task is not shown.
Image for post
Image for post
Life of Network Task: Receive, Aggregate, Transmit

How Do We Handle Wisol UART Commands?


Configure The Blue Pill Program

enable_debug();       //  Uncomment to allow display 
// of debug messages in development
// devices. NOTE: This will hang if
// no debugger is attached.
// disable_debug(); // Uncomment to disable display
// of debug messages. For use in
// production devices.
//  enable_debug();
disable_debug(); // Debug is now disabled.
//  Start the Network Task.
setup_wisol(&wisolContext, &uartContext, uartTaskID,
COUNTRY_SG, false);
#define SIMULATE_BME280 // Uncomment to simulate a BME280 sensor
#define SIMULATE_WISOL // Uncomment to simulate a Wisol module

Image for post
Image for post
Command buttons in the status bar

Build, Upload And Monitor Your Blue Pill Program

Image for post
Image for post
Building your Blue Pill program
Image for post
Image for post
Uploading your program to the Blue Pill
Image for post
Image for post
Connect to view Blue Pill debug log
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Blue Pill Debug Log showing the execution of the program, just like the Arduino Serial Monitor
Image for post
Image for post
Remember to Trash the debug log

Blue Pill gets chatty with Sigfox when the lights flash

Watch Blue Pill Run

Debug Log for the Blue Pill, running with a real Wisol Sigfox Breakout Board and real BME280 sensor
https://docs.google.com/presentation/d/1gXET7xfqv6-aEPF7rmWA8swOta9hPCrTuA-kfOkKpko/edit?usp=sharing
https://docs.google.com/presentation/d/1eGyXvlWfa3HGuaInj1Vwve_1km9IL7Gxm6BcZb2GHGE/edit?usp=sharing
Image for post
Image for post
Timeout error in Blue Pill Debug Log

Configure The Sigfox Backend

Image for post
Image for post
Image for post
Image for post
To activate your custom breakout board: Click Device → New and enter your device ID and PAC (shown in the Blue Pill debug log). Click Register As Prototype
Image for post
Image for post
Image for post
Image for post
Under Device Type → Callbacks, click New then Custom Callback
Image for post
Image for post
https://g9uvbknb0k.execute-api.ap-southeast-1.amazonaws.com/default/sigfoxCallbackDownlink
Sigfox Callback Configuration https://gist.github.com/lupyuen/07aa992d4714bc53c9db60a6a3e88b51
Image for post
Image for post
Click the Downlink circle to enable downlink
Image for post
Image for post
Callback and Downlink Status under Device → Messages
Image for post
Image for post
If you don’t receive any messages, go to Device → Information, click Disengage Sequence Number

Unleash Your Blue Pill

Image for post
Image for post
Breadboard Power Supply at the top
Image for post
Image for post
Stress Testing the Blue Pill with Wisol Sigfox Module and BME280 Sensor. Works perfectly after 12 hours of non-stop operation!

Blue Pill Tips: How To Solder Header Pins To Blue Pill

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
My soldering iron with LEDs, very fine solder wire and soldering kit
Image for post
Image for post
Image for post
Image for post
Measure and break the header pins
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Mount the Blue Pill on a breadboard

Further Reading

Coinmonks

Coinmonks is a non-profit Crypto educational publication.

Sign up for Crypto News

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by CoinCodeCap.com Take a look

Create a free Medium account to get Crypto News in your inbox.

Lup Yuen Lee 李立源

Written by

Techie and Educator in IoT 物聯網教師

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Lup Yuen Lee 李立源

Written by

Techie and Educator in IoT 物聯網教師

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store