Two ESPHome devices from one ESP32?

Hello! I’ve finally learned the beauty of ESPhome because I used Smart Bed Sensor for $5 | Medium to make a sensor to tell when my cats are eating and am using ESPresense, which is also based on ESPHome, they just offer an easy upload that skips using it.


My question… do I have to waste two ESP32s here? Or can Home support two separate images running at the same time? ESPresense doesn’t use any pins…

I don’t think it is GitHub - ESPresense/ESPresense: An ESP32 based node for gathering indoor positioning and transmitting to mqtt

So is this something else?

I wouldn’t waste a single ESP32 on this (overkill). One ESP8266 (Wemos D1 Mini or NodeMCU) is plenty. Flash ESPHome on it and you can have as many devices as you have I/O pins.

I’m confused, it says 8266 doesn’t have the capability for the touch? Nor the bt no?

Post the YAML of your ESP32. I suspect is all you need to do is:

  • find out if you have enough pins left to do a second sensor
  • define another ESP32_touch binary sensor

Espresence is not based on esphome. So you can’t run espresence and esphome at the same time on the same esp32.

You could add some other code to the espresence source code, compile it, and use it to monitor your pressure mats.

And no, the screenshot is not esphome.

1 Like

Thank you. It confused me that they called them the same thing ESPHome and ESPHome Flasher.

This was the info I needed. Thank you again.

If you built it according to the instructions you linked, it’s ESPHome. This is the sample YAML on there:

# ESP32 NodeMCU
esphome:
  name: bed_sensor
  platform: ESP32
  board: nodemcu-32s
# Change this to your Wi-Fi config 
wifi:
  ssid: your_wifi_ssid
  password: your_wifi_password  
  ap:
    ssid: “Bed Sensor Fallback Hotspot”
# Set a password in case Wi-Fi fails
    password: “change_this_please!”
    
# Fallback portal 
captive_portal:
# Logging
logger:
# Uncomment this if you use Home Assistant
#api:
#  password: “change_this_please!”
# Fill your MQTT information
# Delete this if you're using Home Assistant
mqtt:
  broker: 10.0.0.2
  username: livingroom
  password: MyMQTTPassword
# Over-The-Air updates
ota:
  password: “change_this_please!”

Espresense is a separate thing I was confused about ESPHome Flasher and ESPHome. I thought it was, but pretty sure is not.

That wasn’t the question. The question was whether esphome and espresence could be used at the same time on one esp32.

1 Like

Actually, I am not sure this is correct @nickrout . Nabu Casa makes ESPHome. They also make ESPHome-Flasher to make it easier to load things into ESPHome. That means ESPresense runs on ESPHome. Should just be a matter of figuring out how to see the YAML once written or converting the bin file to be read by people that can’t read symbols (that’s what I got when I opened it in notepad)

Actually, I’m 99% sure they are based on ESPHome. Same interface when flashing, and I just used ESPHome to flash the BIN from the prerelease of ESPresense to a 32 Wrover with 0 issue.

Oh, well, that’s unfortunate for my case, but can definitely come in handy for other cases in the future.

1 Like

Nope, they are not based on ESPHome. :slight_smile: You’re confusing and mixing things here:

  • ESPHome = firmware for flashing onto an ESP
  • ESPHome-Flasher = tool to bring firmware (not only ESPHome firmware) onto an ESP
  • ESPPresence = mqtt based presence detection that uses an ESP, not ESPHom
1 Like

Yeah, I guess the part that mainly keeps bringing me back into the stupid confusion is the flasher not only doing ESPHome firmware. Didn’t realize that part until right now. Thanks!

Nonetheless, in your case I wouldn’t use ESPPresence for that specific ESP. You can run the BLE presence detection without ESPPresence as well. In theory, ESPPresence isn’t doing anything fancy, it uses the BLE advertisements and sends them via MQTT to HA.

The same is possible in ESPHome, though I wouldn’t advise to do so. ESPHome has its own HA api, that is faster than MQTT.

I’m running four bed sensors and a few BLE tracker from one ESPHome-flashed-ESP32. No problems at all, and you can easily use the binary_sensors provided by ESPHome to convert them into device_trackers or just use the binary_sensors.

EDIT: I totally forgot, I’m runnning some LED strip from this ESP32 as well. :slight_smile:

1 Like

When you say running the BLE tracker, you mean for room presence, no? because ESPresense returns more than just Home and Away, it tells what room. If so, I need to collaborate with you because this is my end game.
Edit: Also, faster response time sounds heavenly.

What room you’re in is mainly decided with the RSSI value. In theory the first clue is the ESP that sends that value, so if your bedroom ESP sends a signal, chances are already high, that you’re in that room. Taking the RSSI value into account, you can more or less safely say, what room you might be in. The idea behind ESPPresence is, to use this RSSI value, to estimate the distance between the beacon and the ESP.

All of this can be done by hand, though I don’t see the specific need to be that precise (varies on the use case). In theory this is a nice gadget, but I wouldn’t rely on it.

Imagine your ESP is sitting in the bedroom, next to the kitchen wall. If you have a big bedroom, chances are high, that the value received by the ESP, when you’re standing next to the wall in the kitchen, is higher than the one you receive from the “doorstep” to your bedroom…

To circumvent this, you need to get very familiar with your current living situation, and test a lot to get that difference. You need to take into account different sensors from different rooms.

I’m taking a different approach, by just using the BLE presence detection for something “general”, home or not_home. The fine tuning with room occupancy is done by other sensors, eg. a motion sensor in combination with the BLE signal.

This is the part, where ESPPresence does “the magic”:

You can do this in ESPHome by doing your own measurement with the BLE-RSSI component:

EDIT: after re-reading this post: this is not meant against ESPPresence in general, hope that didn’t sound like that! It is just my oppinion, that in this specific case, where you want to use something more on that ESP, it might be better to go a different route. For other rooms, where nothing else is needed from that ESP, it might be a good alternative! Keep in mind though, that an ESP32 can do much more than running “only” a presence detection… :wink: In Germany we use the phrase “to cast pearls before swines” :rofl: :rofl:

So, it took me about a month and a half to set all of my 8 room sensors to accurately (setting the absorption was a pain) know which room I am in. I use it to make lights follow me, to ensure that the tv and the lights stay on when I am in a room and my MAIN and most important use case is to combine with the sensors I just made. I need to know who is in what room at almost all times, 1. I have very sneaky cats. 2. One of them likes to take their collar off, this helps find it, the Tile just isn’t loud enough when it’s under a bed. and then Main: I had a cat pass away recently. We couldn’t figure out which of the 4 wasn’t eating and weren’t able to provide the vet with enough info to save him in time. He passed from cancer at just 3 years old and it really messed me up. So the point in this set up is to ensure that I can capture the moment when Pants, Hathor, or Osiris, or a combination of them is in the laundry room at the same time that the pressure sensor is pressed down. Works FANTASTIC, I can now see that one of my kitties likes to go back and eat for short periods of time all day long and the other two eat like normal. My entire goal is to just make it where I am using one ESP instead of 2, the whole idea triggered because of the loading screen being the same between adopting a chip for ESPHome and ESPHome - Flasher and from there I just confused myself, but if that level of accuracy is possible, sign me up. I was messing with Room Assistant, but Pi has gotten expensive and honestly, I couldn’t get it to think any room was any room other than the bedroom, even inches from the media room Pi.

Honestly if it were possible to just go “Hey, I’ve got this bin on here, I’d like to use the rest of the memory/storage to run ESPHome…” that would be DOPE.

I can see the point, especially when it comes to pets (see my avatar :rofl:).

So how do you differntiate between the cats, if one of them “looses” his beacon? This is, either way, the essential part, without it, it won’t work.

If you’d ask what I’d do, here you go:
I’d setup an ESP32 with ESPHome and try to lower the efficiency of that ESP. Meaning, the ESP is “enclosed” in some kind, and though only reacts on very near presence. In the end, you said, you’d like to know who is grabbing all the food. Additionally you could setup the RSSI signal in ESPHome, and only react on values higher/lower than XY. This would bring you some sensors, that combined into an automation should get very, very close.

esphome:
  name: bedroom_bed_occupancy
  platform: ESP32
  board: nodemcu-32s

[...]

# The actual thingy
esp32_touch:
  # Comment after setup is done
  #setup_mode: true  

esp32_ble_tracker:
  scan_parameters:
    duration: 2min

binary_sensor:
  - platform: esp32_touch
    id: pat_top
    pin: GPIO13
    threshold: 7
    internal: true
    filters:
      - delayed_on_off: 1.5s
  - platform: esp32_touch
    id: pat_bottom
    pin: GPIO12
    threshold: 7
    internal: true
    filters:
      - delayed_on_off: 1.5s
    
  - platform: template
    name: "Bedroom Bed Pat Occupancy"
    lambda: |-
      if (id(pat_top).state && id(pat_bottom).state) {
        return true;
      } else {
        return false;
      }
      
  - platform: ble_presence
    mac_address: !secret mac_mi_band_pat
    name: "mi_band_pat_bedroom"
    device_class: presence
  - platform: ble_presence
    mac_address: !secret mac_g_tag_pat
    name: "g_tag_pat_bedroom"
    device_class: presence

sensor:
  # RSSI based on MAC address, taken from the ESPHome page
  - platform: ble_rssi
    mac_address: AC:37:43:77:5F:4C
    name: "BLE Google Home Mini RSSI value"    

This is a mix from one of my configurations in ESPHome and the example page, so not tested. With this, you would get a sensor with the RSSI value, and some pressure readings. Combine these into an automation and you should be good to go.

Something like if RSSI value above XY AND pressure mat is 'on', you get the idea. :slight_smile:

BUT… I’d use some weighing sensors for this, so you could follow the weight of the food. Telling you, that a cat was there sounds like not being enough for some cases, as you said. Measuring how much food was actually eaten sounds better to me.

Something like these:

Just to note, I’m tracking my dogs food via Groocy, so you clearly are not alone with this thinking. :rofl: :rofl:

And my condolences. I lost my dog (the one on the avatar) a year ago… :face_with_symbols_over_mouth: :face_with_symbols_over_mouth: :face_with_symbols_over_mouth: But I couldn’t stay long without a dog, so now we already have a one year old. :smiley: :smiley: :smiley: