Coder Social home page Coder Social logo

amg8833-esphome's Introduction

ESPHome AMG8833

Source code for creating firmware for an ESP8266 chip (d1 mini in my case) to use an AMG8833 sensor with Thermal Vision via. ESPHome.

Prefer to use PlatformIO? See TheRealWaldo/esp8266-amg8833.

Parts

AMG8833 - I used one on a breakout board for quick prototyping from AliExpress.

D1 Mini - There is quite a few variants of this, but I had some laying around from Banggood.

Wiring

Schematic

Building

This project uses ESPHome. You'll need to provide your own secrets.yaml in the root directory, providing ssid, password, and domain if you wish to use the amg8833.yaml example configuration.

pip3 install esphome
esphome amg8833.yaml run

Configuring

The Thermal Vision camera can be configured by providing the AMG8833CameraComponent's resulting sensor in HASS to the configuration option pixel_sensor instead of host.

Example:

  - platform: thermal_vision
    name: Prototype Thermal Camera
    overlay: true
    pixel_sensor: sensor.sensor_pixels
    auto_range: true

It's important to note that only the Camera sensor will work in this manner. The other sensors are provided natively via. ESPHome and amg8833.h.

Also important to note; the pixel sensor is very, very noisy! You will probably want to exclude it from your HA history.

Example:

history:
  exclude:
    entities:
      - sensor.sensor_pixels

amg8833-esphome's People

Contributors

rapsssito avatar therealwaldo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

amg8833-esphome's Issues

Warning in the HA log

I'm testing the component and everything is working fine so far.
After restarting HA, I have a warning in the log. Is it possible to remove it somehow?

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:549
First occurred: 17:17:06 (1 occurrences)
Last logged: 17:17:06

Entity camera.prototype_thermal_camera (<class 'custom_components.thermal_vision.camera.ThermalVisionCamera'>) implements device_state_attributes. Please report it to the custom component author.

Syntax error in amg8833_person_detected.h

I'm using the latest code here and an up to date ESPHome. If I include the header for person detection, it throws a syntax error.
Perhaps a newer version of the Sparkfun Library has changed the function definition? If I comment that include out, the rest of the example works fine as long as I don't include the PD sensor.

Thermal Camera Controls
Thermal Camera Display

INFO ESPHome 2023.5.5
INFO Reading configuration /config/esphome/esp8266-thermal-camera.yaml...
INFO Detected timezone 'America/Los_Angeles'
INFO Generating C++ source...
INFO Compiling app...
Processing esp8266-thermal-camera (board: esp01_1m; framework: arduino; platform: platformio/[email protected])

HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 1.2.3
|-- Wire @ 1.0
|-- SparkFun GridEYE AMG88 Library @ 1.0.2
|-- ESPAsyncWebServer-esphome @ 2.1.0
| |-- ESPAsyncTCP-esphome @ 1.2.3
| |-- Hash @ 1.0
| |-- ESP8266WiFi @ 1.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- AsyncMqttClient-esphome @ 0.8.6
| |-- ESPAsyncTCP-esphome @ 1.2.3
|-- ArduinoJson @ 6.18.5
Compiling /data/esp8266-thermal-camera/.pioenvs/esp8266-thermal-camera/src/main.cpp.o
In file included from src/main.cpp:68:
src/amg8833_person_detected.h:5:1: error: expected class-name before '{' token
5 | {
| ^
src/amg8833_person_detected.h: In member function 'virtual void AMG8833PersonDetectedComponent::update()':
src/amg8833_person_detected.h:46:17: error: 'publish_state' was not declared in this scope; did you mean 'last_state'?
46 | publish_state(true);
| ^~~~~~~~~~~~~
| last_state
src/amg8833_person_detected.h:58:21: error: 'publish_state' was not declared in this scope; did you mean 'last_state'?
58 | publish_state(false);
| ^~~~~~~~~~~~~
| last_state
*** [/data/esp8266-thermal-camera/.pioenvs/esp8266-thermal-camera/src/main.cpp.o] Error 1
========================= [FAILED] Took 12.92 seconds =========================

Use with ESP32

Hi, I am preparing to go with an ESP32... I have esphome setup with the custom .h files and no errors in the yaml. I screenshot so you can see it is all ok.

image

  • After flashing I see no device coming online in my wifi... Also no logging on serial of the ESP. -
    Never mind: I accidentally screwed another esp.... wrong COM port...

But:
Where are the pins declared?

D1 and D2 are GPIO4 and 5 (or viceversa). Converting to my ESP GPIO4 and 5 are IO4 and IO5.

I now get:
image

How to add a delay to Person Detected

Every 6 seconds my sensor flaps between detecting a person, to not detecting a person for under a second, and then back to the person detected for 6 more seconds.

What is the best way to handle that? I was thinking a simple 1-second delay before switching states would work, but I am not really sure where to define that.

esphome:
  name: upstairs-grid-eye
  includes:
  - amg8833.h
  - amg8833_camera.h
  - amg8833_person_detected.h
  libraries:
    - "Wire"
    - "SparkFun GridEYE AMG88 Library"

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "blah"

ota:
  password: "blah"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Upstairs-Grid-Eye"
    password: "blah"

captive_portal:

i2c:
  sda:  26
  scl:  32
  scan: True
  frequency: 400kHz


text_sensor:
  - platform: custom
    lambda: |-
      auto amg8833 = new AMG8833CameraComponent();
      App.register_component(amg8833);
      return {amg8833};
    text_sensors:
      - name: "Sensor Pixels"

binary_sensor:
  - platform: custom
    lambda: |-
      auto amg8833 = new AMG8833PersonDetectedComponent();
      App.register_component(amg8833);
      return {amg8833};
    binary_sensors:
      name: "Person Detected"
      device_class: occupancy

sensor:
  - platform: custom
    lambda: |-
      auto amg8833 = new AMG8833Component();
      App.register_component(amg8833);
      return {amg8833->sensor_temperature, amg8833->max_temperature, amg8833->min_temperature, amg8833->avg_temperature, amg8833->min_index, amg8833->max_index};
    sensors:
      - name: "Thermal Sensor Temperature"
        unit_of_measurement: °C
        device_class: temperature
        accuracy_decimals: 2

      - name: "Thermal Sensor Max"
        unit_of_measurement: °C
        device_class: temperature
        accuracy_decimals: 2

      - name: "Thermal Sensor Min"
        unit_of_measurement: °C
        device_class: temperature
        accuracy_decimals: 2

      - name: "Thermal Sensor Avg"
        unit_of_measurement: °C
        device_class: temperature
        accuracy_decimals: 2

      - name: "Thermal Sensor Min Index"
        accuracy_decimals: 0

      - name: "Thermal Sensor Max Index"
        accuracy_decimals: 0

License/Upstream to ESPHome

Hello!
Have you considered, or, are interested in, turning this into a component and submitting it to ESPHome?

If not, I have some experience writing them and would like to do so; but I'm cautious about doing so with code that has no license statement. Would you mind setting your license so I know what is OK to do with your code?

Thanks much!

False positive Person detected

Hi,

thanks for that great project!

I just can't figure out how to fix those false positive person detected.
It detects a person if I aim the sensor to

  • my log burner
  • my dog
  • my underfloor heating

what am I doing wrong?
below my yaml config.
many thanks

esp-frtdoorthermsens.yaml.txt

Looking for Wire.h

During compiling the yaml for ESPHome get below error:

`Compiling /data/esphome-test/.pioenvs/esphome-test/lib259/SparkFun GridEYE AMG88 Library/SparkFun_GridEYE_Arduino_Library.cpp.o
In file included from /data/esphome-test/.piolibdeps/esphome-test/SparkFun GridEYE AMG88 Library/src/SparkFun_GridEYE_Arduino_Library.cpp:30:0:
/data/esphome-test/.piolibdeps/esphome-test/SparkFun GridEYE AMG88 Library/src/SparkFun_GridEYE_Arduino_Library.h:38:18: fatal error: Wire.h: No such file or directory



#include <Wire.h>
^
compilation terminated.
`
Any recommendation how to proceed?

This is my yaml configuration:

`esphome:
name: esphome-test
platform: ESP8266
board: esp01_1m
includes:
- amg8833.h
- amg8833_camera.h
- amg8833_person_detected.h
libraries:
- "SparkFun GridEYE AMG88 Library"

wifi:
ssid: "XXXXXX"
password: "XXXXXX"
fast_connect: true

manual_ip:
static_ip: 192.168.100.17
gateway: 192.168.100.1
subnet: 255.255.255.0

Enable logging

logger:

Enable Home Assistant API

api:

ota:

time:

  • platform: homeassistant
    id: homeassistant_time

text_sensor:

  • platform: template
    name: Uptime human readable
    id: uptime_human
    icon: mdi:clock-start

  • platform: version
    name: esphome-test ESPHome Version

  • platform: custom
    lambda: |-
    auto amg8833 = new AMG8833CameraComponent();
    App.register_component(amg8833);
    return {amg8833};

    text_sensors:

    • name: "Sensor Pixels"

substitutions:
devicename: esphome-test
friendly_name: "ESPHome test"

binary_sensor:

  • platform: custom
    lambda: |-
    auto amg8833 = new AMG8833PersonDetectedComponent();
    App.register_component(amg8833);
    return {amg8833};
    binary_sensors:
    name: "Person Detected"
    device_class: occupancy

sensor:

Uptime sensor.

  • platform: uptime
    id: uptime_sensor
    update_interval: 60s
    on_raw_value:
    then:
    - text_sensor.template.publish:
    id: uptime_human
    state: !lambda |-
    int seconds = round(id(uptime_sensor).raw_state);
    int days = seconds / (24 * 3600);
    seconds = seconds % (24 * 3600);
    int hours = seconds / 3600;
    seconds = seconds % 3600;
    int minutes = seconds / 60;
    seconds = seconds % 60;
    return (
    (days ? String(days) + "d " : "") +
    (hours ? String(hours) + "h " : "") +
    (minutes ? String(minutes) + "m " : "") +
    (String(seconds) + "s")
    ).c_str();

WiFi Signal sensor.

  • platform: wifi_signal
    name: esphome-test WiFi Signal
    update_interval: 60s

  • platform: custom
    lambda: |-
    auto amg8833 = new AMG8833Component();
    App.register_component(amg8833);
    return {amg8833->sensor_temperature, amg8833->max_temperature, amg8833->min_temperature, amg8833->avg_temperature, amg8833->min_index, amg8833->max_index};

    sensors:

    • name: "Thermal Sensor Temperature"
      unit_of_measurement: °C
      device_class: temperature
      accuracy_decimals: 2

    • name: "Thermal Sensor Max"
      unit_of_measurement: °C
      device_class: temperature
      accuracy_decimals: 2

    • name: "Thermal Sensor Min"
      unit_of_measurement: °C
      device_class: temperature
      accuracy_decimals: 2

    • name: "Thermal Sensor Avg"
      unit_of_measurement: °C
      device_class: temperature
      accuracy_decimals: 2

    • name: "Thermal Sensor Min Index"
      accuracy_decimals: 0

    • name: "Thermal Sensor Max Index"
      accuracy_decimals: 0`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.