BLE button for your Photon 2

Transform your Photon 2 with a Shelly BLE button, enabling customizable, wireless control for smart home automation and DIY projects.

Story

This guide will show you how to add Bluetooth Low Energy button functionality to your Particle Photon 2, enabling you to create customizable, wireless controls for various applications.

These buttons can be used with any current or future Particle device that supports BLE.

Particle Photon 2

This powerful Wi-Fi microcontroller from Particle continuously scans for nearby Shelly sensors.

For the longest range, add an external BLE antenna (and enable it in the code).

Shelly BLU button setup

Press shortly once, twice, or three times, or press and hold for about 2 sec to emit a signal. It advertises this data in the BTHome format.

It is recommended to update the Shelly devices to the latest firmware using the Shelly app. In case of trouble, you can use the Shelly debug app.

For more technical information, click here.

BTHome

BTHome is an open standard for broadcasting sensor data and button presses over Bluetooth LE.

BTHome is an energy efficient but flexible BLE format for devices to broadcast their sensor data and button presses. Devices can run over a year on a single battery. It allows data encryption and is supported by popular home automation platforms, like Home Assistant, out of the box.

For visiting the BTHome website, click here.

Code

The Particle beacon-scanner library was updated as part of this project to detect BTHome devices.

The minimal code to scan and get information from these devices is on GitHub.

Here's the output of a couple of these buttons read by the Photon 2:

0000124363 [app] INFO: Scanning...
0000124403 [app] INFO: BTHome Address: B0:C7:DE:2C:16:17, Battery: 97, Button: 1, Window: 0, Rotation: 
00000124428 [app] INFO: BTHome Address: B0:C7:DE:61:14:15, Battery: 99, Button: 1, Window: 0, Rotation: 
00000124454 [app] INFO: Scanning...

Printable examples

Here are some nice 3D printables:

Usage Examples

Use these buttons in your project to accomplish practically anything you want on your Photon 2.

Connectivity Options:

If there is no Wi-Fi available, Particle offers alternative options:

Inspired by this project from @tnilsen

11 Likes

Gustavo, you are on a roll with these cool projects!

3 Likes

This is awesome! Thank you so much for sharing this to the community @gusgonnet. I just ordered several of those Shelly BLE buttons to start playing with. You sharing this here will sure help accelerate the development.

The concept is to build upon the water meter tracking I'm doing for maple sap I started outlining here:

The scenario is a maple syrup producer will buy sap from neighboring farm, some use a water meter, others don't. For those that use a water meter, they physically write down the value on the water meter and use napkin math try to account for where all the sap came from for that day, week, season, etc. (Neighbor A, Neighbor B, Neighbor C). Etc.

Basically when someone gets done unloading their haul of sap (i.e. water), we need to create a "production event" or basically a single record in the database/table of the date/time, total gallons, and who/where it came from. My initial thought was just detect when the flow stopped for a period of time and publish the volume of water pumped that cycle, but pumps can turn off mid unload, someone might have 2 tanks to unload, etc. That logic would likely be tough to be good enough for all scenarios where we only get 1 production event. In that scenario, the person would also have to go into the app and mark who it came from.

The concept I'm going to try and test out is use a different BLE beacon for each neighbor. I.e. Neighbor A is the Blue BLE beacon, Neighbor B is the Red Beacon, Neighbor C is the white beacon and so forth. Then once anyone is done unloading their sap, they simply push their button. When the event is observed by Particle device, it then triggers the Particle.Publish of how many gallons was pumped since the last event. The intent is to make the paperwork side of it much easier/automated, you get date, time, quantity and location.

What I love about the BLE beacon is it's quick/easy and I can add as many as I want. I'd just use the Address as the GUID number.

Any chance you've played with this:
https://www.shelly.com/en-us/products/shop/shelly-h-and-t-gen3-1

In a difference scenario, I'd like to monitor temperature and humidity within BLE range of this same device. Basically it's a Frost protection device, don't let me pumps freeze. I assume with a little effort this could talk as well via BLE, decode the packet and have an ability to add on several wireless Temperature and Humidity BLE sensors. I was originally thinking of using a beacon but having the display is nice as well for when you are in person + BLE.

1 Like

Good idea!

I haven't, but modifying the BLE SCANNER library should be easy. the BT HOME standard is quite straightforward.

When you have them at hand, let me know, we can join forces to make them work.

They have this outdoor sensor as well that I like:
https://www.shelly.com/en/products/shop/shelly-blu-h-and-t

Doesn't have display but looks good for some scenarios.

Cheers,

That would be interesting to implement. I could eliminate all my DS18 outdoor sensors, which don't work with a P2. No more wiring.
The battery might be a pain, but maybe someday Shelly will add a small solar cell!

hey, they mention this on their site:

Long Battery life - up to 3 years

So who knows? Maybe not a big pain if it really is 3 years.

They also mention is compatible with Gen 3 devices:

/joke :clown_face: