Git Product home page Git Product logo

esphome-mmwave-sensors's Introduction

ESPHome integration for mmWave sensors

Collection of header files and esphome yaml configs to integrate some Seeed Studio mmWave sensors into Home Assistant.

Currently the following sensors are partially implemented

  • Seeed Studio
    • MR24HPB1 - 24 GHz Human Stationary Sensor
    • MR24HPC1 - 24 GHz Human Static Presence Lite
    • MR60BHA1 - 60 GHz Respiratory Heartbeat Sensor

Table of Contents

Roadmap

  • Implement missing SeeedStudio Sensors (MR24BSD1 & MR60FDA1)
  • Make documentation cleaner and enhance with screenshots and plots
  • Implement sensors as proper external components
    • Are there proper docs on how the config validation/generation part of esphome works?

Installation

Files

If you don't bother or use all the supported sensors just copy the header and packages directories into your Home Assistant config/esphome directory.

Otherwise these are the files needed for each sensor:

  • MR24HPB1
    • Headers
      • headers/mr24hpb1.h
      • headers/mr24hpb1_frame.h
    • Config
      • packages/mr24d.yaml
  • MR24HPC1
    • Headers
      • headers/mr24hpc1.h
      • headers/mrx_frame.h
    • Config
      • packages/mr24hpc1.yaml
  • MR60BHA1
    • Headers
      • headers/mr60bha1.h
      • headers/mrx_frame.h
    • Config
      • packages/mr60bha1.yaml

You can change the name of the headers directory in home assistant if it doesn't apply to your naming scheme. You can adjust the file locations via substitutions.

substitutions:
  header_frame: headers/mrx_frame.h
  header_sensor: headers/mr24hpc1.h

Hardware

MCU

The template assumes the use of a ESP32. I specifically used the AZDelivery ESP32 Devkit C, but any other ESP32 and ESP8266 should work I guess. But I have not tested this.

Wiring

The template assumes the following wiring:

MCU mmWave Sensor
5V 5V
GND GND
GPIO16 (UART RX) TX
GPIO17 (UART TX) RX

The uart pins can be changed in the ESPHome yaml via substitutions

substitutions:
  uart_rx_pin: "16"
  uart_tx_pin: "17"

ESPHome Device

Take a look at the yaml files in the examples directory, these should give you a basic understanding of what to do when you create a new device in ESPHome.

Basically the section substitutions and packages are relevant. When you create a new device the other user relevant section will be generated by ESPHome, the before mentions sections need to be added from the provided example yaml files.

Supported Functions

The MR24HPC1 and MR60BHA1 sensor also support multiple inputs to reset, change operation modes and query specific sensor states.

MR24HPB1 MR24HPC1 MR60BHA1 Info
presence x x x binary (detected/clear)
motion x x x binary (detected/clear)
body movement x x x measurement (0: unoccupied, 1: static presence, 2-100: activity level)
proximity x x measurement (<0: approaching, 0 none or stationary, >0 moving away)
distance x measurement (distance to object in cm)
x, y, z angle x measurements (relative position of object to sensor)
heartrate x measurement
breathing rate x measurement
breathing info x measurement (1: normal, 2: fast, 3: slow, 4: none)
radar out of bounds x measurement (0: out of range, 1: within range)

MR24HPC1

Sensor

MR24HPC1 Sensor

Device Website

MR24HPC1 Sensor

Home Assistant

MR24HPC1 Sensor

MR60HBA1

Sensor

MR60HBA1 Sensor

Device Website

MR60HBA1 Sensor

Home Assistant

MR60HBA1 Sensor

Contributing

Since C++ is not my strongest of languages and this is my first implementation which is interacting with ESPHome, Home Assistant and the uart protocol in general, there are probably a lot of things that can be done easier or cleaner.

Please feel free to dive in! Open an issue or submit PRs.

License

MIT © thefipster

esphome-mmwave-sensors's People

Contributors

the-ress avatar thefipster 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

esphome-mmwave-sensors's Issues

Feedback

Hey Fipster!
I really like the work you did here! Well done, thank you very much!

Unfortunately it seems on an esp32-s2 it crashes after a few hours, but I was not able to aquire any logs to find out what the the reason could be. (Edit: it was an issue with the oscillator on my S2 mini, not related to your component)

I have also found that after restarting the esp with the mmwave sensor (MR24HPC1) on it would not be able to communicate anymore. Wild guessing it might be the uart becoming out of sync.

One more thing regarding configuration, the UART pins are fixed in the package. I'd actually configure the uart outside of the package.

You may wanna have a look at this pr in esphome: esphome/esphome#4434
This is a very nicely made component for the LD2410 mmwave sensor. I guess there will be a lot of similarities with the ones you integrated, maybe it will help you improve your implementation.

Unfortunately I am full with projects at the moment, in case that changes I might just go ahead and try myself. Sounds like a fun venture.

Thanks for your work!

Constant false positive

Lite module:
i am getting body movement readings even when nobody is present (presence alwayson)
i am using an esp8266 and for rx and tx i am using the hardware rx tx of the 8266 with log baud to 0
any ideas?

what might be intereseting is the following: when moving around the sensor the value of body movement drops between 0 and 12 and when no movement it jumps up to 100 than back down to 50

Issue saving mr24hpc1 yaml package

I get the following error when trying to save mr24hpc1 package. Unresolved tag: !lambdaYAML It appears 7 times. All at the the lines with state: !lambda return x > 0;.
Screenshot 2023-07-09 at 11 47 36 PM

mr24hpb1.yaml won't compile for ESP8266

While trying to build mr24hpb1.yaml example for ESP8266 I'm getting:

Compiling /data/mmwave/.pioenvs/mmwave/lib67b/ESP8266WiFi/ESP8266WiFiSTA-WPS.cpp.o
In file included from src/esphome/core/log.h:8,
                 from src/esphome/components/api/proto.h:4,
                 from src/esphome/components/api/api_pb2.h:5,
                 from src/esphome/components/api/api_connection.h:4,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/mr24hpb1.h: In member function 'void MR24HPB1::process()':
src/mr24hpb1.h:57:40: error: initializer fails to determine size of '__pstr__'
   57 |             ESP_LOGD("mr24d", msg.c_str());
/data/cache/platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:39:76: note: in definition of macro 'FPSTR'
   39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
      |                                                                            ^~~~~~~~~~~~
src/esphome/core/log.h:67:36: note: in expansion of macro 'F'
   67 | #define ESPHOME_LOG_FORMAT(format) F(format)
      |                                    ^
src/esphome/core/log.h:92:59: note: in expansion of macro 'ESPHOME_LOG_FORMAT'
   92 |   esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
      |                                                           ^~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:149:28: note: in expansion of macro 'esph_log_d'
  149 | #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__)
      |                            ^~~~~~~~~~
src/mr24hpb1.h:57:13: note: in expansion of macro 'ESP_LOGD'
   57 |             ESP_LOGD("mr24d", msg.c_str());
      |             ^~~~~~~~
src/mr24hpb1.h:57:40: error: array must be initialized with a brace-enclosed initializer
   57 |             ESP_LOGD("mr24d", msg.c_str());
/data/cache/platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:39:76: note: in definition of macro 'FPSTR'
   39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
      |                                                                            ^~~~~~~~~~~~
src/esphome/core/log.h:67:36: note: in expansion of macro 'F'
   67 | #define ESPHOME_LOG_FORMAT(format) F(format)
      |                                    ^
src/esphome/core/log.h:92:59: note: in expansion of macro 'ESPHOME_LOG_FORMAT'
   92 |   esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
      |                                                           ^~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:149:28: note: in expansion of macro 'esph_log_d'
  149 | #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__)
      |                            ^~~~~~~~~~
src/mr24hpb1.h:57:13: note: in expansion of macro 'ESP_LOGD'
   57 |             ESP_LOGD("mr24d", msg.c_str());
      |             ^~~~~~~~

It builds fine for ESP32

fixed by changing line 57 of mr24hpb1.h from:
ESP_LOGD("mr24d", msg.c_str());
to:
ESP_LOGD("mr24d", "%s", msg.c_str());

My C++ is rusty as hell, and I've read zero docs so I have no idea if it's correct but it works. I also had to disable logging over UART and use the hardware UART on the ESP8266 to successfully communicate with the sensor but other than that it works perfectly.

Access Device Website

Hi,
I am testing the MR24HPC1 sensor with success in all its functions except access to the web device,
Some advice ?
Thanks in advance
Vicente Marianito

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.