Running Wi-Fi Sockets and Controlling 8 BLE Devices

INTRO

We have created a demo for controlling 8 BLE peripherals with IoT-HAT with Raspberry Pi Zero.

This demo is similar to our Duo Demo Controller 8 BLE peripherals RedBear Duo.

SETUP

Raspberry Pi Zero and IOT-HAT - RedBear IOT-HAT added WiFi and BLE functions to Pi Zero, and running a Nodejs socket server with Sandeep Mistry's noble BLE library (https://github.com/sandeepmistry/noble) in Central role that will accept connection through Port 8888.

BLE Peripherals - BLE Nano (https://developer.mbed.org/platforms/RedBearLab-BLE-Nano/) running BLE firmware developed on mbed platform.

mbed-enabled-logo

App -  iOS App using TCP/IP socket connection to IoT HAT + Pi Zero and controlling eight BLE peripherals

Protocol – same protocol with Duo Demo. It is in JSON format:

{
"RGB" :
{
"ID" : 1,
"OpCode" : 1,
"R" : 255,
"G" : 50,
"B" : 100
}
}

ID – ID # for the BLE peripheral
OpCode – Operation – 1 to Set, 2 to Read
R, G, B – Color for Red, Green, Blue

USE

When the nodejs socket server starts, the nodejs app will also start scanning BLE peripherals. When LED switch on, it indicates the BLE peripheral is connected to the Pi Zero + IoT-HAT.

Just like our RedBear Duo Demo, we entered Pi Zero's IP address in our iOS App. The App will select port 8888 and connect to Pi Zero's IP address. Once successfully connected, the APP with switch to controller mode. There will be eight control sets with different device number.

We also wire up one of the GPIO pin, to turn off all LEDs from the PiZero itself.

NOTES

  • This Demo shows that PiZero with BLE central role, you can replace GPIO with BLE peripherals.
  • BLE peripherals such as RedBear BLE Nano can connect multiple sensors and trigger multiple actions. You can use PiZero and IOT-HAT as IoT Gateway to perform data collection and remote control.
  • Now you do not need cable between Pi and other GPIO modules and place in different location within BLE range.