Six Sided PCB LED Dice With WIFI & Gyroscope - PIKOCUBE

by moekoe in Circuits > LEDs

28695 Views, 234 Favorites, 0 Comments

Six Sided PCB LED Dice With WIFI & Gyroscope - PIKOCUBE

IMG_4603 3.jpg

Hello makers, it's maker moekoe!

Today I wanna show you how to build a real LED dice based on six PCBs and 54 LEDs in total. Next to its inner gyroscopic sensor which can detect movement and dice position, the cube comes with an ESP8285-01F which is the smallest WiFi MCU I know so far. The MCU dimensions are just 10 by 12 millimeters. Every single PCB has dimensions of 25 by 25 millimeters and contains nine WS2812-2020 mini LED pixel. Next to the controller there is a 150mAh Lipo battery and a charging circuit inside the dice. But more on this later...

If you are searching for an even smaller cube, then check out the first version which I have created on my website. It is casted in epoxy resin!

Pikocube version 1

Get Inspired!

MINI LED CUBE WITH 54 PIXEL, WIFI & GYROSCOPE | SMT HOTPLATE SOLDERING | PIKOCUBE V2.0

Enjoy the video!

You will find nearly everything for the cube in this video. For some further informations, design, PCB and code files you can check out the following steps.

PCB Design!

Bildschirmfoto 2020-03-04 um 00.24.01.png
Bildschirmfoto 2020-03-04 um 00.22.53.png
2020.03.03_pikocube_pcbs_aisler.png
2020.03.03_pikocube_alignment_bg.png

As you might know, my favorite PCB design software is Autodesk EAGLE. That's why I have used it for this project as well.

I've started using two different PCB designs, because I don't want to make the cube bigger than it has to. The outer shapes of both PCBs are just squares of 25x25 millimeters. The special thing of these PCBs are the three castellated holes on each side which distribute the three signals +5V, GND and the LED signal all over the cube. The order of the PCBs is shown in one of the schematics above. Hope you can imagine, the colored sides belong together once the cube is folded as a cube. The arrows are marking the WS2812 signal line.

The schematics, boards and the BOMs of both PCBs are attached to this step.

PCBs and Components!

IMG_4249.jpg
1C29E650-A5B7-47DF-97DC-885B679D0430.JPG
IMG_4354.jpg

The whole cube consists out of two different types of PCBs. The first one comes with the charging circuit and the Lipo battery jack and the second one contains the MCU, the sensor and some power latching circuit. Of course the PCBs have only be equipped once each. All the rest just containing the nine LEDs on the outside of the cube.

The PCBs special thing are the castellated holes on every side. On the one hand these holes/solder pads are used to get the cube looking like a cube and holding everything in place and on the other hand it transmits both the power for the LEDs and the WS2812 signal. Latter is more complicated because it has to be in a specific order. Every PCB has exactly one input and one output signal only and in order to interrupt one signal at a point, I added a few SMD soldering jumper pads.

Parts you will need for the MCU board:

Parts you will need for the power board:

Assembling the Cube!

IMG_4484.jpg
IMG_4506.jpg
IMG_4260.jpg
Bildschirmfoto 2020-03-06 um 11.14.01.png

For all the details of assembling the cube you should refer to the video above.

Assembling the cube isn't the easiest part, but for making it a bit more easy I have designed a small soldering aid where at least three of the six PCBs can be soldered together. Doing it two times you will get two PCB edges which have to be connected once everything is working. Yes, make sure everything is doing. I haven't test it so far, but unsoldering one PCB out of the cube could be difficult.

Make sure to solder three PCBs together before you attach the battery jack. Otherwise you have to modify the .stl file with a small hole where the jack fits in.

Downloads

Arduino Code!

The cube will start with a disabled WiFi to save some power, which is called modem sleep. Regarding to the ESPs datasheet, the MCU takes only 15mA while in modem sleep, whereas it needs around 70mA in normal mode. Good for battery powered devices like this one. To achieve this you will need the following code part before calling the setup function.

void preinit() {
	ESP8266WiFiClass::preinitWiFiOff();
}

With another button press you can wake up the WiFi by calling the standard WiFi.begin() function or in this case the Blynk.begin() which is the setup call for the APP which I have chosen to control the cube.

Converting some animations to the cube is only a little bit of math. The matrix conversion to a pixel on a specific outer wall is done with this simple helper function:

int get_pixel(int mat, int px, int py) {
	//starting at top left corner
	return (px + py * 3) + mat * 9;
}

Referring to the PCB pixel overview in step 2, the first matrix is the top one, the second is the front facing one, next ones are around the cube going into the right direction and the last matrix is the bottom one.

When using the attached code, you have to edit the WiFi credentials to match your network. For correct use with the Blynk APP, make sure to put both the files (BLYNK.ino and the other one with Blynk in it) into the same folder before opening the sketch. The sketch contains of two different tabs. The other file, which does actually nothing, don't need to be equipped with another tab. It is just for making the cube sleep when the button wasn't pressed. Otherwise the cube won't get into sleep and will draw current all the time.

The APP!

IMG_5538.jpg
IMG_5270.jpg

As already told, the cube starts with a single button press. But it won't start with the WiFi functionality at all. Another single press while the cube is already on will start WiFi and connects to a predefined network. Aftwards you can use the BlynkAPP to control the cube. Of course you can extend the functionality, there are plenty of possibilities for this thing...

A simple example layout inside the Blynk APP is shown here. It consists of two SLIDER (brightness and animation speed), two STYLED BUTTON (change animation pattern and switching the cube off), one STEP for changing cube mode, an LED for showing which dice side is up and last but not least a GAUGE for showing the battery status. All of these widgets make use of the virtual pins for APP-MCU communication. Something to read the virtual pins via the MCU is to call this function, whereas V1 is referring to the used virtual pin and param.asInt() holds the current value of the pin. The constrain function is just for limiting the incoming values (safety first :D).

BLYNK_WRITE(V1) { 
	//StepH  t = millis();
	current_mode = constrain(param.asInt(), 0, n_modes - 1);
}

To write a virtual pin to the Blynk APP you can use the following function:

int data = getBatteryVoltage();
Blynk.virtualWrite(V2, data);

You will get more info to this inside the Arduino sketch!

Have Fun!

IMG_5537.jpg

Designing and building the cube was a lot of fun for me! Nevertheless I have had some problems with it. First one is that I wanted to use a boost converter circuit inside the first version of the cube to ensure the WS2812 LEDs will run at 5V. Luckily they will run at Lipo voltage of around 3,7V as well, because the boost converter was far too noisy and disturbs the LED signal which results in an unintended blinky cube.

Second huge problem is that I wanted to use wireless charging possibility, even for the second version. Luckily I have added some charging pads which are accessible from the outside of the cube because the inductive power gets disturbed through the GND planes of the PCB and the components. Therefore I have to create a 3D printed charging stand, so that the cube can be put in and some contacts get pressed to the cube.

Hope that you enjoyed reading this instructable and may found a way to build your own cube!

Feel free to check out my Instagram, Website and Youtube channel for more informations about the cube and other awesome projects!

If you have questions or something is missing then please let me know in the comments below!

Have fun creating! :)