© Pradeeka Seneviratne 2020
P. SeneviratneBeginning e-Textile Developmenthttps://doi.org/10.1007/978-1-4842-6261-0_6

6. Textile Wetness Sensor

Pradeeka Seneviratne1 
(1)
Mulleriyawa, Sri Lanka
 

In this chapter, you will learn about how to use the Wearic textile wetness sensor to detect if your garments got wet by liquids such as water and ice.

6.1 Wearic Wetness Sensor

The Wearic wetness sensor can detect small amounts of water or other liquids and ice on its substrate. The most common measurement principle for textile wetness sensors is a resistance measurement between two conductive electrodes. The support fabric on which the electrodes are built is an insulating material (e.g., polyester, cotton, polypropylene).

In the “dry” state, the textile wetness sensor has a very low electrical conductivity. In other words, the resistance is very high at about 1 megaohm. In a “wet” state, the ionic conduction starts, and the resistance changes to 1 kiloohm which leads to high electrical conductivity.

A big advantage of textile sensors is that fabrics absorb and spread liquids very well. Therefore, a small amount of liquid can change the resistance to a large amount. Also, the design of the two electrodes influences very strongly how big the shift is. The smaller the space between the electrodes, the more sensitive the sensor. To minimize noise, it is useful to define a resistance area and adjust a voltage divider for the desired measuring area.

Figure 6-1 shows the Wearic wetness sensor. The large supporting fabric area detects liquids such as water or ice. The sensor element has two snaps that help you to connect alligator cables. The snaps don’t have an electrical polarity, so you can connect them either way with a microcontroller.
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig1_HTML.jpg
Figure 6-1

Wearic wetness sensor

These sensors are easy to use, but they’re rarely accurate. The output may vary from sensor to sensor. So basically, when you use textile wetness sensors, you should only expect to get ranges of response. While textile wetness sensors can detect moisture or amount of liquids, they’re a bad choice for detecting the exact number of volume on them. However, for most wetness- and moisture-detecting wearable applications, they’re a good choice.

6.2 Testing Your Wetness Sensor

The easiest way to determine how your textile wetness sensor works is to connect a multimeter in resistance measurement mode to the two snaps on your sensor element and see how the resistance changes – the same thing you have done in the previous chapter for the textile pressure sensor.
  • First, measure the resistance of the “dry” textile wetness sensor.

  • Then measure the resistance by spraying (you can use a water spray bottle for this) a very small amount of water onto the sensitive area of the textile wetness sensor.

  • Finally, measure the resistance by spraying a large amount of water onto the sensitive area of the textile wetness sensor (to make it completely wet).

Try different ranges with your multimeter, between 20 MΩ and 2 kΩ. Because the resistance changes a lot, if you have a multimeter that supports auto-ranging mode at hand, turn it on because an auto-ranging multimeter works well here.

You can perform another experiment using ice. But remember to completely dry your textile wetness sensor before getting started.

6.3 Reading Wetness Sensor Values

The easiest way to measure wetness using the textile wetness sensor is to connect one of its snaps to the micro:bit’s 3V pin and the remaining snap to the micro:bit’s P1 (you can also use P0 or P2). Then connect a pull-down resistor (10 kΩ) between micro:bit ground and P1 (the same pin you used to connect the textile wetness sensor). Figure 6-2 shows the hardware setup that you can get help from to build the soft circuit.
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig2_HTML.jpg
Figure 6-2

Hardware setup to measure the wetness. Color code for the 10 kΩ resistor – brown, black, orange, gold

Follow these steps to set it up correctly:
  1. 1.

    Connect one of the snaps on the wetness sensor to the micro:bit pin 1.

     
  2. 2.

    Connect the remaining snap on the wetness sensor to the micro:bit 3V.

     
  3. 3.

    Connect the 10 kΩ resistor between micro:bit pins 1 and GND.

     

Now you are going to build a code to display the sensor values generated by the textile wetness sensor. The sensor values change rapidly when you pour water or some liquids onto the surface of the textile wetness sensor. It is not wise to use the micro:bit 5 × 5 LED matrix to display the sensor values – your micro:bit usually scrolls text and numbers, and it will take some time to display the entire value, so you may miss many sensor readings during the time.

As a solution, you will be writing data on the micro:bit’s serial output so you can read them from your computer (as long as your micro:bit is connected to your computer with a USB cable).

The code is very simple. Table 6-1 shows the steps that you can follow to build the code using the MakeCode blocks.
Table 6-1

Step-by-step instructions to build the code

Step

MakeCode Blocks

Description

1

../images/495861_1_En_6_Chapter/495861_1_En_6_Figa_HTML.jpg

Use the forever block. This will repeat everything you place into it.

2

../images/495861_1_En_6_Chapter/495861_1_En_6_Figb_HTML.jpg

Place the serial write number block into the forever block.

3

../images/495861_1_En_6_Chapter/495861_1_En_6_Figc_HTML.jpg

Replace the number 0 with the analog read pin block.

4

../images/495861_1_En_6_Chapter/495861_1_En_6_Figd_HTML.jpg

Choose P1 from the drop-down menu.

5

../images/495861_1_En_6_Chapter/495861_1_En_6_Fige_HTML.jpg

Place the serial write line block into the forever block after the serial write number block.

Figure 6-3 shows the full code created using the MakeCode blocks. You can also download the shared version of this code onto your editor by visiting https://makecode.microbit.org/_Dw6hC6hP0aet.
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig3_HTML.jpg
Figure 6-3

Code for writing data on the serial port

After you complete the code, download and flash it onto the micro:bit. The code will start to run immediately, but you can’t see any output on the micro:bit display. To get the values, you should read the micro:bit’s serial port.

In Chapter 5, you used the PuTTY serial terminal emulator program to read the micro:bit serial port. In this chapter, you follow the same procedure to read the data coming from the serial port. The following are the same steps you can follow to connect your micro:bit with PuTTY:
  1. 1.

    After downloading or installing, start the PuTTY.

     
  2. 2.

    Use the following settings: COM9, 115200, Serial. Replace COM9 with the correct COM port number which has been assigned to your micro:bit (Figure 6-4).

     
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig4_HTML.jpg
Figure 6-4

Configuration settings for the Session

  1. 3.

    In the Terminal section, check Implicit CR in every LF (Figure 6-5).

     
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig5_HTML.jpg
Figure 6-5

Configuration settings for the Terminal

  1. 4.

    Finally, click Open.

     
  2. 5.

    The serial terminal will open, and the wetness sensor values will display on it (Figure 6-6).

     
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig6_HTML.jpg
Figure 6-6

PuTTY terminal output, without pouring water/placing ice onto the textile wetness sensor

  1. 6.

    If you haven’t poured water or added ice yet onto the textile wetness sensor, the sensor reading you will get should be at about 9.

     
  2. 7.

    Now pour water onto the textile wetness sensor. First, start with a small amount of water and then increase the amount of water to make the sensor fully wet. You can see the sensor values increase to around 370 (the maximum you can get is 1023, but you can’t practically reach this point) (Figure 6-7).

    Note Not all the Wearic textile wetness sensors produce the same value for the same amount of water. Your textile wetness sensor may produce a different range of values than the values shown in this book.

     
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig7_HTML.jpg
Figure 6-7

PuTTY terminal output after pouring a large amount of water onto the textile wetness sensor

This experiment lets you determine the approximate values for different amounts of water and ice (or you can experiment with other liquids too).

6.3.1 Read the Serial Output in Mac OS

If you are using Mac OS, follow these steps to view the serial output:
  1. 1.

    Connect the micro:bit to your computer.

     
  2. 2.

    Open a terminal window.

     
  3. 3.

    Type ls /dev/cu.* and press the Enter key on the keyboard.

     
This will return to you a list of serial devices; one of them will look like /dev/cu.usbmodem1422 (the exact number depends on your computer).
  1. 4.

    Type screen /dev/cu.usbmodem1422 115200 and press the Enter key on the keyboard.

     
This will open up the micro:bit’s serial output.
  1. 5.

    To exit, press Ctrl-A followed by Ctrl-D.

     

6.4 Displaying Different Wetness Levels

In this project, you will display different wetness levels based on the values you are getting from the textile wetness sensor. Table 6-2 shows the approximate range of values and wetness levels.
Table 6-2

Wetness levels and analog read values

Values

Wetness Level

0–9

Dry

10–150

Slightly wet

151–250

Medium wet

251–1023

Fully wet

Note

There is no technical rule or mathematical model to determine the value range for each wetness level. You can use different value ranges for each wetness level based on your requirement – but remember not to overlap values.

Now let’s build the code to display the wetness levels on the PuTTY terminal when you apply different amounts of liquid onto the textile wetness sensor. You can use the same soft circuit you built in the previous section (the wetness sensor should be connected to the micro:bit pin 1).

Table 6-3 shows the steps that you should follow to build the code.
Table 6-3

Step-by-step instructions to build the code

Step

MakeCode Blocks

Description

1

../images/495861_1_En_6_Chapter/495861_1_En_6_Figf_HTML.jpg

Use the forever block. This will repeat everything you place into it.

2

../images/495861_1_En_6_Chapter/495861_1_En_6_Figg_HTML.jpg

Create a variable named wetness.

3

../images/495861_1_En_6_Chapter/495861_1_En_6_Figh_HTML.jpg

Place the set wetness to block into the forever block.

4

../images/495861_1_En_6_Chapter/495861_1_En_6_Figi_HTML.jpg

Replace the number 0 with the analog read pin block.

5

../images/495861_1_En_6_Chapter/495861_1_En_6_Figj_HTML.jpg

Choose P1 from the drop-down menu.

6

../images/495861_1_En_6_Chapter/495861_1_En_6_Figk_HTML.jpg

Place an if-then-else block into the forever block after the set wetness to block.

7

../images/495861_1_En_6_Chapter/495861_1_En_6_Figl_HTML.jpg

Click two times the plus button to add two more else-if sections.

8

../images/495861_1_En_6_Chapter/495861_1_En_6_Figm_HTML.jpg

Replace the true block with the less than block.

9

../images/495861_1_En_6_Chapter/495861_1_En_6_Fign_HTML.jpg

Replace the first input with the variable block, wetness. Also, replace the second input with the value 10.

10

../images/495861_1_En_6_Chapter/495861_1_En_6_Figo_HTML.jpg

Place a serial write line block into the “first” then part. Then type in dry.

11

../images/495861_1_En_6_Chapter/495861_1_En_6_Figp_HTML.jpg

Duplicate the less than block two times and place them into the placeholders of each of the else-if sections.

12

../images/495861_1_En_6_Chapter/495861_1_En_6_Figq_HTML.jpg

In the “first” else-if section, in the less than block, replace the first input with the variable block wetness. Also, replace the second input with the value 151.

13

../images/495861_1_En_6_Chapter/495861_1_En_6_Figr_HTML.jpg

Place a serial write line block into the “second” then part. Then type in slightly wet.

14

../images/495861_1_En_6_Chapter/495861_1_En_6_Figs_HTML.jpg

In the “second” else-if section, in the less than block, replace the first input with the variable block, wetness. Also, replace the second input with the value 251.

15

../images/495861_1_En_6_Chapter/495861_1_En_6_Figt_HTML.jpg

Place a serial write line block into the “third” then part. Then type in medium wet.

16

../images/495861_1_En_6_Chapter/495861_1_En_6_Figu_HTML.jpg

Place a serial write line block into the else part. Then type in fully wet.

Figure 6-8 shows the full code created using the MakeCode blocks. You can also download the shared version of this code onto your editor by visiting https://makecode.microbit.org/_9efKy7KuFAAp.
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig8_HTML.jpg
Figure 6-8

Code for detecting wetness levels

After you complete the code, download and flash it onto the micro:bit. After flashing, open your micro:bit’s serial port and connect to it using the PuTTY serial terminal emulator. Follow the same steps explained in the previous section to open the serial port. You can use the same serial port unless you have connected any USB devices with your computer after the previous project. However, check your micro:bit’s serial port again with the Device Manager.

Similar to the previous project, pour water onto the textile wetness sensor. When you increase the amount of water, the output changes accordingly as shown in Figure 6-9.
../images/495861_1_En_6_Chapter/495861_1_En_6_Fig9_HTML.jpg
Figure 6-9

PuTTY terminal output when pouring water onto the textile wetness sensor

6.5 A Real-World Use Case

Most of the wetness detectors commercially available in the market use the preceding technique to detect liquids on their surface. For example, The TEXIBLE Wisbi bed insert (Figure 6-10) detects wetness for people who suffer from urinary incontinence. If wetness from the bed is detected, a notification is automatically sent to the app or the recipient. A delay can also be set as required.

You can read more about the TEXIBLE Wisbi by visiting its product page at www.texible.at/shop/texible-wisbi-pflegeset-classic-betteinlage-sender-steckdoenempfaenger/.

../images/495861_1_En_6_Chapter/495861_1_En_6_Fig10_HTML.jpg
Figure 6-10

TEXIBLE Wisbi Plus – care set (bed insert, transmitter, socket receiver). Image courtesy of TEXIBLE GmbH (https://​texible.​com/​)

6.6 Technical Specifications

Table 6-4 shows some important technical specifications of the textile wetness sensor element.
Table 6-4

Technical specifications of the textile wetness sensor

Size

180 × 90 mm

Thickness

1.25 mm

Connectors

2 snaps (15 mm s-spring)

Sensing area

100 × 100 mm

Resistance range

1 kΩ–1 MΩ

Liquid amount

0.5–10 ml

Textile material

Cotton, stainless steel

yarn

Measurement circuit

Voltage divider

Washability

Limited washability

6.7 Summary

In this chapter, you learned how to use the Wearic textile wetness sensor with the micro:bit to detect various wetness levels. In the next chapter, you will learn how to send the textile sensor data to a smartphone (or tablet) using Bluetooth Low Energy.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.108.9