Control All the Things - With a Fidget Cube!

by h0chi in Circuits > Remote Control

1143 Views, 7 Favorites, 0 Comments

Control All the Things - With a Fidget Cube!

IMG_20180916_215019_3.jpg
47724783-9e3f1580-dc57-11e8-8187-94d777c2300c.gif
IMG_20200705_220035.jpg

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

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

IMG_20200705_211007.jpg

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...

Opening the Fidget Cube

IMG_20200705_210912.jpg

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

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

Drill & Mill With the Dremel

IMG_20200705_211317.jpg

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.

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() {

}

Solder & Install the Circuit

IMG_20200705_215756.jpg
Screenshot from 2020-07-05 23-31-33.png
IMG_20180916_215019.jpg
SMD-Tactile-Switch.jpg

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!