• No products in the cart.

Build a Wetness alarm with your textile sensor

  /  Make   /  Build a Wetness alarm with your textile sensor

How to detect liquids with a textile sensor

Water leakage on the roof, flooding in the cellar, knowing if the favourite plant needs water or as an addition to your weather station – a wetness or liquid alarm system is a very nice help in you smart home.

In this make section you are going to detect liquids and indicate it via blinking LEDs.

Requirements:

• WEARIC Expansion Board
• nano controller V3.0 Atmel Atmega328
Software Arduino IDE
• mini USB wire
• WEARIC Wetness sensor
• WEARIC LED textile

 

The wetness sensor behaves like a variable resistor, which assumes different values ​​depending on the degree of wetness. The more humid the sensor becomes, the lower the resistance gets and thus the read-in analog value in the µC decline.

That is why we have to check if the analog value falls below a certain limit and then activate the flashing.

We generate the flashing by counting the variable up and when we reach the value, indicated above, it will be reset and transmitted to the pins with the LEDs.

In the main loop we have to implement a delay which sets the exact counting rate. Combined with the maximum Value of the counted variable we determine the flashing frequency of our LEDs.

#define LED1_PIN 10
#define LED2_PIN 11
int counter = 0;
void setup() {
// put your setupcode here, to run once:
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(analogRead(A0));
if(analogRead(A0) > 100)
{
// -> wet
if(counter == 100)
{
digitalWrite(LED1_PIN, !digitalRead(LED1_PIN)); // toggle pin
digitalWrite(LED2_PIN, !digitalRead(LED2_PIN));
counter = 0;
}
counter ++;
}
else
{
digitalWrite(LED1_PIN, LOW);
digitalWrite(LED2_PIN, LOW);
}
delay(10);
}

This code can now be loaded onto the nano controller. When the sensor is dry, both LEDs are off. As soon as the sensor detects wetness, both LEDs start to flash and indicate the leakage.

For example, this function could be used for early detection of moisture in a cellar. Combined with a Bluetooth or Wi-Fi module the alarm could be sent to a smartphone to create an alarm wherever you are.