• EUR€
  • £GBP
  • $USD

ESP32 Arduino Bluetooth: Finding the device with Python

DFRobot Apr 20 2018 1008

How to make a dress representing Saturn? The planets and satellites light up when the ring appears.

(This article copied from hackster.io, Author: Kitty Yeung)


Things used in this project

Hardware components

Adafruit Flora ×1

DFRobot Gravity: I2C BMI160 6-Axis Inertial Motion Sensor ×1

DFRobot LED String Lights ×1

DFRobot Accessories Polymer Lithium Ion Battery 1000mAh

(Or any 3.7 V Lithium Ion battery with a JST connector.) ×1

Painting of Saturn on fabrics ×1


Software apps and online services

Arduino IDE


Hand tools and fabrication machines

Sewing machine (generic)

zipper (generic)




A lot of my designs have been nature-inspired and space-themed. Saturn is one of my favourite solar system planets. It has a beautiful ring. I've been trying to come up with a way to display the ring, while regular clothing does not accommodate such a shape. But we all love spinning skirts. What if Saturn shows up when we spin? Since a spinning skirt will create an angle, why don't I add an accelerometer to detect the angle and light up the "planets" and "satellites?"

1. Fabrics

The first step is to create fabrics with images of Saturn on it. I've been using custom prints of my paintings on fabrics. I painted three designs: one for the front, one for the back and another one for the ring. I loved painting the shadows on the planet and the ring. All paintings need to be fit to the right size and considered for the fabric printing repeats. I also overlaid the patterns and the seam allowances of the dress directly on the graphics. This makes the cutting and sewing very easy later. (So you don't have to use paper patterns and transfer onto fabrics.)

Below are the three pieces with sewing instructions. You can purchase the fabrics with the patterns and seam allowances on them at shop.kittyyeung.com


2. Circuit and programming

(If you are looking at this tutorial for the dress making without tech, you can skip this step.)

Two components are attached to the microcontroller: the accelerometer and the LED string. Their schematics below show how they are connected to a DFRduino (Arduino UNO). I did use a UNO to do testing but then because for wearables we need smaller and thin boards, I switched to Adafruit FLORA.


Sticking the BMI accelerometer onto the FLORA makes them very compact. Note the direction of the X and Y axes. You need to make sure the Y axis is in the vertical direction when it's inserted to the dress later.

Cut the wires short and solder them onto the correct pins. Tape the battery to the FLORA. This makes everything durable and sturdy.


I really love that FLORA has its on-board switch. It always makes it easier when we have as few external components as possible. I tested that the lights can be seen through the fabric. It's great as it is subtle.


You can find in the code below how the accelerometer was programmed. It is a 6-axis BMI accelerometer and gyroscope, which can give readings of three accelerations and three angles. For this application, we calculate the angle between the Y and Z axis. I found that making the LED lit up at "abs(angle) > 0.2 && abs(angle) < 2.8" gives the best results - it won't be too sensitive which lights up all the time, but sensitive enough to make a difference. This is an empirical range. You may try other values and fine adjust based on your own system. To learn more, you can find other demo code for the accelerometer here.

3. Sewing

The first picture in section 1 shows the order to sew the pattern pieces. Hopefully it's straightforward for people who have sewn before. Just remember to leave space for the zipper (~14 inches).

Here are the specific steps and things to note when constructing the ring.

Cut the patterns along the solid lines.


You can also make a layer of lining, using fabrics of your choice. Cut the lining based on the patterns cut out.

Sew the pieces together along the seam allowances on the wrong side. Try it on. Adjust the fit if needed. These patterns are a little bigger on me, which is better than a little smaller.


Cut out the two rings, one for the top side, the other for the bottom side. Sew along the blue pattern lines to hide them inside. Leave the one along the "shadow" un-sewn.


Sew the two rings together along the outer and inner circumferences on the wrong side. Cut along the un-sewn line from the last step. Flip the right side out through the cut. Now sew the lines together, leaving a 20 cm gap like a pocket opening.

Pin the ring onto the dress, aligning at an angle based on the planet tilt. Also create some gathers where needed.

Cut a open section of the back of the ring to align with the zipper opening. Then sew the ring onto the main body, removing the pins.


Create bias tapes using leftover fabrics. Sew along the neckline and armholes. I added my logo during this step. Also finish the hem. May or may not need bias tape for the hem.

Press the dress and sew the invisible zipper on.

Throw the LEDs and modules into the pocket on the ring. Sew the FLORA through the pin holes onto the skirt with the Y axis in the vertical direction. Test it out. Adjust the code if needed.

There it is. Enjoy!




Accelerometer on microcontroller

Learn more here: https://wiki.dfrobot.com/Gravity__BMI160_6-Axis_Inertial_Motion_Sensor_SKU__SEN0250


LED string on microcontroller

Learn more here: https://wiki.dfrobot.com/LED_String_Lights__Colorful__SKU__DFR0439


Accelerometer angle-controlled LEDs Arduino

Learn more here: https://wiki.dfrobot.com/Gravity__BMI160_6-Axis_Inertial_Motion_Sensor_SKU__SEN0250

#include <DFRobot_BMI160.h>
int t;
#define  Light_string 6

DFRobot_BMI160 bmi160;
const int8_t i2c_addr = 0x69;
void setup(){
    pinMode( Light_string, OUTPUT);
  //init the hardware bmin160  
  if (bmi160.softReset() != BMI160_OK){
    Serial.println("reset false");
  //set and init the bmi160 i2c address
  if (bmi160.I2cInit(i2c_addr) != BMI160_OK){
    Serial.println("init false");

void loop() {

  int i = 0;
  int rslt;
  int16_t accelGyro[6]={0}; 
  //get both accel and gyro data from bmi160
  //parameter accelGyro is the pointer to store the data
  rslt = bmi160.getAccelGyroData(accelGyro);

    // read accelerometer:
  float rawX = accelGyro[3]*3.14/180.0;
  float rawY = accelGyro[4]*3.14/180.0;
  float rawZ = accelGyro[5]*3.14/180.0;


float angle = atan2(rawZ, rawY); // the funtion atan2() converts x and y forces into an angle in radians.  cool!  Output is -3.14 to 3.14
  if (abs(angle) > 0.2 && abs(angle) < 2.8) { //  digital pins are down
    ///  turn lights off in this position
        analogWrite( Light_string, 255);

    analogWrite( Light_string, LOW);