Final working breadboard setup with ESP32 connected to buzzer

You'll see this again.

In this post, I'll talk about how and why I automated my NYC Apartment Buzzer using ESP32s, Hubitat, ChatGPT, and The Indomitable Human Spirit / guessing.

Table of Contents

The Problems

I had three problems that all stemmed from the same issue. In this post, I will talk about the challenges I faced, the solution I came up with, the building out of the solution, and the learnings I took away.

Problem 1: The Party Problem

I have always had a natural inclination to hosting. I live in a nice one bedroom in Bushwick, and I have befriended my neighbors, and every other week or so I have them over for movie nights. Nothing too grand -- perhaps 8 or so people maximum. That being said, a few times a year I like to really stress test my relationship with my upstairs / downstairs neighbors by throwing a big party and inviting pretty much anyone who I've made eye contact with in the past few months. The problem is, someone always has to be by the buzzer at these events -- and as they get rowdy, the buzzer gets quiet and then people are just calling me to be let in because nobody is hearing the buzzer or letting people in. This also leads to additional annoyance from my neighbors as people are now on my stoop / buzzing random doors in the building.

Problem 2: The Bike Problem

I also love to bike. I like to bike to my office (about 30 minutes), and I also bike back (45 minutes).[0] When I get back on my bike, I am tired, sweaty, and really really tired. I store my bike on my apartment on the second floor. The worst thing in the world is when I get home from a bike ride, and then have to get my keys from my backpack (they usually manage to wiggle their way to the bottom), and then I carry my bike in one hand and my keys in the other as I try to open the door with one quick action, buttressing the door with my bike and then squeezing through and putting my keys back in my bag as I readjust to bring the bike up to the second floor where I can tie it up like a horse outside my apartment.

Problem 3: The Package Problem

As you can maybe tell by my bike carrying situation, my building was constructed in the 1930s. It does not have a doorman. It barely has internet.[1] When a package gets delivered, the delivery person will buzz the intercom to your apartment, wait about 30 seconds, and if you're not at home the delivery person will leave your package on the stoop. This is a great system for many of the people who hang out in my neighborhood, as this means free stuff pretty much every day of the week. That being said, I love my apartment, and have no intention of moving out.[2]

The Solution

The solution hit me like a regular amount of bricks: I needed to automate my buzzer. And I should be able to trigger it remotely! So I went to the drawing board.

I have a Hubitat in my apartment, which I use to connect to my IKEA blinds[3] and my lightbulb.[4] So I had an ecosystem for home automation already set up -- first step down.

Second thing I had to figure out was how I could actually automate my buzzer. I have no experience with hardware whatsoever.[5] I figured -- I push a button to open the door, and buttons just close circuits, so that's probably what's going on there. I could probably automate that. And I'm probably not the first one to do it -- so I hit Google. And I found a guy named Chris Whong who's pretty much done it before. So, easy enough -- just gotta follow his instructions. Except he used hardware I don't have, but I have ESP32s lying around and I discovered that some lovely individual maintains an open source repository for connecting ESP32s to Hubitat. So the decision was made -- using Chris Whong's Medium guide as a source, I'd build:

I tackled this in steps.

The Technical Stuff

Step 1: Learn how to close a circuit with an ESP32

I downloaded Arduino IDE on my Mac. I downloaded the drivers. I learned what the little numbers meant on the sides of the ESP32 and I learned how to read and write from the outputs. I got my breadboard, my little wires, and a transistor, which is the only hardware thing I know about (thank you, Bachelor of Arts in English and Computer Science).

First circuit board with ESP32 and transistor that triggers an LED.

My first circuit -- a transistor and an ESP32.

This was pretty quick. I admittedly did have to google "How do transistors work" (I am still thankful for my BA).

Step 2: Learn how to trigger a pulse from Hubduino

This was also not so bad. I followed the instructions for setting up the Hubduino drivers on my Hubitat as well as on my library for my Arduino. Then, after a little bit of trial and error, I set up the ability to send a pulse through the circuit, turning on an LED using the power of my phone! Yay! Hardware wasn't that scary after all. I lamented the fact that I had let my ESP32s sit in my apartment for about a year, that I never did all the little projects I thought I was going to do. I realized that all those people on twitter[7] were right -- everything is actually really easy, being a CS guy means you can do anything, everything's online and not only is nothing impossible but actually everything is really easy.

Step 3: Learn how to do all the stuff that was actually really hard

Hubris. A natural consequence of constantly standing on the shoulders of giants. I had been living a lie -- building circuits on third base thinking I had hit a triple. I figured I'd be able to follow Chris' post, but reading through his medium article over and over again I realized I lacked the sufficient understanding of hardware concepts to comprehend how to finish the project. So I winged it: I decided that I would simply listen for an analog signal through one of the ESP32 ports, and then I'd use a transistor to close the circuit that opened the door.[8]

I went ahead and built my first iteration: an ESP32 that would send a pulse to a transistor that would bridge two wires and unlocking the door. The only problem was the circuit would close haphazardly, almost randomly. Fortunately, years of software development had prepared me for this -- I decided to add resistors until it worked.[9]

Circuit board with resistors added to prevent automatic triggering

I ended up just using one of the really big resistors.

Once the buzzing was complete I had to listen for the signal so I could let people in automatically at parties, and I could know when delivery people were at my door and buzz if they were close on whatever respective delivery service they were at. I read into how to listen for digital / analog signals on my ESP32, and then I hooked up the wires. Unfortunately, the buzzer seemed to always be sending some sort of signal. So I once again utilized my years of software development experience and added resistors until it stopped doing that.

Circuit board with additional resistors to filter the buzzer signal

I have a natural gift for circuit design.

I measured the outputs for a minute, set up some logic on Hubitat, and went downstairs and buzzed:

iPhone notification showing 'Button Pressed!' alert

Sometimes you get a text that's really bad like it's about someone dying or something. This was like the opposite of that feeling.

And it worked! And I was very proud of myself. Sure, the physical buzzer didn't work for some reason when it was plugged in, but I would never need to use my physical buzzer again with Alexa Integration and iPhone Integration and as I mused about how I would work around everything the "Button Pressed!" notification popped up again and again and again regardless of whether or not anything was being pressed and I realized that perhaps my system was flawed.

I looked at Chris' post once more and saw that there was some complicated circuitry that I didn't understand. I tried using LLMs to tell me what I needed to do, but they responded with hallucinated and confusing responses. I resolved to learn about it and tackle the problem later.

Step 4: Living with this solution for like a year

That's about where I ended up in 2024. I basically kept the circuit unplugged all the time except when I was throwing parties, in which case the false positives on the buzzer were fine. The solution wasn't what I wanted it to be, but it still looked cool at parties[11] and worked fine enough then. I got much better at opening my door with my bike and accepted that I would simply work from home on days with important packages.

Step 5: ChatGPT

A year ago, I tried asking ChatGPT for help with this project. It was not very helpful. Maybe I asked it wrong, maybe I wanted to give up, maybe I was happy with where it was -- all I know is that I couldn't get it to work. A week ago, I decided to give it another shot. I asked it:

ChatGPT conversation asking for help with buzzer automation

Asking ChatGPT for help.

It immediately returned a step by step guide (that was completely wrong). It made a lot of assumptions -- it assumed I was connecting wires directly to the ESP32, it assumed that the signal was 24 VAC[12] -- which I knew was wrong, because I had read the Medium piece. But then I realized! I read the Medium piece! Maybe I could use that in conjunction with ChatGPT...

And so I did -- I fed Chris' Medium article alongside a list of the supplies I had in my AliExpress electronics kit and the Arduino code I had written into ChatGPT, and out it spat:

ChatGPT generated circuit diagram showing ESP32 wiring

ChatGPT's beautiful diagram (nonfunctional).

Amazing! It told me exactly what I needed to do to read the signal -- AND it gave me a diagram. So I wired up everything and gave it a shot. It didn't work.

But then I checked through the code I wrote for the original ESP32, comparing it to the response, and I realized that the code wasn't doing what ChatGPT thought.

Back and forth ChatGPT conversation debugging the code

Sometimes you gotta lay down the law.

And then yayyyy! It worked.[13]

Final working breadboard setup with ESP32 connected to buzzer

Pictured: ESP32 connected to Songle SRD relay and 4N35 optocoupler, with appropriate resistors this time.

Learnings

Now, you may be asking -- how does this all work? What are the mechanisms? What did you learn?

The answer is -- I don't know, no clue, no idea. I managed to get this whole thing working without really having a deep understanding of what I was doing. I don't really understand pull-up resistors, optocouplers, pulsed DC. It leaves a queasy feeling in my stomach.

Growing up as early gen Z, I spent a lot of time on the internet having been given almost entirely free range by my loving but clueless parents. I sometimes wonder if this ruined my brain. Whenever I had a question, I'd always pop over to Google to answer it -- when I chatted with my friends online, I'd be a repository of knowledge. Then when it came to in person chatting I vaguely knew a lot of things but felt neutered without the web.[14]

I developed a dependency on the internet. And to this day, I have a terrible memory but I'm very fast at getting things done and quick to Google.

In this regard, ChatGPT is like Google but superpowered. I can do even more while understanding even less. I can't speak to the repercussions of it. All I know is that now I can open my door from my Apple Watch while carrying my bike.


[0] It could probably take 30 minutes to bike back, but after a long day of work I don't have the energy to sprint the Williamsburg Bridge. Conversely I am almost always running late in the morning and my love of being a good employee / fear of being a bad one unlocks a pace in me that shocks, scares, and impresses my followers on Strava.

[1] Spectrum.

[2] I've done the calculations -- I save more in rent than I spend on re-ordering packages.

[3] When I set my iPhone to Sleep/DND, the blinds close. When I wake up in the morning, they open. It's great.

[4] My apartment has a bunch of built in high frequency overhead lighting. I like a low orange light so I have a bunch of lamps in my apartment, and they turn on when the sun goes down.

[5] I have some ESP32s and a breadboard and a little electronics kit because it was really cheap on AliExpress.[6]
[6] In a similar vein, I also bought a lockpicking set for like 20 bucks. Maybe I'll do a blog post when I figure that out too.

[7] You can follow me at @AldenHallak -- I'm trying to get into it. shoot me a DM or something and we can follow each other maybe. idk

[8] Also, very lucky that this buzzer just worked by shorting two wires together. That's not how everything works apparently, but made things really easy on my end.

[9] Worked here is a loose term -- I definitely could trigger it from my phone, but I could no longer trigger it from the button on the door. I figured that I'd figure that out later.[10]
[10] I didn't.

[11] Cool, scary, whatever.

[12] I don't know what that means, but I know it's wrong.

[13] You can view the full ChatGPT conversation here.

[14] In this way I was like a spider. ha, ha.