Skip to content

Apache Mynewt Sensor Network Application for STM32 Blue Pill and nRF52 with Visual Rust, NB-IoT, GPS, iBeacon, NimBLE, ESP8266 (WiFi Geolocation) and nRF24L01

License

Notifications You must be signed in to change notification settings

lupyuen/stm32bluepill-mynewt-sensor

Repository files navigation

Apache Mynewt Sensor Network Application for STM32 Blue Pill with Rust, ESP8266 and nRF24L01 (includes Geolocation)

If you're looking for...

You are now at the older branch for STM32 Blue Pill with nRF24L01 and ESP8266. Check the tutorial...

Build Your IoT Sensor Network — STM32 Blue Pill + nRF24L01 + ESP8266 + Apache Mynewt + thethings.io

Contents

This repository contains...

  1. my_sensor_app: Sensor Network Application

  2. boot_stub: Mynewt Bootloader Stub

  3. adc_stm32f1: Mynewt Driver for ADC on STM32F1

  4. custom_sensor: Custom Sensor Definitions

  5. esp8266: Mynewt Driver for ESP8266

  6. hmac_prng: HMAC pseudorandom number generator with entropy based on internal temperature sensor

  7. nrf24l01: Mynewt Driver for nRF24L01

  8. remote_sensor: Mynewt Driver for Remote Sensor

  9. semihosting_console: Mynewt Console for Arm Semihosting

  10. sensor_coap: Sensor CoAP Library

  11. sensor_network: Sensor Network Library

  12. temp_stm32: Mynewt Driver for Internal Temperature Sensor on STM32

Requirements

  1. STM32 Blue Pill or Super Blue Pill

  2. ESP8266 or nRF24L01 or both

Configuration

The program runs in 4 modes:

1️⃣ Standalone Node (Blue Pill with ESP8266): The program polls the Blue Pill internal temperature sensor every 10 seconds and transmits the sensor data (JSON format) to a CoAP (UDP) Server, such as thethings.io.

Edit the settings in targets/bluepill_my_sensor/syscfg.yml as follows:

syscfg.vals:
    # TUTORIAL1: 1
    TUTORIAL2: 1
    # TUTORIAL3: 1
    ...

2️⃣ Sensor Node (Blue Pill with nRF24L01): The program polls the Blue Pill internal temperature sensor every 10 seconds and transmits the sensor data (CBOR format) to the Collector Node.

Edit the settings in targets/bluepill_my_sensor/syscfg.yml as follows:

syscfg.vals:
    # TUTORIAL1: 1
    # TUTORIAL2: 1
    TUTORIAL3: 1
    ...

Set SENSOR_NODE_HW_ID_1 to the Hardware ID of the Blue Pill.

3️⃣ Collector Node (Blue Pill with nRF24L01 and ESP8266): The program receives sensor data (CBOR format) from the Sensor Node, and transmits the sensor data (JSON format) to a CoAP (UDP) Server, such as thethings.io.

Edit the settings in targets/bluepill_my_sensor/syscfg.yml as follows:

syscfg.vals:
    # TUTORIAL1: 1
    # TUTORIAL2: 1
    TUTORIAL3: 1
    ...

Set COLLECTOR_NODE_HW_ID to the Hardware ID of the Blue Pill.

4️⃣ WiFi Geolocation (Blue Pill with ESP8266): The program sends WiFi Access Point MAC Addresses and Signal Strength scanned by ESP8266 to a CoAP (UDP) Server, such as thethings.io. See https://github.com/lupyuen/thethingsio-wifi-geolocation

thethings.io will call the Google Geolocation API to compute the latitude and longitude based on the WiFi data. For public display, the computed geolocation is pushed to a web application hosted on Google Cloud App Engine. See https://github.com/lupyuen/gcloud-wifi-geolocation

Edit the settings in targets/bluepill_my_sensor/syscfg.yml as follows:

syscfg.vals:
    # TUTORIAL1: 1
    TUTORIAL2: 1
    # TUTORIAL3: 1
    WIFI_GEOLOCATION: 1
    ...

Install Apache Mynewt for Windows and macOS

To install Apache Mynewt for Windows and macOS, refer to the tutorials...

  1. Build Your IoT Sensor Network — STM32 Blue Pill + nRF24L01 + ESP8266 + Apache Mynewt + thethings.io

  2. Connect STM32 Blue Pill to ESP8266 with Apache Mynewt

  3. Create your IoT gadget with Apache Mynewt and STM32 Blue Pill

Install Apache Mynewt for Ubuntu Linux

  1. Launch Video Studio Code

  2. Click Terminal → Run Task

  3. Select [0] Install Apache Mynewt

  4. When prompted, click on the Terminal pane and enter the sudo password. The password only needs to be entered once.

  5. The setup script will take a few minutes to download and install the build tools. When it’s done, we should see Done!

  6. Exit and restart Visual Studio Code. This activates the installed extensions.

In case of problems, compare your log with this setup log.

Installation, Build, Flash and Debug Logs

Sample logs for Windows and Ubuntu Linux may be found in the logs folder

How This Application Was Created

Based on

https://mynewt.apache.org/latest/tutorials/sensors/sensor_thingy_lis2dh12_onb.html

https://mynewt.apache.org/latest/tutorials/sensors/sensor_nrf52_bno055.html

cd /mnt/c
newt new stm32bluepill-mynewt-sensor
cd stm32bluepill-mynewt-sensor
cat project.yml

newt install
newt pkg new -t app apps/my_sensor_app
newt pkg new -t lib libs/semihosting_console

newt target create bluepill_boot
newt target set bluepill_boot bsp=@apache-mynewt-core/hw/bsp/bluepill
newt target set bluepill_boot app=@apache-mynewt-core/apps/boot
newt target set bluepill_boot build_profile=optimized

newt target create bluepill_my_sensor
newt target set bluepill_my_sensor bsp=@apache-mynewt-core/hw/bsp/bluepill
newt target set bluepill_my_sensor app=apps/my_sensor_app
newt target set bluepill_my_sensor build_profile=debug

project.yml should contain

project.name: "my_project"

project.repositories:
    - apache-mynewt-core

repository.apache-mynewt-core:
    type: github
    vers: 1.6.0
    user: apache
    repo: mynewt-core