Mighty Mule Driveway Alarm with ESPhome

I thought I’d share this in case it helps someone.
I’d found a few requests help or projects for Mighty Mule Driveway Alarms but they all seemed to not include all the details for setting them up or remain unanswered in the case of help requests.

I purchased the Mighty Mule Driveway Alarm because kangaroos, koalas and sheep would render a movement detector useless, the 50 metre distance to the driveway, and because in my naïvety I thought it would be easy enough to hack together something to talk to Home Assistant.

After months of pain it seems to be working

The beauty of this setup is it could be used to read any LED’s to convert to sensors to automate anything. If it has been done before I couldn’t find it. If it hasn’t, I have no idea why.

First a caveat, I have sod all knowledge of electronics and even less of YAML. I’m sure there’s better ways of doing this. The electronics, no doubt is all over the shop but it seems to be working well.

Opening the Mighty Mule Driveway Alarm, there are 3 LED’s to read, Power, Alarm and Low Battery.
The alarm LED stays lit on activation and must be turned off manually with the reset button. I discovered shorting the bottom 2 pins of the reset button achieved this.

After blowing up my first D1 mini by wiring sensor and ground in parallel with the LED I searched the web and discovered optoisolators, more searching gave me some wiring examples to sort of understand them.
YAML code was the next big hurdle. it’s really hard to find examples to copy or learn from. I couldn’t find any examples of multiple sensors and they just would not work until one line in a post somewhere mentioned unique id’s. I was then flummoxed by instructions at Home Assistant Binary Sensor — ESPHome. and the error i got [entity_id] is an invalid option for [binary_sensor.gpio]. I then had trouble with pullup. I could not for the life of me find a description of what that meant. :slight_smile:

anyway the shopping list:
D1 mini
3 x MOC3021M optoisolated
3 X 100K resistors
3 X 2N3904NPN transistors
lots of luck
arduino relay

I had to remove the LED’s from the board and insert the optoisolator between the positive pin and the circuit board Heres the basic schematic for each LED and pin on the D1 mini.
(The GND is the ground on the D1 mini)


Here’s the mess I made of the unit showing the power coming back to to the LED’s

and here’s the reverse side with the leads from the power to the leds via the optoisolators and from the reset switch to the relay.
I also ran wires from the 12v in case i ever do use a buck converter for powering the D1

all the bits.
I also added a dht temperature and humidity sensor. because.

and the code:

sensor:
  - platform: dht
    pin: GPIO4
    temperature:
      name: "Shed Temperature"
    humidity:
      name: "Shed Humidity"
    update_interval: 300s
binary_sensor:
  - platform: gpio
    name: “Driveway Sensor Power"
    id: driveway_sensor_power
    device_class: power
    pin: 
      number: GPIO14
      inverted: true
      mode:
        input: true
        pullup: True
    filters:
      - delayed_on: 10ms
  - platform: gpio
    name: “Driveway Sensor Alarm”
    id: driveway_sensor_alarm
    device_class: occupancy
    pin: 
      number: GPIO12
      inverted: true
      mode:
        input: true
        pullup: True
    filters:
      - delayed_on: 10ms
  - platform: gpio
    name: “Driveway Sensor Battery"
    id: driveway_sensor_battery
    device_class: battery
    pin: 
      number: GPIO13
      inverted: true
      mode:
        input: true
        pullup: True
    filters:
      - delayed_on: 10ms
switch:
  - platform: gpio
    name: "Driveway Alarm Reset"
    id: Driveway_Alarm_Reset
    pin: GPIO2
    internal: True
cover:
  - platform: template
    name: "Driveway Alarm Reset Button"
    id: "Driveway_Alarm_Reset_Button"
    stop_action:
      - switch.turn_on: Driveway_Alarm_Reset
      - delay: 0.1s
      - switch.turn_off: Driveway_Alarm_Reset
    close_action:
      - switch.turn_off: Driveway_Alarm_Reset
      - switch.turn_on: Driveway_Alarm_Reset
      - delay: 0.1s
      - switch.turn_off: Driveway_Alarm_Reset

All features of the unit are available in home assistant. I have set up an automation in home assistant that runs the reset 15s after the alarm is triggered. I didn’t know how to do this in the ESPhome.

image

the lovelace card is nothing special but lovelace hates me so I’m doing well to even have it there

  • happy automations
2 Likes

A month later (almost) and a quick update to this.
I somehow thought the GPIO pins would have a resistor or something built in and that shorting to ground would be ok. that is not the case. After a day of running the D1 would become unreliable. Putting a 1K resistor between the GPIO pin and the transistor solved that. The setup has been running reliably ever since

I appreciate the work you have done. I went down this same path about a year or two ago. Your soldering on the LEDs reminded me of good times. I bought a zook something or other that had ports that I could connect the LEDs to, and a relay that I could use to trigger the reset.

Ultimately, I want to use two of the driveway alarms to determine the direction of the vehicle in my driveway. I want to turn on a series of lights leading up the driveway ahead of a car, at night. Lots of deer in Texas ,not many Koalas or Kangaroos.

I was thinking about using something like a wemos d1 to read the voltage to the buzzer. That could then be added to Home Assistant so it would know it activated.

Jon