Control All the Things - With a Fidget Cube!

Introduction: Control All the Things - With a Fidget Cube!

Remember 2016s' fidget cubes?

Apparently all fidget cubes have working smd buttons inside. So I
decided to build an ESP8266 based iot switch for my two sonoff switches.

Of course, you can speak to any HTTP(s) device or API or even use other protocols, e.g. MQTT.

  • Usage note: You will need to press the button until the request is sent. The reason for this is discussed in the source code step.
  • Cost: $5-$10.

Supplies

  • fidget cube with smd buttons in it
  • soldering iron
  • solder
  • dremel
  • tweezers (or any more sophisticated tool to strip wires)
  • ESP-01
  • some thin but insulated wire
  • a tiny lithium battery (buy on e.g. aliexpress, mine is about 15mmx20mm)
  • USBtoTTL interface + jumper wires
  • maybe shrinktube

Step 1: Ensure You Have All the Things Ready & Know How to Program an ESP-01

Because we opt for a small footprint, we use the ESP-01 board with an ESP8266 on it. It's one of the ESP8266 boards with the smallest footprint.

Unlike the nodemcu or the arduino, the ESP-01 board has no onboard USBtoTTL, so you will need an extra device, a USB to UART interface.

If you are new to programming microcontrollers without any onboard USBtoTTL-Chip you may take a look at this Instructable:

https://www.instructables.com/id/Getting-Started-W...

Step 2: Opening the Fidget Cube

It takes some force to open, but eventually it will surrender!

The button side of the fidget cube should have 5 working SMD buttons.

Step 3: Drill & Mill With the Dremel

Before we solder the circuit, we need to get some space for the battery and the ESP01. Depending on where you put them, you might also need a drill for the wire to the button.

Here you're pretty much on your own, because there are at a lot different types of fidget cubes. Just make sure to have just enough place to fit battery and ESP01 plus some wire.

Step 4: Upload the Software Via Arduino IDE

This software just sends a HTTP request to a wifi plug with switches a lamp. You could however send any other HTTP(S) request or even use other protocols like MQTT.
Make sure to replace with your own Wifi credentials and HTTP endpoint.

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char *ssid =  "MyWiFi";
const char *pass =  "password";

void setup() {
  WiFi.begin(ssid, pass);
  //active waiting until connected to wifi
  while (WiFi.status() != WL_CONNECTED) {
    delay(50);
  }
  HTTPClient http;
  http.begin("http://192.168.178.65/led/1");
  http.GET(); 
  http.end();
}
void loop() {

}

Step 5: Solder & Install the Circuit

You just switch the whole ESP01. This is an extremly simple design with the consequence that you need to hold the button until the HTTP request is send. However it also saves the battery.

You could also use an always on design with the consequence that the battery may drain quicker and you would need a far more complicated software involving deep sleep mode and hardware interrupts to wake the device.

If your ESP-01 comes with headers (the pins), you may want to desolder them first. In my case this was the only way I could fit the ESP in the cube.

Make sure that you connect the smd button the right way (see image). The pairs are both fused.

That's it.

Happy hacking!

Pocket-Sized Speed Challenge

Participated in the
Pocket-Sized Speed Challenge

Be the First to Share

    Recommendations

    • Micro:bit Contest

      Micro:bit Contest
    • Plastic Challenge

      Plastic Challenge
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge

    Comments

    0
    jabujavi
    jabujavi

    1 year ago

    Wow! Such a great idea!