Author Topic: Presence / proximity detection, bluetooth?  (Read 4533 times)

0 Members and 1 Guest are viewing this topic.

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: gb
Presence / proximity detection, bluetooth?
« on: October 22, 2019, 10:00:45 am »
I need a way to tell when a person is in a particular room.  I'm happy enough for that to be a probability or "strength" value for each room, for each person.

I can see lots of people using the ESP32 and BLE, but almost everyone of these articles reports issues as BLE is ... awkward and illusive at times.  I get the feeling that BLE is the new kid in town and everyone wants to play with it, but is it really anyway better or appropriate for this use case?

Power savings aside is there anything wrong with simply making a normal, non BLE connection to/from a phone as you might for Bluetooth audio and using the signal strength from the bluetooth radio as the proximity value?

Can anyone suggest other ways to do this?
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 9224
  • Country: nl
  • Current job: ATEX product design
Re: Presence / proximity detection, bluetooth?
« Reply #1 on: October 22, 2019, 12:15:43 pm »
The search term is "BLE Beacon". Or iBeacon (apple stuff).  There are plenty of of Beacons, Gateways and products built on this. A gateway will just report the RSSI values and adresses to a server. The technology works quite OK.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #2 on: October 22, 2019, 01:00:53 pm »
The search term is "BLE Beacon". Or iBeacon (apple stuff).  There are plenty of of Beacons, Gateways and products built on this. A gateway will just report the RSSI values and adresses to a server. The technology works quite OK.

So this would mean running a BLE Beacon app on my phone.  How does that work with regards to aggressive Android power saving?  Do the beacons not randomize their mac addresses and stuff?  I already have issues with my phone and normal bluetooth in that it will connect to the car, but not do anything until I unlock it because Android keeps it asleep while it's locked.

RSSI?  Radio Signal Strength Indication?

The other approach I was going to take was have my phone paired to the ESP32s using normal bluetooth and when in range, it would connect and receive temperature readings, which while fairly pointless, it tells the ESP32 that a phone is connected to it, so it can report the signal strength of that particular phone.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 9224
  • Country: nl
  • Current job: ATEX product design
Re: Presence / proximity detection, bluetooth?
« Reply #3 on: October 22, 2019, 01:25:29 pm »
RSSI?  Radio Signal Strength Indication?
Correct.
So this would mean running a BLE Beacon app on my phone.  How does that work with regards to aggressive Android power saving? 
https://play.google.com/store/apps/details?id=net.alea.beaconsimulator&hl=en
I guess something like this. I haven't tried the app. I dont think it requeries too much power, as these BLE beacons run for a year on a CR2032 battery.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #4 on: October 23, 2019, 06:57:55 am »
Thanks I'll give it a try.  Quick read suggests the MAC is irrelevant and you match on the UUID or URL sent by the beacon.  I like that they have a rolling code beacon which would make it less easy to track by someone else.  I think I'll have a play over the weekend.

It's for adding individual room temperature boost to a heating system I created.  Currently running the tracked rooms at 18C which is fine for a base temperature, but on cold nights it would be nice to either increase the temp in the room I'm using or even decrease the rooms I'm not to save on fuel/CO2.  Just seems a waste running the heating for 5-10 minutes an hour keeping the living room warm when I'm spending the whole night in the lab upstairs which is being heated by my body heat and PC heat output fairly well.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: es
Re: Presence / proximity detection, bluetooth?
« Reply #5 on: October 23, 2019, 08:15:21 am »
It's for adding individual room temperature boost to a heating system I created.  Currently running the tracked rooms at 18C which is fine for a base temperature, but on cold nights it would be nice to either increase the temp in the room I'm using or even decrease the rooms I'm not to save on fuel/CO2.  Just seems a waste running the heating for 5-10 minutes an hour keeping the living room warm when I'm spending the whole night in the lab upstairs which is being heated by my body heat and PC heat output fairly well.

I have pretty much the same problem of choosing what rooms to heat and how much. I gave some thought to something like you are doing but came to the conclusion it was not practical and this for several reasons.

In my house rooms have great thermal mass and inertia.  Rooms take time to heat up and keep the heat long time after the heating is turned off.

I may be working in one room and go to another room but, will I just spend a minute there getting a screwdriver or will I spend the next hour there doing something? Will I return to the room I left soon?

There is no point in turning on the heat in a room as I enter when the heat will only be felt after I have left.

In the end I find the best thing to do is control it manually. Only I know my intentions for the next few hours and then only vaguely. No automated system is going to improve on that.

Generally and mostly I just heat the entire house to the minimum temperature and heat the room where I spend most of my time to a more comfortable temperature.

It's simple and gives me good result.
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #6 on: October 23, 2019, 08:47:42 am »
Generally and mostly I just heat the entire house to the minimum temperature and heat the room where I spend most of my time to a more comfortable temperature.

It's simple and gives me good result.

Manual is plan B.  Basically a "Profile switcher" with profiles like "Favour living room", "Favour office" etc.

Some of my rooms hold their heat, some do not.  The living room doesn't really hold it's heat, but it does have an electric wall fire.  So I have been setting a temperature lower than is really comfortable, "18C" and either climbing under the "throw" on the sofa or putting the electric fire on for 10 minutes to lift it to 20.  The other room I spend a lot of time in is the lab/office, but it does a better job of staying warm as it's a smaller upstairs room and with my body heat and the PC/monitors, even though the heating lifts it to 18C on schedule it actually rises to 20C or higher when in use, as long as the door is closed.

My heating scheduler has a stack of hysteresis as heating demands last a minimum of 5 minutes and are refreshed only every 30 seconds.  I intend to add similar hysteresis to the location awareness, maybe 1 minute or more of samples before publishing presence.   So if I pop downstairs to the fridge to grab a beer it is unlikely to trigger a heating demand for the living room as I pass and if it does it won't be a big deal as it might cycle the heating on only for 5 minutes.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline nali

  • Frequent Contributor
  • **
  • Posts: 830
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #7 on: October 23, 2019, 10:38:02 am »
I can't quite tell, but does your phone have control over the whole house?

The easiest way for BLE is beacons, either Eddystone or iBeacon although indoors you'll need to watch out for multipath reception and things like transmission through ceilings/floorboards. Each beacon is
pre-programmed with a UID or URL which will let the phone know which area it's in.

Or, if you have some kind of smart device in each room, consider simply adding a PIR sensor to it? You can get off the shelf PIR thermostats, but they're pretty expensive.

A lot depends on the architecture of your system I guess.


 
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #8 on: October 23, 2019, 11:34:20 am »
Or, if you have some kind of smart device in each room, consider simply adding a PIR sensor to it? You can get off the shelf PIR thermostats, but they're pretty expensive.

Yes.  So I currently have a bunch of ESP8266's hanging down the back of sofas or cupboards as temperature probes.  One idea is to upgrade those to ESP32s (or ideally a WeMos Mini variant with an ESP32 for size).

Then in addition to emitting the current temperature every 5 seconds they can emit the BLE signal strength of any beacon it receives.  Those signal strengths will be pre-analysed to convert them to a percentage based "probability" of presence in a room.

The probability values can be used by the schedule to help it choose the target temps for each room.  All rooms that have a target temp will have a beacon receiver and a temperature sensor.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline nali

  • Frequent Contributor
  • **
  • Posts: 830
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #9 on: October 23, 2019, 01:15:11 pm »
OK so you do want your phone(s) to act in Peripheral mode then. Not all phones support it but you can get apps to check that on Play store.

I have a similar requirement to you, but after playing around with trying to get the phones to advertise decided to make the BLE devices connectable beacons & let the phone do the scanning... this was a 2-3 years ago mind you just after Android introduced support for Peripheral mode and not many phones supported it at that time.

If you're using Android it's not too bad running background tasks, but iPhone REALLY makes it hard to do background operations (apart from of course Apple's own processes like iBeacon background scanning..)

 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #10 on: October 23, 2019, 05:58:07 pm »
OK so you do want your phone(s) to act in Peripheral mode then. Not all phones support it but you can get apps to check that on Play store.

I have a similar requirement to you, but after playing around with trying to get the phones to advertise decided to make the BLE devices connectable beacons & let the phone do the scanning... this was a 2-3 years ago mind you just after Android introduced support for Peripheral mode and not many phones supported it at that time.

If you're using Android it's not too bad running background tasks, but iPhone REALLY makes it hard to do background operations (apart from of course Apple's own processes like iBeacon background scanning..)

Yes this was my original concern about android.  The latest Android has extremely aggressive power saving.  When the phone locks, the screen is off, it simply shuts down some system services, but it doesn't tell applications this.  So your BLE beacon app might be pinging away but Android has switched off the bluetooth transmitter so nobody hears it.

I found this with trying to use the phone to publish it's own presence while I was home.  It worked on the bench until I set the phone down and a few minutes after it locked it stopped sending data.  In fact it appeared not to have a functioning IP address either.  The only solution, as it still responds to Wifi beacons is to ask the router if the phone is listed in it's ARP table... which turns out is 95% reliable.

The other option I'm less keen on and that's putting a tracker bracelet on myself or one of those little coin cell bluetooth beacons.  If I'm not going to leave it sitting somewhere all the time it would need to be some form of jewellery and thats just tacky.

Still I'm not giving up just yet.  Maybe Android hasn't yet crippled background BLE beacons.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline nali

  • Frequent Contributor
  • **
  • Posts: 830
  • Country: gb
Re: Presence / proximity detection, bluetooth?
« Reply #11 on: October 23, 2019, 07:22:45 pm »
Seems to work on my Android Pie phone... I tried "Beacon Simulator" to set up and run an Eddystone beacon and set the screen to sleep in 15 seconds. It was still broadcasting after 5 mins, so you may be OK.

That's not to say Google won't move the goalposts in the future though!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf