Introduction: Rube Goldberg Machine With an ESP8266-based Alarm Clock

We created an Internet-connected alarm clock with the Rube Goldberg machine as inspiration. This project utilizes an ESP8266 Wi-Fi module and the Adafruit Circuit Playground, which are interfaced with the Blynk app to set the alarm. The reason for building this project, aside from being our course’s final project, was to create an interesting way to execute a simple task - setting off an alarm. By using the concept of a Rube Goldberg machine, the simple task of being alerted by an alarm was turned to an, perhaps unnecessary, but also more interesting series of events.

Our project requires interaction between hardware (Arduino Circuit Playground, ESP8266 module), software (Blynk app, Arduino IDE), and web services (world time API). The alarm isn't simply set and triggered, but requires setting a digital time, which when matched, triggers a visual and auditory alarm until manually stopped. The unnecessary complexity of the Rube Goldberg Machine lies in this project's digital interaction.

Our project also must include 3 sensory scenarios coming from the controller, and 3 operating scenarios that will reach the controller:

Sensory scenarios coming from the controller:

  • WiFi Connection Status: The controller is connected to WiFi and using this connection to send data to the server. The sensory scenario involves sensing whether the device is connected to the network or not.
  • Time Data: The controller connects to the WorldTimeAPI server, performs a GET request, and receives a response in JSON format that it then parses for the current time in the specified timezone. It uses this information to check if it's time to trigger the alarm.
  • Alarm status (Button press): Once the alarm is going off, it's looking for user input to turn it off. The device is waiting for a button press on the Circuit Playground to turn off the alarm.

Operating scenarios that will reach the controller:

  • Alarm Settings: The Blynk app sends user-defined alarm settings (hour and minute) to the controller via virtual pins V0 and V1. These are received in the BLYNK_WRITE functions.
  • Alarm Trigger: If the current time matches the alarm time, the controller triggers an alarm. It sets the color of the LEDs on the Circuit Playground to red, and makes a beeping noise.
  • Resetting Alarm Time: Once the alarm has been acknowledged by the user pressing a button, the controller will go back to the initial state, waiting for a new alarm time to be set via the Blynk app.

Supplies

  • ESP8266 Wi-Fi Module
  • Arduino Circuit Playground.
  • Blynk App installed on your smartphone.
  • Arduino IDE installed on your computer.
  • USB cable (or whatever needed to connect board to your computer)

Step 1: Setting Up the Blynk App

  1. Open the Blynk App on your smartphone or computer
  2. Create a New Project and name it "Rube Goldberg Machine".
  3. Choose the ESP8266 as your hardware model and Wi-Fi as the connection type.
  4. In the project dashboard, add two "Slider" Widgets.
  5. Set the output pin of the first slider to V0 and the second to V1. These will be used to set the alarm hour and minute, respectively.
  6. For the first slider (V0), set the input range to be 0-23. For the second slider (V1), set the input range to be 0-59.


Step 2: Wiring the Circuit

In this project, the ESP8266 Wi-Fi module and the Arduino Circuit Playground have been pre-connected. If you are in a similar situation, you can move forward with the already assembled board. However, if your ESP8266 Wi-Fi module and Arduino Circuit Playground are not pre-connected, you will need to wire them together. There are several resources available online to guide you through this process, and the exact wiring will depend on the specific models of the Arduino and ESP8266 that you're using. To follow our models... 


  1. Upload the sketch "ESP8266Console" to the CPX board. Open a Serial Monitor at 9600 Baud.
  2. Type the following AT commands in the monitor's command line one by one:
  • AT+RST (Reset the module)
  • AT+CWMODE=1 (Select Wi-Fi type - Station)
  • AT+CWJAP="SSID","PASSWORD" (Connect to the Wi-Fi network with your SSID and password)
  • AT+CIPMUX=0 (Select single connection mode)
  • AT+CIFSR (Show IP address, check if connected to Wi-Fi)
  • AT+CIPSTART="TCP","www.adafruit.com",80 (Connect to the server)
  • AT+CIPSEND=61 (Preparing to send)
  • GET /testwifi/index.html HTTP/1.1 (Requesting a page)
  1. Verify that the firmware version is correct. Type "AT+RST" in the monitor's command line and note the firmware version number displayed.
  2. If the firmware version is outdated or mismatches, download and install the ESP8266 Download Tool.
  3. Download the latest firmware file from http://bit.ly/esp-firmware-174.
  4. Select the downloaded firmware file in the ESP8266 Download Tool and press the Start button to upload the updated version to the board.
  5. Once the correct firmware is installed, the ESP8266 should be ready to access web servers.

Step 3: Programming

  1. Open the Arduino IDE on your computer.
  2. Connect your board to your computer via USB cable.
  3. Copy the provided code into the IDE.
  4. Replace the "auth", "wifiSSID", and "wifiPass" with your Blynk Authorization Token and Wi-Fi credentials.
  5. Select your Arduino board type and port from the Tools menu, then upload the code.


Step 4: Running the Machine

Event 1: The Blynk app is used to set the alarm time (Set the alarm time in the Blynk App by adjusting the sliders.). This sends a signal through the internet to the ESP8266 Wi-Fi module.

Event 2: The ESP8266 Wi-Fi module receives the alarm time and passes it to the Arduino Circuit Playground.

Event 3: Simultaneously, the ESP8266 Wi-Fi module regularly fetches the current time from the world time API over the internet.

Event 4: The Arduino Circuit Playground continuously compares the alarm time from the Blynk app and the current time from the world time API.

Event 5: Once the current time matches the alarm time, the Arduino triggers an alarm sequence on the Circuit Playground.

Event 6: The alarm sequence begins by flashing all the LEDs and producing a tone.

Event 7: The alarm sequence continues in a loop (flashing LEDs and tone) until a user intervention event happens - pressing either the left or the right button on the Circuit Playground.

Event 8: The pressing of the button sends a signal to the Arduino to stop the alarm sequence.