Welcome to Day Four of Learning Robotics
Today I designed a case for my ESP32 Distance Sensing Light Switch.
I designed the case with holes for the sensor antenna and an open back to mount the ESP32.
I screwed it together using four M2 screws.
The whole device is powered by the USB-C cable and mounted to my workbench wall to detect my presence.
This project uses an ESP32. It’s a microcontroller that has wifi and bluetooth.
I’m connecting it to this ultrasonic distance sensor so it can detect when I sit down at my workbench.
It gets connected to GND, 5V, GPIO 25 (Trig), and GPIO 26 (Echo) using a breadboard
Once it detects that I’m here, it turns on my light using a smart plug, and a home assistant web hook.
Follow for part four, to see how you can set up home assistant too.
The ultrasonic distance sensor and servo motor from Day 1 are used to open a toolbox when a hand approaches it.
Use the circuit from day one. Detach the power rail of the breadboard, and reconnect the components using jumper wires. Pin numbers remain the same. Flash the code: ServoToggle to the board.
3D Print hinges and the servo bracket, and use M2 or M2.5 screws to attach them directly to the plastic box.
Drill two holes into the front of the box, spaced to fit the ultrasonic distance sensor's antenna. Drill one hole in the back to plug in the Arduino.
Once attached, use electrical tape to secure the jumper wire connections and to hold down wires.
Use trial and error when placing the servo horn:
180 degrees should point down into the box.
90 degrees should be a resting position to keep the horn close to opening the lid, making response times shorter.
50 degrees should be enough to open the box, while allowing it to fall back down on its own.
This taught me that even simple circuits can become successful projects when given enough thought.
Follow along for day 3, where this sensor (along with others) will become a permanent part of my workbench.
Welcome to Episode 1 of Learning Robotics
An Arduino Uno is a microcontroller board.
It can be used to control things such as servo motors.
Using 'Simple Sweep' on the Arduino IDE will make the servo motor move from 0 degrees to 180 degrees and back, continuously.
Then, connect an ultrasonic distance sensor: First, connect a power rail (side of the breadboard) to the Arduino's 5V pin and GND. Second, connect both the servo and the sensor to 5V and GND as appropriate. Third, connect the trigger and echo pins of the sensor to GPIOs 8 and 7, respectively. Finally, flash the 'Sensor Sweep' code to the board.
Follow along to see day two, where we will use what we just built in a robot.