ESP32 CAM Example (Barn Door Control)

Hi,

Thought I would share a project I am close to finishing. A sliding barn door controlled by a stepper motor, a TM2209 FYSETC 3.1 (should work with any 2209) , an ESP32CAM, a 12V power supply, 12V to 5V solution and some jumper wires.

Stall guard might not be enough for precise and consistant positioning, but seems to be good at stopping a door when it gets to the end of it’s path, or stopping when colliding with someone. This is the basic concept behind this. Very silent too.

From working with the ESP32 CAM it is certainly capable of driving multiple 2209s using one wire UART mode, you could in theory have a version of marlin running on one. Very powerful little device.

It has a web page that you access via barndoor.local, put in your SSID and password at the top and program the ESPCAM32. The web page has buttons as shown below, open door, close door, update firmware, refresh. click on the pic to take another pic, wait and refresh the page. (will get around to something better, not javascript guru.). This is not using steps, but a sin function to control speed, it does the homing thing at the end. This needs to bump into something at either end, if not it won’t work properly, but barn doors usually have a bumper on either end.

Arduino code: (Needs some common downloaded libraries.)

Pretty new must say: (new html stuff, can go to X)
BarnDoor1.5.zip (8.9 KB)

Even Newer than that Version: (adds limit by steps)
BarnDoor1.4.zip (8.1 KB)

Newest Version: (Adds progress bar for OTA and mis tweeks.)
BarnDoor1.2.zip (7.5 KB)

Newer Version: (Adds json communication of settings.)
BarnDoor.zip (6.8 KB)

New version: (Adds log to the web page, misc tweaks)
barndoor.zip (6.5 KB)

Original
barndoor.zip (5.5 KB)



6 Likes

I’m not a fan of the barn door trend, but nice work adding power to it.

This would be even cooler with a motion sensor for automatic open/close. Better yet, add a DF-player with speaker, and have it play that “fssst” sound like the doors on Star Trek. I did that on one of my doors using homeassistant and esphome… not the automation, just the sound (it’s a swinging door).

[edit: With things like this… we are all stepping closer to acheiving “alexa, cook me up some 1/4lb burgers, with american cheese and ketchup.”

4 Likes

More of a practical necessity than any concern about being trendy, it’s a small room and sometimes large sheets need to get in it, so a normal door wide enough would be more trouble than it’s worth. :slight_smile:

The wall portion has sound deadening in it, very mesy stuff, imagine chasing bits of it down the road after it cracks off the roof of your car kind of messy. The door itself is insulated with rigid pink, keeps the heat in.

I have lots of ideas for where to go with it, this is just the start, originally was going to use face recognition, but needs consistant lighting I think. May use a electronic lock using esp01s and it’s relay board powered using the same 12V.

Cheers!

1 Like

I glanced through the code. You’ve integrated a lot of neat parts. Great project. Looks like a lot of fun. You can make any fun sounds yourself when operating it.

The esp32 cam is easily the most bang for the buck. Before the esp came out, a wifi adaptor for an arduino would set you back $100. It is so nice to be able to build stuff like this into custom projects.

I have moved most of my esp projects to esphome and I depend on home assistant to be the interface.

I have thought about that too, looked at the google API, everything seems to need a remote server of some kind, or you have a raspberry pi involved to roll your own. Keeping thinking of having to access the panel when the power goes out. More thinking and planning on that front.

I have the door opening in around 10 seconds, any kind of detection has to be 10 seconds early for the door to have moved in time, which involves thinking about sensor placement and technologies. The door is next to the washing machine, and I am inside doing the work from home thing, motion detector would drive me nuts, lol.

Cheers!

Home assistant runs on a home computer. A pi is ok. But I have the HA blue, which is a little more powerful SBC for about $100. You can install it on anything though. A VM on a home computer is a common install method. It isn’t worth it for any one project, but it is the backbone of all of them at this point. I probably have 50+ devices connected to it. I only use the local control, no google stuff. I really wish my google home could connect to the stuff that is on the exact same network. But it refuses and only wants to access apis on the https internet.

Those ESP32-Cam devices are amazing for the price. I bought ten of them from China not too long ago and they are waiting for projects. This is a cool use.

I was thinking it could be a replacement for a Pi Camera or USB camera on OctoPi, since OctoPrint doesn’t need the camera to be part of the same server. A computer vision operation could take advantage of any number of cameras, wide/narrow field of view, stereo, shallow view angle, or whatever, and given that they are only $5 each you can really go crazy.

1 Like

@ByronM fun project! Do you think that the metal bearings are going to eventually wear into your wall?

Neat project! Need something similar for my Jefferies tubes.

1 Like

You will need a pi or other server to make use of esphome/HA, but the nicest part about it all is it’s designed to be cloud/internet free. Also if power goes out, you can configure an esphome device to still function without the server (provided the sensors and actuators are physically attached to the esp device). So you won’t have malfunctioning doors/lights when the internet goes down, unlike cloud based automation solutions.

You may need to add a battery backup nearby if you need to operate the door when the power goes down. There are lots of ways to implement this. I often use these with a gel cell battery to make a DIY 12VDC UPS:
https://www.amazon.com/MEAN-WELL-DRC-100A-Battery-Charger/dp/B09HJYGRQC

For sensors other than motion, camera recognition, under floor pressure sensor, or an IR trip wire are common solutions. One of those esp32-cam’s Jamie mentioned might work great for camera recognition. I have an arducam-esp32/uno-psram board, and it can do facial recognition onboard (locally processed, no cloud or network required). Not sure on pressure sensors, or if that is even possible for your install. The IR sensors would be easy peasy… but a bit limited in that the trigger line is fixed and cannot be temporarily blocked.

WRT the washing machine… I use sonoff pow devices (these are rated 20A) flashed with esphome to monitor the current drawn by my washing machine and gas dryer. This is used by HA to determine when either machine cycle finishes, and I get voice prompts “Dryer load is finished” and “Washer load is done” from the dfplayers spread throughout the house (also get a telegram to my phone, but thats going way OT). Modern washers are sorta tricky to sense because most of them will stay in what would appear to any sensor (outside of hacking the internal circuit of the machine, using a light sensor above the “running LED”, or other less elegant methods) as off state for long periods of time mid cycle, then continue working. You have to observe and measure these idle periods, and account for them with conditions in the code for it to work reliably. In my case, I just have the automation wait until it sees >25sec of off current before calling it “done”.

2 Likes

My Internet of Laundry Things uses a photoresistor on the status leds of the washer/dryer. There is an led on the washer for “door locked” which is on during the whole cycle. The dryer has a “clean lint filter” which turns on at the end.

2 Likes

Might, will have to see the long term impact, the scuf mark is likely from the testing phase, some crazy flapping when it keeps banging with no end in sight, paint should cover it up. Easier to hang the door with one guide above the one on the floor since I made the door taller than I thought.

Cheers!

1 Like

Lots of idea there, for now I just disable the motor when it’s not moving so I can move it by hand easily, back current hasn’t fried anything yet, cross fingers. Also the belt is probably looser with less angle than say a low rider, going to get one of those large motor gears (2"?) to increase the surface area the belt contacts. One of these days I will try 3d printing again.

The wall I made is in front of stairs going up to the front door, so the angle of the sensor would have to be just so and facial recognition is likely one of those movie things where you are standing in front of the door for a while. I had the sample face recognition sketch working but it is cpu intensive with streaming video at least, haven’t tried all the tensor lite and derivatives for doing it faster.

I can hear the washing machine easily enough, lol.

Cheers!

Same, had the idea of multiple camera angles to do video of a low rider making something. :slight_smile:

50+, that’s a lot. I have some light bulbs and led strips, can’t imagine that many things. :slight_smile:

I just counted. 94 devices (which includes internet services).

I have replaced almost all of the light switches with wifi ones (shelly). I have the chromecasts, 15 ESPHome things, 10 BT temp sensors. Then a bunch of 1-2 things. A couple of the integrations are just web scrapers or they integrate with the Internet to get the weather, or status of my home routers, or download speed tests.

It didn’t happen like that overnight. I spend a little time here or there adding things. There are a few automations the family really likes. Most of them are barely useful, but I enjoy working on it.

1 Like

I wonder if adding diodes would prevent that? I recently saw a post where someone fried a driver by moving their gantry around. Really surprising. But this is a really low probability use case so maybe you don’t have to worry about it. :man_shrugging:t2:

The stepper drivers drive current in both directions, on both coils, so I can’t think if a way simple diodes on the motor circuits can help. Some diodes on the PSU to sink any voltage over the supply voltage might work.

I would just not back drive it too fast. A larger gear on the stepper motor would make it move faster, and have less back driven voltage.

1 Like

Hmm, this may be best solved mechanically, like a servo operated clutch or similar. With something like that you can get away with a single 18650… just enough to throw the servo over to disengage the transmission after power goes out.

Twice I have fried control boards (MKS Gen L) from moving the steppers too fast. The drivers are fine, but they back-feed excessive voltage back to the motor supply. I haven’t analyzed exactly which pieces died, but I’m pretty sure the 5V controller voltage is regulated down from the 24V and probably that regulator fails and cooks stuff on the 5V rail.

In this case it would depend what happens when the buck converter is given excessive voltage. You probably have a lot of headroom since the supply is 12V and those buck converters tolerate up to 30V.

This I would think would be the best approach, but it probably requires a proper circuit design to ensure it’s successful. My first guess would be a Zener diode to detect and shunt over-voltage, but the Zener diodes might themselves blow up quickly and then you lose the protection.

Maybe a Zener diode and current limiting resistor can turn on a transistor that powers a beeper so it screams in pain when you move it too fast. That would add safety and it would also be fun.

1 Like