This project revolves around a box that can be opened remotely over a Wi-Fi connection. The box hosts a server locally and waits for the client to press a button on the webpage in order to transition from the CLOSED to the OPEN state, or OPEN to CLOSED if it has transitioned previously. Everything will be hosted on the same network, a mobile hotspot for the sake of the project.
Initially, the box is in the OPEN state, where the servo is at a 90 degree angle, the display has the “OPENED” text, IP address and the box is considered opened(lid up). After the user presses the button on the page, the box plays a sound, the motor activates to push down the cover of the box and the displayed message changes to “CLOSED”. A toggle will revert to the initial state.
The current implementation includes all the functionalities:
Libraries used are:
It is a very straight forward project, making use of multiple libraries and concepts (WiFi communication, HTML design, PWM, I2C, GPIO, UART). For end users, it's very simple to use, as the IP is clearly displayed, and could be even easier to connect to using a DNS. There's no need for them to do anything other than charge the battery every now and then as long as the network stays the same.
The servo was calibrated according to the first link in the software section and does a 90 degree turn. The display was calibrated using the 3rd link. The timeout is 10s, because a mobile hotspot could be a bit slow at times, in a real scenario this should be <1s.
I implemented one function at a time, first to make a sound, then to move the servo and then to draw on the display. I observed them working normally, whereas for the server I first used the serial to make sure it's connecting to the WiFi and later my laptop to connect to the server.
https://www.upesy.com/blogs/tutorials/esp32-servo-motor-with-arduino-code-sg90 - servo calibration
https://randomnerdtutorials.com/esp32-servo-motor-web-server-arduino-ide/ - another servo code I studied
https://randomnerdtutorials.com/esp32-ssd1306-oled-display-arduino-ide/ - display calibration + usage
https://randomnerdtutorials.com/esp32-web-server-arduino-ide/ - client response handling
https://github.com/stefungureanu/ESP32-remote-box - repository for the code
https://www.silabs.com/developer-tools/usb-to-uart-bridge-vcp-drivers - needed to connect to the ESP32 with a USB
https://www.electronicwings.com/esp32/esp32-timer-interrupts - timer interrupt guide, used for the client timeout
https://lastminuteengineers.com/esp32-pinout-reference/ – shows exactly which pin supports what
https://www.youtube.com/watch?v=2YbPyw5PS9A – useful video to show how ESP32 can be mounted on 2 breadboards
https://esp32io.com/tutorials/how-to-power-esp32 – very important read in case you want to power the board and the components with different sources