Bluetooth based PIR motion detecting application using STM32 board

1. Introduction

In this project we will use a PIR sensor to detect motion. Once motion is detected, it will trigger an interrupt and the BleuIO dongle connected to the board will advertise for 25 seconds. You can expand the project based on your needs further.

A PIR (passive infrared) Sensor is an electronic device that  detects heats from human or animal body, giving a detection signal when movement happens in a given area or range of the sensor.

For this project, we will need one dongle and a PIR sensor (for example: https://www.digikey.com/short/4v12z2nw).
When the BleuIO Dongle is connected to the Nucleo boards USB port the STM32 will recognize it and set up a new device name for the dongle: BleuIO PIR Detected. This will show up when the dongle is advertising.

2. Using the example project

2.1 What we will need

2. How to setup project

2.1 Downloading the project from GitHub

Get project HERE

https://github.com/smart-sensor-devices-ab/stm32_bleuio_pir_example


Either clone the project, or download it as a zip file and unzip it, into your STM32CubeIDE workspace.

2.2 Importing as an Existing Project

  • From STM32CubeIDE choose File>Import…
  • Then choose General>Existing Projects into Workspace then click ‘Next >’
  • Make sure you’ve choosen your workspace in ‘Select root directory:’
  • You should see the project “stm32_bleuio_pir_example”, check it and click ‘Finish’.

If you download the project as a zip file you will need to rename the project folder from ‘stm32_bleuio_pir_example-master’ to ‘stm32_bleuio_pir_example’

5. Connecting the sensor

Connect the PIR Sensor Gnd to ground and Vdd to power and Output to a pin of your choice on the Nucleo board (In the example we use PA0)

If you want a different PIN you will need to go into the STM32Cube ioc file and make some edits:

  • Click on PA0 and select Reset_State in the STM32Cube ioc file.
  • Click on your desired Pin and select EXTIO
  • Then go to GPIO under System Core and make sure you setup the pin as follows:

    GPIO mode: External Interrupt Mode with Rising edge trigger detection

    GPIO Pull-up/Pull-down: Pull-down
  • Then go to NVIC under System Core and make sure EXTI line0 interrupt is enabled

6. Running the example

  • In STMCubeIDE click the hammer icon to build the project.
  • Open up the ‘STMicroelectronics STLink Viritual COM Port’ with a serial terminal emulation program like TeraTerm, Putty or CoolTerm.

Baudrate: 115200

Data Bits: 8

Parity: None

Stop Bits: 1

Flow Control: None

  • In STMCubeIDE click the green play button to flash and run it on your board. The first time you click it the ‘Run Configuration’ window will appear. You can just leave it as is and click run.
  • Connect the BleuIO Dongle.

7. Output

When the PIR sensor detects movement it will trigger an interrupt that in turn will tell the BleuIO Dongle to advertise for 25 seconds. Just so the PIR Sensor will not trigger constantly we have put a 20 second timeout before it will trigger again. If no new interrupts have been detected after the 25 second advertising timer has run out the BleuIO Dongle will stop advertising and wait for a new interrupt to happen.

The yellow LED on the STM32 board also toggles if there is a movement.

Hope you found this article informative.

Share this post on :

Benefits and use cases of Bluetooth Low Energy technology

We live in a day where wireless data transfer is a rather common phenomenon. From offering location services or audio streaming to maintaining device networks and data transfers, all is made possible due to wireless communication technologies and Bluetooth is one of them. Bluetooth is a short-range wireless technology which helps exchange data between connected devices over short radiuses. 

Bluetooth Low Energy is essential for IoT networks due to its ability to preserve battery power on devices. Major use cases of Bluetooth Low Energy technology include:

Use Cases

  • Mobile payments at retail outlets.
  • Wireless charging for multiple devices.
  • Keep track of traveller luggage at the airport by using smart tags.
  • Monitor air quality of the indoor environment by using BLE-powered sensors.
  • Remote monitoring of patient’s health conditions
  • Autonomous vehicles with intelligent seats and steering wheels, intelligent proximity reporting etc
  • Smart Home automation systems with sensors for tracking fire breakouts, water leakages, or motion in case of robbery.

Advantages of Bluetooth Low Energy technology

  • Sends an ID number via BLE advertising channels
  • The 2.4 GHz frequency controls interference in signals.
  • Determines the location of users within its range
  • Longer battery life by keeping the radio off when not required
  • Uninterrupted broadcast using Bluetooth beacon 
  • The devices are able to establish connections and faster data transfer.
  • Small size (maximum up to 255 bytes) data transfer which is helpful for IoT-based applications
  • The 128-bit AES algorithm ensures the safety of data transfer.
  • Low power consumption compared to other wireless technologies.
  • Comparatively lower cost of deployment and maintenance of chipsets and modules.

The BleuIO is Bluetooth low energy USB dongle that can be used to create Bluetooth low energy application. Just use the AT Commands available on the device for faster development.
The BleuIO is a fully integrated solution, providing MCU and Bluetooth® radio in one chip, based on Dialog Semiconductor latest Bluetooth chip DA14683. The FLASH based device permits field or boot upgradable, while application is stored on FLASH memory.
Projects and tutorials with source code can be found at https://www.bleuio.com/blog/?bleprojects

Share this post on :

Integration of Bluetooth technology within Embedded Systems

Bluetooth Low Energy (BLE) is one of the most widely applicable low-power connectivity standards. Its purpose is to connect devices over a fairly short range. BLE was developed with IoT applications in mind, which has special implications for its design.

Integration of Bluetooth technology within Embedded Systems facilitates an expansive range of Application Domains to support devices at various design levels. Engaging Bluetooth into an embedded system creates value in device capability for specific needs, via the implementation of Bluetooth Profiles that can help the data transfer between compatible devices. Recent introductions to Bluetooth LE Audio in the SMART phone market deliver revolutions in Bluetooth audio capability, enabling users to share audio from a single device to multiple wireless headsets.

Bluetooth Low Energy is used almost everywhere, which is one of its core strengths compared to other low-power networks. This is one of the reasons why everyone looking into BLE when designing their solutions. Because of the well-established name of Bluetooth Classic, BLE had an easier time gaining trust among developers. All these factors combined made it the obvious choice for many consumer IoT applications and much more.

On the other hand, Bluetooth Low Energy is constantly being developed and perfected to meet the most current demands of the market, therefore, it is one of the top choices for embedded system developers to integrate BLE in their solutions.

The BleuIO is Bluetooth low energy USB dongle that can be used in embedded system solutuions. Just use the AT Commands available on the device for faster development.
The BleuIO is a fully integrated solution, providing MCU and Bluetooth® radio in one chip, based on Dialog Semiconductor latest Bluetooth chip DA14683. The FLASH based device permits field or boot upgradable, while application is stored on FLASH memory.
Projects and tutorials with source code can be found at https://www.bleuio.com/blog/?bleprojects

Share this post on :