BLE IOT Sensor and Win10 Host App


The most common question I get is for a simple IOT sensor example. This post shows how to easily set up a BLE device which broadcasts the state of an input pin in its advertisement data. You can use it to show data from passive IR sensor, switch, light sensor or anything else. I also include a C# example to read this data using the BLE host on any Win10 laptop. It’s a very neat demo.

First thing you need is an IOT device. We’re going to use a PSOC BLE development kit: CY8CKIT-042 BLE. You can buy it direct from Cypress, at Mouser or DigiKey. Next thing you need is PSOC Creator. It’s a free integrated development environment from Cypress. Don’t let the “free” fool you though. Creator is highly sophisticated, easy to use and makes BLE development easy. Here’s an example of configuring BLE inside Creator.

Next thing you need is the Creator project. Download it from here, unzip, open with PSOC Creator and program your CY8CKIT-042 BLE. It will start advertising as “BLE Sensor v3”. Data from pin p1.0 on the kit is populated in BLE advertising data with service UUID 0xAAAA. You can verify this with any smartphone application which shows BLE advertisement data.

Finally, you need a Win10 application to view the BLE data. Download here. I used the Microsoft “BLE Watcher” console application, fixed up some references and modified it to read the 0xAAAA service data. You will need to download and install Visual Studio Community from Microsoft here to modify the source code. Otherwise, just run the executable. The console application uses Microsoft API calls to access the BLE host on your laptop, then displays data it receives as shown below.

That’s it. Now you have a working IOT BLE sensor and host application. Connect anything wirelessly to your PC or even the internet.