Looking for a switch/relay that detects 12v => to a sensor

Ok indeed :wink:

Still not sure yet if I am going to use a PI for the project

Yeah, you can do the same thing with a RPi.

Please don’t suggest the use of 5V. The inputs are only rated to 3.3V and 5V will destroy the device.

The resistor values I suggested are ‘standard’ values and will bring the 12V down to a suitable voltage for the input of either a D1 or a RPi. Both of these devices only use 3.3V inputs

yeah, still think about a d1 vs rpi :slight_smile:
anyway, i hooked op a voltage meter today

seems when doorbell is not pressed, i get value like -2,5 v :slight_smile:
and when doorbell is pressed, i indeed get 12v value for 2 seconds, thats enought to trigger something on rpi/d1 , to send out state to HA

but is that -2,5 v normal? electronical is all new to me :slight_smile:

Hard to know what is going on without seeing the whole setup but I would imagine that if you combine the ground of both the doorbell and the D1 / RPi you should be ok… however it might pay to add in an extra bit of circuitry to block the negative voltage going to the device you choose.

EDIT: the above only needs to be a diode

ok, gonna have a visit to a local elektronical shop next week

thnx so much for all info

hi, i deiced not to go with the PI :slight_smile: , but also not wth a wemos d1 , i dont like soldering
since i am new, i am going to buy a startet pack like below, it has i think everything i need
this has a nodemcu esp2866 , but do i also need to flash it with esphome? do i need an exta tool for that? or why does it need to be flashed with esphome anyway ?

https://www.bol.com/nl/p/iot-starter-kit-nodemcu-esp8266-wifi-breadboard-leds-arduino-compatible/9200000082970388/?suggestionType=typedsearch&bltgh=kf5Ap5SA9ax9JJilBzdI6w.1.2.ProductTitle

Yeah, that will work fine. You want ESPhome because the NodeMCU needs some sort of code on it and ESPhome was made exactly for this, to integrate with HA perfectly. To flash it all you need is a micro USB cable.

Are you running HassIO?

yess, hassio on (hassos) on a esxi server
ok, so i need to hook up with the usb cable to a laptop, and flash
then i probably need to program it , make a py or whatever, to also read gpio 14 (sck) (3,3v)
not sure what sck means, but thats the pin to set to input mode , right?

then send a mqtt message to HA , or do a curl to set the state of a sensor, so i can do at the end an automation

No, you are over complicating it. ESPhome has a native HA API. Look at the docs for ESPhome. There is no MQTT required, no Curl commands required.

I’ll post a config file for you tomorrow. Install the ESPhome add-on for HassIO. From there you can simply plug the USB cable directly into your HA server and do the initial NodeMCU coding from the Add-on. Later, any updates can be done over the air.

ah ok , yeah , but gonna do it initiial config/flash from my laptop then, since i have an esxi server, its difficult to connect it to the HA server, i already have passthrough my USB ports for the conbee stick

but, the nodemcu card will be located somewhere else, at the end, so probably i can access it directly with wifi from HA

Ok, that’s fine. Install the ESPhome add-on and once you have your config sorted for the NodeMCU you can compile and download. Then use a program called ESPhome flasher to send it to the NodeMCU plugged into your laptop.

It’s super easy. I’ll post a config tomorrow

:slight_smile:
Sounds easy :wink:

btw, i am googling alot
your solution is thay you indeed devide voltage with resistors
so with some kinde of yaml code, i need to know if a gpio receives 3,3 v, then switch a sensor…
but maybe i can also work with a relay? so i attach the doorbell , to the relays, relays receives a pulse , and that pulse is connected to a gpio ?
isnt that easier? so the nodecmu acts as a switch instead of cinfigured to read an INPUT voltage?

another relay switch?

@sparkydave

my esp2866 arrived :slight_smile:
can you share that little code , to configure an esp2866 gpio as INPUT to read 3,3v to and to trigger a sensor?
also question, i was looking at resistor, why did you configure as output 3V and not 3,3V ? i changed that second resistor to 3,8 ?

anyway, if i have my breadbord ready, gonna make a picture :slight_smile:

btw, is it also possible to simulate that button press? can i take whatever 3.3v output pin, and connect it to an configured input pin (for 2 sec), to simulate? i see 3 x gpio output pins that are 3.3v , not sure if those need to be enabled first though, does it mather witch gpio pin i choose, i see several gnd 3.3v output pins

thnx

after reading some more, i think i need to configure just this, seems only a0 pin can read a voltage?

probably i need to setup update interval to 1 sec, since i only have like 3,3 v for 2 seconds when doorbell is pressed?
but seems it can only read voltages from 0,0 to 1,0 ? do i need to change the resistors?

sensor:
  - platform: adc
    pin: A0
    name: "doorbell"
    update_interval: 1s

EDIT EDIT , disregard this text above , i think i amtotally wrong, i just need to enable another pin like D2 , D5, D6 (green ones according to this image) to INPUT mode , thats it i think ?

binary_sensor:
  - platform: gpio
    pin:
      number: D2
      mode: INPUT_PULLUP
    name: ...

not sure what mode i need to use, input, input_pullup , input_pulldown

You just need to know if the button was pressed
So a digital yes/no on/off is perfect
People above have given you several methods to achieve this
Why are you now looking at analogue circuitry ?

yeah, i was wrong, i edited my last reply, thats makes sense right?

i just need this config? thats all ? not sure about what input mode i need to choose?
actually i just need to read that 3,3 voltage, thats happening for 2 sec when my doorbell is pressed

binary_sensor:
  - platform: gpio
    pin:
      number: D2
      mode: INPUT_PULLUP
    name: doorbell_pressed

I made it 3v because there is a chance that the 12v from the doorbell will fluctuate a little and you don’t want it going over 3.3 at all as it will damage the ESP. the input will work fine at 3v.

Code coming soon