Using ESP32 GPIO to detect integrated magnetic car signal

I suspect this is an elementary question - but I’m struggling to get an ESP32 GPIO signal from a Cartell branded magnetic sensor.

The sensor works fine - there is a physical speaker hooked up to it that alarms. My challenge is getting a GPIO on an ESP32 to detect the “system integration” connection signal.

From the cartell integration instructions:

I have connected terminal 7 to GPIO16, and terminal 6 to GND on the ESP32.

I am using the following configuration in ESPHome, and it seems to be functional (compiles and uploads fine), and in home assistant I am seeing the sensor… it just never toggles to anything other than “ON”.

binary_sensor:
  - platform: gpio
    name: "Cartell Sensor"
    pin:
      number: GPIO16
      mode: INPUT_PULLDOWN

My guess is I’m making a pretty obvious mistake (I am very far from an electrician) but I would welcome any feedback or troubleshooting trips that you might recommend.

First thing - does a multimeter confirm the cartell works as expected?

Second, if you ground gpio16 does that show in esphome?

Thanks!

I just grounded the GPIO16 pin and esphome / home assistant do not show the sensor as changing state - it’s still “On”.

Silly me I think you want pullup not pulldown.

Thanks - I adjusted / uploaded the new firmware calling out PULLUP for GPIO16 via HA dashboard.

I grounded / ungrounded the IO a few times leaving it for 10 seconds each time - and unfortunately it’s still not toggling at all. That gray period on the timeline was when the ESP32 was rebooting after the new firmware was uploaded.

Look in the esphome logs.

Thanks again for the hand-holding. I can connect to the log via esphome dashboard - but I don’t get any indication in the log that it is detecting any changes, when I ground / unground GPIO16.

It’s possible that I need to enable some higher level of logging (it looks like there is a logging section in the .yaml that is blank) for it to give me more verbose insights.

can you not connect common on the relay to our gpio input then nc to + on on the esp and no to - on the esp.
That way you dont need any pull up/down reisitors

I’m happy to try that! For clarity, you are saying:

  • Connect “C” to GPIO16
  • Connect NO to… ground?
  • Conect NC to VCC? or 3.3v?

And I would adjust my ESP32 to be a simple:

binary_sensor:
  - platform: gpio
    name: "Cartell Sensor"
    pin:
      number: GPIO16

Hi,

Assuming C is common, I would connect that to GND. Then define your gpio with internal pullup and I think inverted true and connect that to NO.

If the sensor triggers it will connect to GND and your gpio pin will be low, if not because of the pullup the pin will not be floating and read high which is why you want inverted option. Advantage is that this way you will not kill your gpio with too high voltage.

You may want to test If the NO connect to C If a car is present but I would think so.

Have fun!

Yes exactly that. You don’t need a pull up or down if your switching your input.

1 Like

You’ll want a resistor on 3.3v, probably 47k. Otherwise you’ll short the 3.3 rail to ground.
Edit:
@versigo is correct, shouldn’t post before coffee. :laughing:

Not if each side of the relay is pos and neg.