Closed jcastro closed 3 years ago
Hi @jcastro !
Yes, I am planning on adapting this to esphome, but only for occupancy detection, not the thermal camera bit.
Detection is not as easy as you might think; right now, the difference between the high and the low values, factoring in the room and sensor temperature, seems to be the only logical way to detect a warm body in front of the sensor.
I've been collecting data for a few weeks and still trying to find the most optimal algorithm for this.
The most significant difference with this over a PIR is that these sensors measure surface temperature at multiple points and do not require the subject to be in motion to detect it.
The problem I've encountered so far with these sensors is with the resolution. Each pixel represents the average surface temperature of every object that the pixel encompasses in a line-of-sight fashion. So, for example, if the sensor is in a position that allows a human to be close enough that their exposed flesh fills one pixel, then you'll have very accurate detection. If they are further away and the pixel averages with something in the background, you will have less precise detection.
For more range, you need more resolution. More resolution means a more expensive sensor.
You also have to consider that human surface temperature is not the same as internal, and it varies with conditions, ambient temperature, airflow, humidity, and clothing.
So, in short, it's not going to give you a simple true/false value that a PIR sensor would, there is more work to do, but the benefit is occupancy detection vs. motion detection!
Please share your findings when you get your sensor. I intend to use the data I have collected to still everything down into a reliable occupancy sensor soon!
Thanks so much for the reply!
We have been discussing your work in a Presence detection discord server. Actually what I mean (that I didn't explain well) was if you think it could be possible and/or interesting to use it as a people counter instead. For example https://www.hiome.com/ seems to be using successfully for people counting, which will also end up detecting presence in a room. Even if you have a room with several entrances as long as you have sensors on each door frame you will be able to know.
In the discord server we have already tried with the VL53L1X sensor, which worked perfectly (I tried it myself) for counting people in and out, with a huge caveat... if the ambient light is high (daytime for example) it will generate a lot of false positives and the counter will go nuts. This is what led us into look for something else.
There's already a repo that holds this code which was working perfectly with this said sensor, that maybe you want to look at and see if it's possible to make it work also with the AMG8853 as well
If you want, we are usually here discussing about what we can do to create the best presence detection sensor at this discord server
Thanks!
I really appreciate your work. Somehow I can configure supported components according to the ESPhome documentation. Unfortunately, I would not know how to handle this thermal camera component. I own several of these cameras and I will follow the development and when it is possible according to some procedure I will put them into operation so that I can help as much as possible. I also have two VL53L1X sensors and I'm just waiting for them to be supported in ESPhome to try them out. My priority is the presence or counting of people in the room.
People counters! Didn't think of that. I suppose you could hypothesize the number of people in the room from a combination of sensors.
So that we're on the same page, here are some definitions I've been working on to help people understand the work:
Motion Detection: Movement has been detected in the space PIR Detection: Movement, likely from a human, has been detected in the space Occupancy Detection: A human is or is not occupying the current space; sometimes includes the count Presence Detection: Who is present in a given space (the actual people) e.g., Jonatan and Pepe
Using a TOF sensor (which is great at estimating the distance to an object) sounds like a great way to detect something moving through a door frame (could use two, but one would suffice if angled correctly). It would help estimate the number of individuals in a room, assuming all entrances and exits are covered and the starting occupancy is known (sensor downtime could be a problem).
With thermal imaging, as an example, if the resolution is high enough and the bodies are far enough apart, one can count how many individuals are within its view. I have sample data demonstrating a distinct pattern when my wife and I sit on our couch vs. just myself.
So, you could use it over a door frame like a TOF, PIR, or motion sensor, but the thermal sensor could actually be used to cover an entire room. That being said, placing it in a door frame would help with any range problem, allowing for accurate detection with low resolution. It would still have a margin of error due to the assumptions I mentioned earlier.
I'm trying to cover Human Occupancy primarily with this sensor, but I see now that that can extend to count as well!
Great ideas!
Great definitions, what I'm personally trying to get working at home is effectively an occupancy sensor. Presence detection would be also great in some circumstances but honestly as of right now high accurate occupancy sensor/system will be already great.
As you said, I've seen some people using a few sensors working together to get even higher reliability in the results. For example, some people in the discord server were using the VL53L1X + motion sensor, so if the counter was at 0 but motion is triggered then you could assume there's a mistake in the reading and it will increase the counter to 1
is there a guide to flashing the ESP chip, or can you post the code please? I have managed to flash with, but i am not sure if thats what i need along with the hacs component. I am trying to get occupancy for the rooms. https://gist.github.com/NeoCat/a57f73b8db0605e1763d3ca1a1f75941
@stress1ner I'll do my best to push my occupancy code and notes at some point in the next week.
Updates for all; I've updated the README for this repositories version of the firmware.
Additionally, I started a port to ESPHome and pushed the work so far to https://github.com/TheRealWaldo/AMG8833-ESPHOME, and I've also updated the integration. No guide yet; anyone with experience with ESPHome should have no problem, however.
To use either with the camera in HASS, the https://github.com/TheRealWaldo/thermal HACS Integration is required (now a default repository in HACS, so super simple to install!).
To use just the sensor values, you can use the ESPHome version with the amg8333.h
include. The camera will not work stand-alone but can be used with the integration by setting pixel_sensor
instead of host
on the HASS camera configuration.
Over the next couple of weeks, I hope to have more README's and, of course, a working example of the use of this sensor for occupancy detection.
Hello!
This is so great man, thanks! I’m waiting on my sensor to test this out. I was just wondering a few things if you have a bit of time to reply:
Thanks!