Integrating AMG8833 8X8 pixel Thermal Camera for human detection

Hello!

I´m trying to integrate the AMG8833. Actually I´m able to read the sensor and write it in the log but I´m not able to publish the list of 64 values (8x8 pixels) into esphome. I get an error at compiling time

This is my custom_8833.h:

#include "esphome.h"
#include "SparkFun_GridEYE_Arduino_Library.h"
#include <vector>

class AMG8833 : public PollingComponent, public Sensor {
 public:
  AMG8833() : PollingComponent(2000) {}
  std::vector<float> pixels;
  GridEYE grideye;

  void setup() override {
    ESP_LOGD("custom", "Starting up AMG8833 sensor");
    grideye.begin();
    delay(1000);
  }

  void update() override {
    pixels.clear();
    for(unsigned char i = 0; i < 64; i++){
      pixels.push_back(grideye.getPixelTemperature(i));
      ESP_LOGD("custom", "The value of sensor is: %f", this->grideye.getPixelTemperature(i));     
    }
    publish_state(pixels);    
  }
};

And this in my prueba.yaml

esphome:
  name: prueba
  platform: ESP8266
  board: nodemcuv2
  includes:
    - custom_amg8833.h
  libraries:
    - "SparkFun GridEYE AMG88 Library"

# Enable logging
logger:
  level: DEBUG
  esp8266_store_log_strings_in_flash: False

i2c: 
  sda: D2
  scl: D1
  scan: True
  
sensor:
  - platform: custom
    lambda: |-
      auto amg8833 = new AMG8833();
      App.register_component(amg8833);
      return {amg8833};
    sensors:
      name: "AMG8833"

I got this error

In file included from src/main.cpp:20:0:
src/custom_amg8833.h: In member function 'virtual void AMG8833::update()':
src/custom_amg8833.h:23:25: error: no matching function for call to 'AMG8833::publish_state(std::vector<float>&)'
     publish_state(pixels);    
                         ^
src/custom_amg8833.h:23:25: note: candidate is:
In file included from src/esphome/core/application.h:15:0,
                 from src/esphome/components/api/api_connection.h:4,
                 from src/esphome.h:2,
                 from src/main.cpp:3:
src/esphome/components/sensor/sensor.h:101:8: note: void esphome::sensor::Sensor::publish_state(float)
   void publish_state(float state);
        ^
src/esphome/components/sensor/sensor.h:101:8: note:   no known conversion for argument 1 from 'std::vector<float>' to 'float'
Compiling /data/prueba/.pioenvs/prueba/lib4d9/ESP8266WiFi/ESP8266WiFiGeneric.cpp.o
*** [/data/prueba/.pioenvs/prueba/src/main.cpp.o] Error 1
========================= [FAILED] Took 22.53 seconds =========================

Can I only publish floats? that could be horrible if I have to publish 64 floats

Hi
You succeed connect this sensor to HA?

I’m also curious if you were able to get this working as I think this could be a really interesting way to do presence detection in more challenging rooms

Hola, has conseguido hacerlo funcionar??. Estoy pensando en utilizarlo como detector de presencia, sería interesante poder mandar la imagen también, pero de momento con detectar presencia me serviría.te escribo en español,porque el nombre del archivo te delata .

Gracias!!, un saludo.

Not a direct answer to the question, but you can check out this post. Custom Component: Thermal Vision posted by @eyalco. He made a custom component for HA with the AMG8833 sensor, although with Arduino code.

1 Like

Just as an FYI for anyone looking into this: room-assistant supports these sensors complete with a occupancy count detection and a heatmap camera entity in Home Assistant. It does not work on ESPs though, it needs a Linux board like a Pi Zero W. The code is open source, so feel free to port it to ESPHome!

3 Likes

I’ll use google translate

Hello, did you get it to work ??. I’m thinking of using it as a presence detector, it would be interesting to be able to send the image as well, but for now, detecting presence would help me. I’m writing to you in Spanish, because the name of the file gives you away.

Thanks greetings.

But please speak english on this forum :slight_smile:

Sorry for my late reply, I have had a moving recently, but I will recover this project soon!

Waiting for my sensor as well so as to make a presence detector without bluetooth! Really interested to see how it will work out!

What is your experience? I tested this sensor and it doesn’t want to detect at a distance of 3-5m. I see a change in temperature when approaching less than 1m.

It works only for distances of 30-40cm or less… How is it possible to work for 5-7m as advertized in the datasheet?

1 Like

I have the same problem and I don’t know how to get a distance of at least 3 m.

Mine is working fine in a 3-4 meter range. You need to offset the temperature readings against the actual temperature in the room. Here is a picure where I am waving my arms in front of the sensor at around 2 meters, with nearest neigbour 5 pass algoritm for interpolation.


To improve further, yoy can take a snapshot of the heat readings in an empty room and use as offset.

Thank you very much, I didn’t think of that.
Can you share your settings or at least part of them?
Thank you

I am using my own Arduino sketch, but the code is very similar to the code produced by esphome, so it’s easy to emplement. Esp home is way to slow since I am sending data every 200ms, thus the need for the Arduino sketch. I have implemented a websocket api to send the data to HA as a json list with 64 integer values. I then do the 5 pass nearest neighbour interpolation in javascript in the browser since a calculation like that would kill the esp device. Sounds more complicated than it is, but works like a charm. I am now working on the snapshot calibration to make it even more sensitive. I will post on github and post a link.

Another way is to just keep the espcode and make a minor change to the output sent to HA and then use my javascript code for the nearest neighbour calculation. If I have time, I will look at the esp home code and see what need to be changed.

Thank you very much and I will watch.
I received 3 pieces of these cameras from my son, but so far I put them off because I didn’t know where to start. I will consult with him about the information and hopefully we will put it into operation to our satisfaction.

I just had a quick look at the esp home code and as long as you can get the readings in to a sensor in HA, you will just need to add my interpolation code to a lovelace card and it should work. I am not using the HA lovelace fromtend at all, I have witten my own UI, so I am not to familiar with making a lovelace card, but I will have a look. This will take care of the camera view. For presense detection, a little bit of python script will be needed, but that I got ready.

This esp home code from eyalcha works fine https://github.com/eyalcha/thermal for getting the values into HA.

Thanks, I’ll try. My idea was to use a camera to detect the presence in the room.

Wow! So cool and exactly what I am looking for. Although if it would work on esphome… will it work with that? I read al links and googled but cannot find any confirmation. I would like to use this AMG8833 sensor with esphome as an occupancy sensor published in hass.

Please advise, thank you!

Hi! Is it possible to share the code you use so as to test?

It would be really nice and helpful :slightly_smiling_face: