IoT Touch Sensor Using ESP8266 and KiwisIoT

by prakatheeshwaranR in Circuits > Arduino

187 Views, 0 Favorites, 0 Comments

IoT Touch Sensor Using ESP8266 and KiwisIoT

touchcom.jpeg

In this project, I wanted to try a simple way of detecting touch and viewing the result online using an IoT platform.

For this, I used a NodeMCU ESP8266, a TTP223 touch sensor, and the KiwisIoT platform.

The TTP223 is a simple capacitive touch sensor. When I touch the sensor, its output becomes HIGH, and when I remove my finger, the output becomes LOW.

The NodeMCU reads this value and sends it to KiwisIoT through Wi-Fi. This allows me to monitor the touch status directly from the KiwisIoT dashboard.

The complete working flow is:

Touch Sensor → NodeMCU ESP8266 → Wi-Fi → KiwisIoT → Dashboard

Supplies

touchcom.jpeg
touchcab.jpeg
  1. NodeMCU ESP8266
  2. TTP223 Touch Sensor
  3. Jumper Wires
  4. USB Cable
  5. Wi-Fi Connection
  6. Arduino IDE
  7. KiwisIoT Platform

Connect the Touch Sensor

touchcur.jpeg

First, I connected the TTP223 touch sensor to the NodeMCU ESP8266.

The sensor only needs three connections:

TTP223 → NodeMCU

  1. VCC → 3.3V
  2. GND → GND
  3. OUT → D2 (GPIO4)

After connecting the sensor, I connected the NodeMCU to my computer using a USB cable.

Set Up KiwisIoT

Next, I created a dashboard on the KiwisIoT platform.

For this project, I used Channel 1 to display the touch sensor value.

The NodeMCU sends either 0 or 1 to this channel depending on the current state of the touch sensor.


Program the NodeMCU

#include <KiwisIoT.h>

const char* ssid = "Wifi name"; // Replace with your WiFi network name
const char* pass = "Wifi password"; // Replace with your WiFi network password
const char* topic = "dash_1790068686198"; // Replace with your dashboard topic ID

#define TOUCH_PIN D2

KiwisIoT kiwisiot(ssid, pass, topic);

void setup() {
Serial.begin(115200);
delay(1000);

pinMode(TOUCH_PIN, INPUT);

kiwisiot.begin();

Serial.println();
Serial.println("Touch Sensor Started");
}

void loop() {
kiwisiot.run();

int touchValue = digitalRead(TOUCH_PIN);

Serial.print("Touch Value: ");
Serial.println(touchValue);

// Send data to KiwisIoT Channel 1
kiwisiot.send("1", touchValue);

delay(2000);
}


Read the Touch Sensor

The NodeMCU continuously checks the output of the TTP223 sensor.

When I touch the sensor:

Touch → HIGH → 1

When I remove my finger:

No Touch → LOW → 0

This makes it very easy to identify whether the sensor is currently being touched.

Send the Value to KiwisIoT

touchkiwis.png

After reading the touch sensor, the NodeMCU sends the value to Channel 1 on KiwisIoT through Wi-Fi.

The complete data flow is:

TTP223 Touch Sensor → NodeMCU ESP8266 → Wi-Fi → KiwisIoT → Channel 1

The NodeMCU keeps checking the sensor and updating the value on the dashboard.

Test Using Serial Monitor

touchout_832x551.png

After uploading the program, I opened the Arduino Serial Monitor to check whether the sensor was working correctly.

When I touched the TTP223 sensor, the Serial Monitor displayed:

Touch Value: 1

When I removed my finger, it changed back to:

Touch Value: 0

This confirmed that the NodeMCU was correctly reading the sensor.

Final Result

The project worked successfully. The TTP223 sensor detected when I touched it, and the NodeMCU sent the sensor value to the KiwisIoT dashboard through Wi-Fi.

I was able to see 1 when the sensor was touched and 0 when it was not touched.

This is a simple project, but it helped me understand how a digital sensor can be connected to the NodeMCU and monitored remotely using an IoT platform.

In the future, this project can be improved by connecting a relay, LED, buzzer, or other device. For example, the touch sensor could be used to control a light or trigger an alarm through the NodeMCU.

It can also be expanded into a touch-based IoT control system where devices can be monitored and controlled using KiwisIoT.