16. Wildcard week

This week I produced a shirt that combines embroidery, and sewn circuits.

The idea is to have the LEDs blink to the pulse sensed on MAX30102.

To do that, I need to

  • embroid a flower design using an embroidery machine, on the chest
  • sew MAX30102 (pulse oximetry and heart rate monitor module) using conductive thread, on the sleeve
  • sew LEDs using conductive thread on the flower embroidery, on the chest
  • produce a control board for MAX30102 and LEDs, and sew it onto the sleeve


FabLab Kamakura has 2 types of embroidery machines by Brothers.

Design the pattern

For the design, I decided to refer to this one.

To make the design in Inkscape, I followed this tutorial. She explained about how to draw flowers, leaves, and stems.


For the pedals and inside the flower, I made ellipse with filling and without stroke, duplicated to 6 and attached them together.


For the stem, I firstly tried “Draw freehand lines”.

I discoveredd that you can choose the smoothness of the line you draw. Once you selected “Draw freehand lines”, you can see that on the menu bar.

Here is a comparison among 6, 30, and 60.

And if I use “stroke to path” in “path” menu, it allows me to edit the line as a shape.

So I drew the stem.


I used “Draw Beizer curves” to draw the leaves.

After drawing, I editted the nodes so there aren’t any extra shape.

Finish up

And so I get one flower pattern!

So I grouped the pattern, copied and rotated to make the whole pattern. And I adjusted the canvas size.

Generate embroidery design using Ink/Stitch

Ink/Stitch is an open source machine embroidery design platform based on Inkscape.


I went to the install page, and downloaded Ink/Stitch v1.26.2 (2019-08-20) for macOS Mojave.

On Inkscpae, I opened Edit > preferences > System to check where my extensions are located.

Then I extended the downloaded folder of Ink/Stitch and pasted it under the extensions folder, and it’s installed!

Create params

Extensions > Ink/Stitch > Params is the function to generate embroidery paths

I drew a circle, Path > Object to Path to make it a path, and then got this with Params!

And the sewing angle changes when “Angle of lines of stitches” in “Autofill” is changed from 0 to 45 degrees.

However, when I tried to do it with the pattern I made, I got an error message:

Clean up paths

I figured that I had too many unnecessary paths. So I tried to combine paths.

Apparently it doesn’t work when I try to combine the whole pattern.

So I worked on the pedals and the inside of the flower.

I discovered that “Combine” actually doesn’t deletes the paths of the overlaping patterns, while “Union” does.

So I used union to combine the red and pink part of the flowers.

But I still get the same error from Ink/Stitch....

Generate embroidery design using Shishu PRONEXT

Not understanding what’s going on with Ink/Stitch, I turned to Shishu PRONEXT - a commercial software by BROTHER, using remote control of FabLab Kamakura’s laptop.

I get to access the laptop with shishu PRONEXT with remote control on Zoom.

I chose the machine type (PR1050), set up the canvas size, and opened the vector data after I exported my design to .wmf file.

It seemed like some parts of the flower were missing, so I copy & pasted to make sure all parts are there.

You can change the density of thread (an example of radius sewing),

and you can change how you want to sew it.

I chose radius sewing for the pedal, and concentric sewing for the inside of the flower.

And this is the one I got. My problems are that,

  • on the left it indicates that there are too many unnecessary parts.
  • the bottom part that indicates how the process will take part shows that there would too many thread changes

Revise data

To solve the problems, I

  • Cleaned up unecessary paths
  • Put the same color into the same layer

Clean up unecessary paths

I found out there were still unecessary parts remained on the leaf.

So I edited the path, deleted some nodes, and made everything smooth.

I need to be more careful with Beizer curves…

Edit layer

To put same color into the same layer, I needed to add a same frame to each layer, so I and the machine would know the exact position.

And I separated stem with leaves. Althought they are same color, one is line while the other is pattern. So this makes it easy when I want to change how to sew them.

Regenerate embroidery data

I went to the lab use Shishu PRONEXT to generate embroidery data.

I opened .wmf data of each layer individually, select the pattern, and set the style of stitches as the previous section.

And I saved each file as .pes file.

Then I clicked “Import data”, and clicked the folder icon appeared on the right to import all .pes data.

And I opened the data based on the order I want it to be embroidered (stem -> leaf -> red -> pink -> yellow. The one goes underneath needs to be embroidered earlier.)

Then I set up the thread color.

I selected the parts with same color, Pattern > Set thread color to open the color settings.

And I selected the same color number as the thread that is actually going to be set onto the machine.

I deleted the frame used in each layer.

I pressed the play button at the bottom to preview the embroider process. This tume the embroider procedure is following the order of each color!

And with Stitch simulator, you can see the connecting thread - when the machine finishes embroidering one part and goes to the next part with the same color, the thread is not cut so there is unnecessary crossover thread being generated. You can either cut it using your hand afterwards, or set up on the machine to have the machine cutting it for you.

Prepare the material/clothes

Adhesive core was ironed to the back of the material, to prevent the material from wrinkles when embroidered.

Once putting the adhesive core onto the material (the shiny side goes onto the material), I ironed with temperature set to “high” with steam. While ironing and after ironing, I pressed a book onto it to remove heat from the material.

Then I set the frame onto the material.

The frame should be within the area where adhesive core is on.

I put the upper frame onto the front, and screwed the back frame onto the upper frame.

I made sure that the cloth is tightly fixed onto the frame, so when you flick it, it makes a drum-like sound.

To set the shirt on the machine, I made sure that the neck part goes into the beam. Then I fixed the frame’s metal part onto the machine.

Set up the machine

To change the thread, I switched the lever to loosen the lock for thread.

I chose the thread of the color I wanted, and put a netted sleeve onto it.

After putting the bobbin onto the machine, I pulled the thread through many spots. The machine has guide on it so I just followed it.

Then I pressed the button on the panel to set the thread up, and switched the lever to loch the thread.

Using the panel, I selected the correct thread color.

I plugged the USB memory with the .pes data, and opened the data on the panel.

On the panel, you can move the position, change the size of the pattern, or rotate it.

After fixing those, I pressed the red button once to unlock, and again to start.

When embroidering, the thread got caught and stopped.

I discovered that to restart, I can start from the current position, or I can choose to wind back as many stitches as I want in case the previous stitches were not stitched properly.

Hero shot


The MAX30102 (datasheet) is an integrated pulse oximetry and heart-rate monitor module.

It uses I2C communication.

Connect MAX30102 to ATTiny44

I connected it to an ATTiny44 with 20MHz resonator, SDA to PA6, and SCL to PA4.

I added SparkFun MAX3010x library.

I tried to run a code from this site.

#include <Wire.h>
#include "MAX30105.h"
MAX30105 particleSensor; // initialize MAX30102 with I2C
void setup()
  while(!Serial); //We must wait for Teensy to come online
  // Initialize sensor
  if (particleSensor.begin(Wire, I2C_SPEED_FAST) == false) //Use default I2C port, 400kHz speed
    Serial.println("MAX30105 was not found. Please check wiring/power. ");
    while (1);
  byte ledBrightness = 70; //Options: 0=Off to 255=50mA
  byte sampleAverage = 1; //Options: 1, 2, 4, 8, 16, 32
  byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
  int sampleRate = 400; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
  int pulseWidth = 69; //Options: 69, 118, 215, 411
  int adcRange = 16384; //Options: 2048, 4096, 8192, 16384
  particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings
void loop() {
  particleSensor.check(); //Check the sensor
  while (particleSensor.available()) {
      // read stored IR
      // read stored red
      // read next set of samples

However, the serial plotter was blank.

I tried to run an I2C scanner code:

// --------------------------------------
// i2c_scanner
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
#include <Wire.h>
void setup()
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
void loop()
  byte error, address;
  int nDevices;
  nDevices = 0;
  for(address = 1; address < 127; address++ )
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();
    if (error == 0)
      Serial.print("I2C device found at address 0x");
      if (address<16)
      Serial.println("  !");
    else if (error==4)
      Serial.print("Unknown error at address 0x");
      if (address<16)
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  delay(5000);           // wait 5 seconds for next scan

But it tells me no devices were found.

An instructor told me that:

  • The I2C library for ATTiny is different from that of Arduino. TinyWire is one of them.
  • ATTiny44 doesn’t have hardware serial, so the pins for software serial need to be defined.

I will try these out later.

Connect MAX30102 to Arduino UNO

I connected MAX30102 to an Arduino UNO, with SDA to A4, SCL to A5.

I ran Example4_HeartbeatPlotter from Sparkfun library to plot heart rate.

  Heart beat plotting!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 20th, 2016

  Shows the user's heart beat on Arduino's serial plotter

  1) Load code onto Redboard
  2) Attach sensor to your finger with a rubber band (see below)
  3) Open Tools->'Serial Plotter'
  4) Make sure the drop down is set to 115200 baud
  5) Checkout the blips!
  6) Feel the pulse on your neck and watch it mimic the blips

  It is best to attach the sensor to your finger using a rubber band or other tightening
  device. Humans are generally bad at applying constant pressure to a thing. When you
  press your finger against the sensor it varies enough to cause the blood in your
  finger to flow differently which causes the sensor readings to go wonky.

  Hardware Connections (Breakoutboard to Arduino):
  -5V = 5V (3.3V is allowed)
  -GND = GND
  -SDA = A4 (or SDA)
  -SCL = A5 (or SCL)
  -INT = Not connected

  The MAX30105 Breakout can handle 5V or 3.3V I2C logic. We recommend powering the board with 5V
  but it will also run at 3.3V.

#include <Wire.h>
#include "MAX30105.h"

MAX30105 particleSensor;

void setup()

  // Initialize sensor
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
    Serial.println("MAX30105 was not found. Please check wiring/power. ");
    while (1);

  //Setup to sense a nice looking saw tooth on the plotter
  byte ledBrightness = 0x1F; //Options: 0=Off to 255=50mA
  byte sampleAverage = 8; //Options: 1, 2, 4, 8, 16, 32
  byte ledMode = 3; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
  int sampleRate = 100; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
  int pulseWidth = 411; //Options: 69, 118, 215, 411
  int adcRange = 4096; //Options: 2048, 4096, 8192, 16384

  particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings

  //Arduino plotter auto-scales annoyingly. To get around this, pre-populate
  //the plotter with 500 of an average reading from the sensor

  //Take an average of IR readings at power up
  const byte avgAmount = 64;
  long baseValue = 0;
  for (byte x = 0 ; x < avgAmount ; x++)
    baseValue += particleSensor.getIR(); //Read the IR value
  baseValue /= avgAmount;

  //Pre-populate the plotter so that the Y scale is close to IR values
  for (int x = 0 ; x < 500 ; x++)

void loop()
  Serial.println(particleSensor.getIR()); //Send raw data to plotter

And it worked!

Then I connected 2 LEDs with 150Ohm resistors parallel to Digital pin 3.

I didn’t know how to program it so it detects every heartbeat. So I refered to this page where they made the heart on the OLED “beats” everytime there is a heartbeat.

I crossed out all about OLED, added code about LED to the “We sensed a beat!” part.

#include <Wire.h>
#include "MAX30105.h"           //MAX3010x library
#include "heartRate.h"          //Heart rate calculating algorithm

MAX30105 particleSensor;

# define LED_BUILTIN 3
#define MAX30102   0x48 // 7 bit I2C address for DS1621 temperature sensor

void setup() {  

  particleSensor.begin(Wire, I2C_SPEED_FAST); //Use default I2C port, 400kHz speed
  particleSensor.setup(); //Configure sensor with default settings
  particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running


void loop() {
 long irValue = particleSensor.getIR();    //Reading the IR value it will permit us to know if there's a finger on the sensor or not
                                           //Also detecting a heartbeat
if(irValue > 7000){                                           //If a finger is detected

  if (checkForBeat(irValue) == true)                        //If a heart beat is detected

    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(LED_BUILTIN, LOW);

It worked out! I’m alive!

Points to consider when designing the circuit

The board and the sensor will be placed on the sleeve, while LEDs being sewn from there using conductive threads. Since it’s easy to short, I wanted to have as less wires as possible.

Here are the advices the electronics guru in FabLab Kamakura gave me.

  • Connect the LEDs in circular form with one wire to VCC and GND each
  • Solder the resistor onto the LED
  • Use transistor to magnify current

Board design

As much as I want it to work with ATTiny44, I will go ahead and design a board for ATMEGA328P.

I will make holes like Flora by Adafruit like this:

But I might do this after FabAcademy ends since the embroidery project should already cover the assignment…!



  • Flower pattern .svg file

  • Flower leaf part .wmf file

  • Flower stem part .wmf file

  • Flower red part .wmf file

  • Flower pink part .wmf file

  • Flower yellow part .wmf file

Sewn circuit

  • Example4_HeartBeat_Plotter .ino file
  • I2C Scanner .ino file
  • BPM to LED .ino file