Can you share the logs from when you install the config?
Here is the log.
INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/esp32-a.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-a (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
RAM: [= ] 12.4% (used 40648 bytes from 327680 bytes)
Flash: [===== ] 49.6% (used 910425 bytes from 1835008 bytes)
========================= [SUCCESS] Took 18.21 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.157
INFO Uploading /data/build/esp32-a/.pioenvs/esp32-a/firmware.bin (916192 bytes)
Uploading: [============================================================] 100% Done...
INFO Upload took 12.86 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.157 using esphome API
INFO Successfully connected to esp32-a @ 192.168.1.157 in 36.307s
INFO Successful handshake with esp32-a @ 192.168.1.157 in 1.508s
[18:25:14][I][app:102]: ESPHome version 2023.12.9 compiled on Feb 12 2024, 18:02:00
[18:25:15][C][wifi:573]: WiFi:
[18:25:15][C][wifi:405]: Local MAC: E8:6B:EA:F6:FE:E4
[18:25:15][C][wifi:410]: SSID: 'TechnoAlpin'[redacted]
[18:25:15][C][wifi:411]: IP Address: 192.168.1.157
[18:25:15][C][wifi:413]: BSSID: D8:EC:5E:46:A3:2B[redacted]
[18:25:15][C][wifi:414]: Hostname: 'esp32-a'
[18:25:15][C][wifi:416]: Signal strength: -53 dB ▂▄▆█
[18:25:15][C][wifi:420]: Channel: 7
[18:25:15][C][wifi:421]: Subnet: 255.255.255.0
[18:25:15][C][wifi:422]: Gateway: 192.168.1.1
[18:25:15][C][wifi:423]: DNS1: 192.168.1.1
[18:25:15][C][wifi:424]: DNS2: 0.0.0.0
[18:25:15][C][logger:439]: Logger:
[18:25:15][C][logger:440]: Level: DEBUG
[18:25:15][C][logger:441]: Log Baud Rate: 115200
[18:25:15][C][logger:443]: Hardware UART: UART0
[18:25:15][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a_input1'
[18:25:16][D][api:102]: Accepted 192.168.1.13
[18:25:16][D][api.connection:1121]: Home Assistant 2024.2.1 (192.168.1.13): Connected successfully
And here is the full YAML minus the OTA pw and API key.
esphome:
name: esp32-a
friendly_name: ESP32-A
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "yada"
ota:
password: "yadayada"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: GPIO32
inverted: false
mode:
input: true
pullup: true
name: "a_input1"
filters:
- delayed_on: 10ms
Try this:
binary_sensor:
- platform: gpio
pin:
number: GPIO32
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
Another test to try:
Get a short piece of wire and carefully short the solder pads for P32 to GND directly on the dev board. Not on the screw terminal carrier board it is plugged into.
Does that cause the log to show the binary sensor turned off?
One more thing I just remembered. There is a dev boards that can not be powered properly via USB. You have to supply power via the 5V pin. Unfortunately I can’t find the forum post about this to compare it with yours. But it looks familiar…
It does look like your board.
Tom, I really appreciate your sticking to this and all of your suggestions. All of the moderators and contributors here are what really makes Home Assistant successful. I can usually answer my own questions by searching. I was about to try another ESP32 board.
I think it is solved. I had taken the wiring apart and rewired everything a couple of times, but each time I think I had the polarity reversed. I finally tried it the other way. The Seco-larm documentation says the power input is non-polarized. But, I’m betting that only applies to AC.
Glad you got it sorted.
It depends on how they are rectifying the AC to DC. If they use a full bridge rectifier then it should not matter. A half bridge rectifier would have issues with reversed polarity DC.
Hi Gaz, I note that the voltage for this sensor is 6-36V DC. how does this work with the ESP32 or do you interface it into home assistant another way. Im looking to set up a sensor that will detect letters being put into a mailbox slot.
Is your esp going to be in mailbox?
i can, but I thought I would leave it under the house out of the weather. Im not sure which is the best way yet?
So how long is the distance from box to house?
The cable run would be about 10 to 12 metres
Quite a lot. What about small wireless door sensor(reed switch) on the slot?
I would if I could find a mail box front with a door that looks ok. I have purchased one but it has a open slot. The plan was to use the photoelectric sensor on the front slot and reed switch on the back door
Ok, back to the original.
You can use any NPN sensor if it’s open collector without any problems. I means that signal is either low or floating. So there is no conflict with voltage.
Another option is to use PNP and simple voltage divider(two resistors) between sensor output and Esp.
Third option is to use some cheap 3.3V sensor module like this:
Just be sure to use some shielded alarm or ethernet cable, 10+ meter cable is a long antenna for interferences.
thanks Karosm. I might need to make it a little water proof in case rain blows in. I could probably 3D print a case and just have the sensors stick through. So basically put the ESP32 and sensor in the mailbox and run 5v accross the 10-12m?. Ill need to check my wifi signal there. It may be sheilded by the metal enclosure of the mailbox case. Or leave the esp32 in the house and just run 5v, ground and signal the 10-12m? I would imagine that would not be much voltage drop over this distance based on the current draw of this sensor?
What about these type? Infrared Diffuse Reflection Type Photoelectric Switch Sensor Switch’s E3Z-D61 E3Z-D62 E3Z-D81 E3Z-D82 DC12-24V with Bracket - AliExpress 13
There are two options, either both in mailbox or just sensor in mailbox.
Putting just sensor there has more advantages, the downside is interferences. But since I expect you don’t need some microsecond speed for your mail detection , you can just filter them out in your code.
You can waterproof them as you want, even dipping in epoxy… Just leave the tips of the leds uncovered.
If you go with ready made sensor switches, choose NPN NO type. If it’s open collector (without internal pullup) you can wire it straight to Esp. If it has internal pullup, you need to add one diode between sensor output and Esp pin. You really don’t know before you receive it(except if you find some good datasheets).
Just make sure it’s adjustable.
There are also sensors that work with 5V and up, might be more convenient for powering it…
https://nl.aliexpress.com/item/1005006558697041.html?spm=a2g0o.detail.pcDetailBottomMoreOtherSeller.6.21dbxRLPxRLP4O&gps-id=pcDetailBottomMoreOtherSeller&scm=1007.40196.368083.0&scm_id=1007.40196.368083.0&scm-url=1007.40196.368083.0&pvid=d0ae22e8-baf8-4a72-87bf-6b3c3e3db5c4&_t=gps-id:pcDetailBottomMoreOtherSeller,scm-url:1007.40196.368083.0,pvid:d0ae22e8-baf8-4a72-87bf-6b3c3e3db5c4,tpp_buckets:668%232846%238111%231996&pdp_npi=4%40dis!EUR!2.02!2.02!!!2.20!2.20!%402103850917247483308696456e0199!12000037665158890!rec!IT!103797544!XZ&utparam-url=scene%3ApcDetailBottomMoreOtherSeller|query_from%3A
Thanks again Karosm. This is great info. Im wondering if the same 5V power supply would work for both ESP32 (leaving ESP 32 in House) and the sensor over this distance for the Aliexpress one listed. I was looking to run shielded 17AWG or 1mm2 cable (probably 6 core to run both the proximity switch and reed switch) Would get a little volt drop but not sure if it would work. perhaps the one above might be better and put it in a box. (it will operate down to 3.3v)
As long as your 5V psu has current rating high enough. Normal 5V2A phone charger is sufficient. Voltage drop depends on current, if you have low power sensor, voltage drop is minimal even if wire resistance is high.
There are so many tiny battery operated BLE and Zigbee reed switch sensors around, that it’s almost shame to use wired one.