-
1Circuit Connection
The only circuit connection we need is connection between ESP32 and servo motor :
ESP32 ------------ Servo motor
VIN ----------------- VCC (Red pin)
GND ---------------- GND (Brown pin)
D12 ----------------- PWM pin (Orange pin) -
2The Voice Control App
Following is the app I used to send the voice commands from our smartphone to ESP32 via Bluetooth :
https://play.google.com/store/apps/details?id=com.locominder.bluetoothvoicecontrol
This voice control app is very quick to get started and It has some example codes for both Arduino and ESP32. Next, let us see the project code. -
3Project Code
I used Arduino IDE to program ESP32. We need the ESP32Servo library needs to install in Arduino IDE to control the servo motor using ESP32. Check the attached image for the ESP32Servo library. After installing the library upload the following code to the ESP32 and the project will work like a charm. Check the project in action in the above video
#include "BluetoothSerial.h" #include <ESP32Servo.h> #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif #if !defined(CONFIG_BT_SPP_ENABLED) #error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. #endif BluetoothSerial SerialBT; Servo light_servo; const int light_servo_pin = 12; void setup() { Serial.begin(115200); SerialBT.begin("ESP32Circuit"); //BLUETOOTH DEVICE NAME light_servo.attach(light_servo_pin); light_servo.write(133); } void loop() { if (SerialBT.available()) { String value = SerialBT.readStringUntil('\n'); value.toLowerCase(); Serial.println(value); if(value == "light on") { light_servo.write(70); } if(value == "light off") { light_servo.write(133); } } }
-
4Conclusion
With the power of ESP32, the precision of a servo motor, and the convenience of voice control, we've successfully transformed an ordinary home lighting system into a futuristic masterpiece. By combining hardware and software, we've bridged the gap between manual switch operation and intelligent voice commands. Our voice-controlled lighting system not only enhances convenience but also opens doors to endless possibilities in home automation. So, let's embrace this revolution and make our homes smarter, one voice command at a time!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.