The non-attributed and non-adapted work in this repository is licensed under the MIT LIcense.
All files in adjusted folder are apapted work from @balassy 3D models on Thingiverse and are licensed under CC BY-NC-SA 4.0.
This concept and 3D model for the enclosure, mechanical and eletronic design is based on useless-box and Smart Useless Box with ESP8266 and Gesture Sensor.
All source code has been created from scratch.
3D Sketches available on Thingiverse, with local copy and extracted here. These files are licensed under CC BY-NC-SA 4.0 attributed to György Balássy.
The included Fritzing schematics are directly from the GitHub repository and licesed under MIT LIcense attributed to György Balássy (@balassy).
Using ESP32-C3 Super Mini
Datasheet from ardustore.dk
Pinout from arduinio.cc
See ESP32-C3 Super Mini on sudo.is.
Included parts for the Fritzing schematics:
- ESP32-C3 Super Mini (from Fritzing Forum - direct link)
- SG90 which is compatible with the MG90S used in this design (from SolderedElectronics/e-radionica.com-Fritzing-Library-parts- GitHub repo - direct link)
- APDS-9960 (from sparkfun/Fritzing_Parts GitHub repo - direct link)
- 2 Pin Toggle Switch (from Fritzing Forum - direct link)
brew install esptool
or
pip install esptool
Flash ESP32:
esptool.py --chip esp32c3 --port /dev/cu.usbmodem1452201 erase_flash
esptool.py --chip esp32c3 --port /dev/cu.usbmodem1452201 --baud 460800 write_flash -z 0x0 ./firmware/ESP32_GENERIC_C3-20240602-v1.23.0.bin
- 1 mini breadboard
- 1 x ESP32-C3 Super Mini
- 2 x MG90S this is compatible with the original SG90, but is more robust (metal gears) and quieter
- 1 x APDS-9960 (library)
- 1 x 2 Pin Mini On/Off Toggle Switch
- 1 x 1 kΩ resistor (color code Brown-Black-Red-Gold for reference)
- Various M2 and M3 screws, nuts and washers
The original files from balassy has been adjusted to accomodate the slightly larger controller on a mini breadboard (with extended). Additionally the micro USB port has been adjusted size and position for the USB-C port on the used ESP-C3 Super Mini.
Additionally mounts have been added to the box bottom, to allow for better mounting of the servo for the lid on the box-base, using 2 M2 screws.
This version of the useless-box has a controller which manages the behavior/response of the useless-box to stimuli/input. The implemented behaviors are:
- When the program starts, the controller initializes the box components, including the switch arm, lid arm, proximity sensor, toggle switch, and LED.
- The system enters the IDLE state initially, waiting for any user interaction (such as the proximity of a hand or the toggle switch being activated).
- The
update()
method continuously monitors the proximity sensor and the state of the toggle switch. - The box reacts based on proximity levels (
VERY_CLOSE
,CLOSE
, orFAR
) and the toggle switch state (On
orOff
). Here's how each condition is handled:
- If the toggle switch is turned on (
current_switch
becomesTrue
):- The system enters the
SWITCH_OFF
state. - The LED is turned on to signal the activation.
- A random delay (shorter or longer, with more frequent short delays) is introduced before switching off the toggle.
- The
_handle_switch_toggle()
method is called, which:- Opens the lid.
- Attempts to switch off the toggle. If it fails, it retries up to three times.
- Retracts the switch arm and closes the lid afterward.
- The LED is turned off again, and the state resets to IDLE.
- The system enters the
-
If a hand is detected very close (
ProximityState.VERY_CLOSE
) and the box is in theIDLE
state:- There is a 5% chance of the box playing a peek-a-boo animation:
- The lid opens slightly and then closes.
- There is also a 20% chance of the box threatening to turn off the toggle:
- The switch arm moves to a halfway position as if threatening, then retracts.
- If neither occurs, the box simply acknowledges the hand's presence but does nothing more.
- There is a 5% chance of the box playing a peek-a-boo animation:
-
If the lid is already open when the hand is very close:
- The box ensures the lid stays closed to prevent any tampering.
- Occasionally, it might perform a peek-a-boo with a 1% probability.
- The LED blinks slowly when the hand is very close.
- If a hand is detected close (
ProximityState.CLOSE
) and the box is in theIDLE
state:- There is a 30% chance the box will perform a fake-out:
- The lid opens slightly and quickly closes.
- Otherwise, it enters the
TEASING
state and performs a teasing animation:- The lid opens to a random angle (50% to 100%), pauses, and then closes.
- There is a 30% chance the box will perform a fake-out:
- If the hand moves away (
ProximityState.FAR
) and the box is not in theIDLE
state:- The box returns to the IDLE state.
- The LED is turned off.
- The lid is closed if it is open, and the switch arm is retracted.
- The box monitors the duration since the last interaction. If the time exceeds the set
inactivity_timeout
(5 seconds in this case):- If the lid is open (
LID_OPEN
state), the box closes the lid and retracts the switch arm to its default position.
- If the lid is open (
- If the user toggles the switch repeatedly (three times within three seconds):
- The box enters panic mode, where it:
- Rapidly opens and closes the lid while blinking the LED for five cycles.
- The state returns to IDLE after the panic mode completes.
- The box enters panic mode, where it:
- The LED behavior is tied to proximity:
- Very Close: LED blinks slowly (on for half a second, off for half a second).
- Close: LED blinks rapidly (on for 0.1 seconds, off for 0.1 seconds).
- Far: LED remains off.
- The
UselessBoxController
reacts dynamically based on the proximity of a hand and the toggle switch state. It performs quirky behaviors like teasing, fake-outs, peek-a-boo, threatening gestures, and panic mode to entertain and surprise users. - The randomness introduced (through probabilities and delays) ensures that the box feels unpredictable and playful, making interactions more engaging.
- The box also incorporates safety measures, such as ensuring the lid stays closed when the hand is too close and resetting states after inactivity, providing a consistent user experience.
- Useless Box PRO with ESP8266 and Gesture Sensor remix from original