Skip to content

5. E-textiles

WHAT IS?

Liza Stark covered everything we needed to know about circuits and sensors in this week's lecture, including how to build them, what supplies and equipment we'll need.

E-textiles, or electronic textiles, as it stands for, are fabric that you embed electronic components in. Any electrical component can theoretically be embedded, but commonly used in e-textiles are sensors, lights, and batteries.

Key components of e-textiles may include:

Conductive Yarns and Threads: These materials have conductive properties and can be woven or stitched into the fabric to create conductive pathways.

Microcontrollers: Small, programmable devices that can be embedded into the fabric to control electronic functions.

Sensors: Components that can detect and measure physical stimuli, such as light, temperature, or motion.

LEDs (Light Emitting Diodes): Small, low-power lights that can be integrated into the fabric for illumination or display purposes.

Batteries: Power sources that can be incorporated into the textile to provide energy for electronic components.

Flexible Circuits: Thin and flexible circuits that can bend and conform to the shape of the fabric.



WHAT IS ELECTRICITY?

Shutterstock

Electricity is a form of energy resulting from the existence of charged particles (such as electrons or protons), either statically as an accumulation of charge or dynamically as a current. It is a secondary energy source, meaning that it is converted from another, primary source of energy, such as coal, natural gas, oil, nuclear, or renewable sources.

The movement of electrons from one atom to another creates an electric current, which can be harnessed for various purposes. This flow of electric charge is typically facilitated by conductive materials like metals. The unit of electric current is the ampere (A).

Electricity has a wide range of applications and is fundamental to the functioning of modern societies. It powers our homes, businesses, and industries, and it is crucial for the operation of electronic devices, appliances, and machinery. The study of electricity and its applications is known as electrical engineering.

You can learn more about electricity Here



ELECTRONICS LAWS

OHM'S LAW

Quantity Ohm's Law symbol Unit of measure (abbreviation) Role in circuits In case you're wondering:
Voltage E Volt (V) Pressure that triggers electron flow E = electromotive force (old-school term)
Current I Ampere, amp (A) Rate of electron flow I = intensity
Resistance R Ohm (Ω) Flow inhibitor Ω = Greek letter omega

OHM'S LAW

This is the relation:

E = I x R

R = E/I

I = E/R

Here an example

OHM'S LAW

You can learn more about Ohm's law Here


REFERENCES AND INSPIRATION

one of my inspirations in the world of e-textiles is liza-stark, on her page you can see several of her works and collaborations when creating switches, sensors and more. The creative way helped me see electronics applications in a more artistic way and at the same time helped me break those limits that I knew.

Stroke sensors

describe what you see in this image describe what you see in this image


MORE INSPIRATION

Another work that inspired me a lot was that of Diane Wakim where she shows us how to make a sweatshirt that lights up. I began to see how we can use the conductive thread to power the LEDs, not only as a tool for conducting energy but also as a protagonist in the aesthetic area.

  • Image reference

sweatshirt that lights up/Diana Wakim

Being able to work with these conductive elements such as threads, soft sensors and others as an object not only function but also as a fashion item led me to expand the concepts that I already had, which is why I was encouraged to do something similar, I will show you later .

CLASS EXPERIMENTS

TOOLS

BEGINNING WITH ESP32

Something that we must always do before starting to use a new microcontroller is to investigate its characteristics, in my case I will be using an ESP32 WROOM from Adafruit.

CHARACTERISTICS

  • [Microcontrolador Tensilica LX6 240 MHz dual core - 600 DMIPS.]
  • [520 KB SRAM.]
  • [Wifi 802.11b/g/n HT40 Wi-Fi transceiver, baseband, stack and LWIP.]
  • [Flash 4 MBytes.]
  • [Sensor Hall]

The pin data can be seen HERE

PINOUT ESP 32

HOW TO CONNECT WITH ARDUINO IDE

STEP 1

In order to connect the ESP to the Arduino IDE, the following steps are necessary. You open the File option, click on preferences

CONECTION WITH IDE

You must paste the following link https://dl.espressif.com/dl/package_esp32_index.json

This will allow us to add the library of the espressif brand esp32 range boards

STEP 2

Then we need to install the esp32 library and select the correct card with which we will work.

CONECTION WITH IDE2

Now we are ready to start uploading code

The "HELLO WORLD", in electronics with microcontrollers is to turn on an LED, so in the following experiment we connected an LED to the ESP32 card and the LED's job was to turn on for 1 second and then turn off for another second.

CIRCUIT1 RESULT


void setup() {

  pinMode(14, OUTPUT);
}

void loop() {
  digitalWrite(14, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(14, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

LED ACTIVATED BY A BUTTON

In this experiment we occupy one input and one output.

input = button

output = led

The condition was that every time the button was pressed the LED would light up.

CIRCUIT1 RESULT


In the next photo I explain each part of the code

Code explained

const int buttonPin = 32;  // the number of the pushbutton pin
const int ledPin = 14;    // the number of the LED pin


int buttonState = 0; 

void setup() {

  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop() {

  buttonState = digitalRead(buttonPin);


  if (buttonState == HIGH) {

    digitalWrite(ledPin, HIGH);
  } else {

    digitalWrite(ledPin, LOW);
  }
}

LED BRIGHTNESS CONTROL WITH PHOTORRESISTANCE

In this example, the luminosity of the LED is controlled with a Photoresistor (adjustable resistor that changes its resistivity according to how much light is exposed). The more light the resistor is exposed to, the more the LED will turn on and the more light we remove, the more the LED will turn off.

CIRCUIT1 RESULT


  int LDR = 26;  
  int LED = 14; 
  int valor;   

  int max= 4000;  
  int min = 500; 

  void setup()
  {
       Serial.begin(9600);   
       pinMode(LED, OUTPUT); 
       pinMode(LDR, INPUT);
  }

  void loop()
  {
    Serial.println(LDR);

       valor = analogRead(LDR);    
       valor = constrain(valor, min, max);
       valor = map(valor, max, min, 0, 255);
       analogWrite(LED, valor);   //PWM OUTPUT     
  }

SWITCH WITH FRACS

For this example I wanted to see how to light some LEDs with a 3V battery and use a metal button as a switch.

CIRCUIT1


It was a challenge to accommodate everything in the fabric since I did not want to cause a short circuit with the conductive threads so I covered them with silicone, then I realized that if I also put a fabric between the middle of the fabrics it would still help me not to they made contact with the battery, bypassing the switch.

CIRCUIT1 RESULT


ANALOG SWITCH WITH FRACS

On this occasion I wanted to try to connect an LED and about 3 LEDs with a parallel connection, so I could regulate the brightness depending on the light in the environment.

For this example I used some components from the lilypad kit.

CIRCUIT1

CIRCUIT1

I really liked the final result, I think it is useful for decorations on clothing. In the following example I show how to do it with an esp32 and make the LEDs shine when there is no lighting, which would be the opposite behavior to that of this example and will be even more useful.

PROJECT

#include <WiFi.h>
#include <WebServer.h>


const char* ssid = "MOVISTAR_7936";  
const char* password = "M4N6JV6LF5jSgpezQuHB";  


WebServer server(80);



bool LED1Estado = LOW;

bool LED2Estado = LOW;


//LEDS

uint8_t led1L = 13 ;
uint8_t led2L = 12;
uint8_t led3L = 27;

uint8_t led1R = 33;
uint8_t led2R = 15;
uint8_t led3R = 32;

void handle_OnConnect() {
  LED1Estado = LOW; // 1
  LED2Estado = LOW; // 1
  Serial.println("LED1 : OFF | LED2: OFF"); // 2
  server.send(200, "text/html", SendHTML(LED1Estado, LED2Estado)); // 3
}

void handle_led1on() {
  LED1Estado = HIGH; //1
  Serial.println("LED1: ON"); // 2
  server.send(200, "text/html", SendHTML(true, LED2Estado)); //3
}

void handle_led1off() {
  LED1Estado = LOW;
  Serial.println("LED1: OFF");
  server.send(200, "text/html", SendHTML(false, LED2Estado));
}

void handle_led2on() {
  LED2Estado = HIGH;
  Serial.println("LED2: ON");
  server.send(200, "text/html", SendHTML(LED1Estado, true));
}

void handle_led2off() {
  LED2Estado = LOW;
  Serial.println("LED2: OFF");
  server.send(200, "text/html", SendHTML(LED1Estado, false));
}

void handle_NotFound() {
  server.send(404, "text/plain", "Problems here");
}

/*
   Aqui esta definido todo el HTML y el CSS del servidor WEB con ESP32
*/
String SendHTML(uint8_t led1stat, uint8_t led2stat) {
  // Cabecera de todas las paginas WEB
  String ptr = "<!DOCTYPE html>  <html>\n";

  // <meta> viewport. Para que la pagina se vea correctamente en cualquier dispositivo
  ptr += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr += "<title>Control LED</title>\n";

/*
 * El estilo de la pagina WEB, tipo de letra, tamaño, colores, 
 * El estilos de los botones (las clases en CSS) y la definicion de como van a cambiar dependiendo de como
 * cambien los estado de los LEDs, color fondo etc
 */
  ptr += "<style>html {background-color:#33475b; font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr += "body{margin-top: 50px;} h1 {color: #FFFFFF;margin: 50px auto 30px;} h3 {color: #FFFFFF;margin-bottom: 50px;}\n";
  ptr += ".button {display: block;width: 80px;background-color: #3498db;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
  ptr += ".button-on {background-color: #3498db;}\n";
  ptr += ".button-on:active {background-color: #2980b9;}\n";
  ptr += ".button-off {background-color: #1E2129;}\n";
  ptr += ".button-off:active {background-color: #2c3e50;}\n";
  ptr += "p {font-size: 14px;color: #888;margin-bottom: 10px;}\n";
  ptr += "</style>\n";
  ptr += "</head>\n";

  ptr += "<body>\n";
  /*
   * Encabezados de la pagina
   */
  ptr += "<h1>E-TEXTILES</h1>\n";
  ptr += "<h3>CONTROL PANEL</h3>\n";


/*
 * Aqui esta la inteligencia del servidor WEB con ESP32, dependiento de los parametros de la funcion SendHTML
 * modificara la vista de la pagina WEB,  llamaran a las clases "button-on y button-off" que cambian como
 * se muestran los datos en la pagina WEB 
 */
  if (led1stat)
  {
    ptr += "<p>RUTINE 1: ON</p><a class=\"button button-off\" href=\"/led1off\">ON</a>\n";
  }
  else
  {
    ptr += "<p>RUTINE 1: OFF</p><a class=\"button button-on\" href=\"/led1on\">OFF</a>\n";
  }

  if (led2stat)
  {
    ptr += "<p>RUTINE 2: ON</p><a class=\"button button-off\" href=\"/led2off\">ON</a>\n";
  }
  else
  {
    ptr += "<p>RUTINE 2: OFF</p><a class=\"button button-on\" href=\"/led2on\">OFF</a>\n";
  }

  ptr += "</body>\n";
  ptr += "</html>\n";
  return ptr;
}

void setup() {
  /*
   * Declaracion de la velocidad de comunicacion entre Arduino IDE y ESP32
   * Configura el comportamiento de los pines
   */


  Serial.begin(115200);
  pinMode(led1L, OUTPUT);
  pinMode(led2L, OUTPUT);
  pinMode(led3L, OUTPUT);

  pinMode(led1R, OUTPUT);
  pinMode(led2R, OUTPUT);
  pinMode(led3R, OUTPUT);

/*
 * Configuracion de la conexion a la Wifi de tu casa
 */
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Conectado a ");
  Serial.println(ssid);
  Serial.print("Direccion IP: ");
  Serial.println(WiFi.localIP());

  server.on("/", handle_OnConnect); // 1
  server.on("/led1on", handle_led1on); // 2
  server.on("/led1off", handle_led1off); // 2
  server.on("/led2on", handle_led2on); // 2
  server.on("/led2off", handle_led2off); // 2
  server.onNotFound(handle_NotFound); // 3

  server.begin();
  Serial.println("Servidor HTTP iniciado");
}

void loop() {
  server.handleClient();
  if (LED1Estado)
  {
    secuence1leds();
  }
  else
  {
    digitalWrite(led1L, LOW);
    digitalWrite(led2L, LOW);
    digitalWrite(led3L, LOW);
    digitalWrite(led1R, LOW);
    digitalWrite(led2R, LOW);
    digitalWrite(led3R, LOW);
  }

  if (LED2Estado)
  {
   secuence2leds ();
  }
  else
  {
    digitalWrite(led1L, LOW);
    digitalWrite(led2L, LOW);
    digitalWrite(led3L, LOW);
    digitalWrite(led1R, LOW);
    digitalWrite(led2R, LOW);
    digitalWrite(led3R, LOW);
  }
}

void secuence1leds (){
  digitalWrite(led1L, HIGH);
  digitalWrite(led1R, HIGH);

  delay(100);

  digitalWrite(led1L, LOW);
  digitalWrite(led1R, LOW);

  delay (100);

  digitalWrite(led2L, HIGH);
  digitalWrite(led2R, HIGH);

  delay(100);

  digitalWrite(led2L, LOW);
  digitalWrite(led2R, LOW);

  delay (100);

  digitalWrite(led3L, HIGH);
  digitalWrite(led3R, HIGH);

  delay(100);

  digitalWrite(led3L, LOW);
  digitalWrite(led3R, LOW);

  delay (100);


}

void secuence2leds (){
  digitalWrite(led1L, HIGH);
  digitalWrite(led1R, HIGH);
  digitalWrite(led2L, HIGH);
  digitalWrite(led2R, HIGH);
  digitalWrite(led3L, HIGH);
  digitalWrite(led3R, HIGH);

}