So I am here with my new Contactless Switching Mechanism that can almost applicable in the real world scenario. Unlike mechanical switches you don't need to apply pressure on switches, they extremely contactless. So it is highly usable in the world which faces COVID - 19 pandemics. So this mechanism can be used in public places to avoid contact between peoples which avoid the possibility of spread in the community.
Rather than a simple contactless switching mechanism. It has different two different modes of switching capability. They are
- Toggle Mode
- Push-button Mode
Let's see the Demo video
This contactless switching mechanism can be used anywhere
- as Nurse call button
- as proximity switches
The possibilities are infinite and that depends upon the user's need.
In this project, I made a switchboard with this mechanism. The user didn't need to change the mode, the switching device automatically changes its mode in accordance with user interactions. Apart from this,switchboard can monitor the energy consumption of the gadget connected to this device,and it will be shown on your mobile. By its capability, the switching can be done on this device only by the infrared rays emitted by the human body. So any other body emitting the infrared rays can't trigger the switches.
Hardware- KEMET’s Pyroelectric Infrared Sensor(SS-430):
The most important part of the switching device is Kemet SS-430. This sensor is actually triggering the switch,when we fingered in to the switch board. It works by using the pyroelectric effect of ceramic by absorbing infrared rays emitted from the human body.
For working with this I have removed the connector pads because i don't have JST-Connectors.
For connecting and soldering,i have used 30AWG wires and mustool's iron. I have soldered the wires in the 300 degree Celsius temperature. That temperature won't damage the IC's in the sensor board. We need only three wires from SS-430, that are
Vin - Pin No.1 (Input Voltage)
Vout - Pin No.4(Comparator output)
GND - Pin No.5(Ground)
The other pins are not used. Also be careful while soldering the wires.
- ACS712 Current Sensor Module:
Here AC current is measured by using ACS712. It is a Hall Effect current sensor that accurately measures current when induced. The magnetic field around the AC wire is detected which gives the equivalent analog output voltage. The analog voltage output is then processed by the microcontroller to measure the current flow through the load. To know more about this sensor check out here . It is a current sensor, so it is connected in series with the load. Here i am using ACS712 with 5A current range. It is available in different ranges.
- Relay:
A relay is a switching device as it works to isolate or change the state of an electric circuit from one state to another. It is used to switch the High load with 3v input from micocontroller.
- NodeMCU:
NodeMCU is a low-cost open source IOT platform. It initially included firmware which runs on the ESP8266 WiFi SoC from Espressif Systems, and hardware which was based on the ESP-12 module.
In this project, NodeMCU forms the brain of the device. All the data are processed here and further events are triggered by this microcontroller unit. Sensors and relay are connected with this Microcontroller. It should be connected to a wifi to share the data and the wifi has proper internet access.
- 5V 1A Power Supply:
I have used the 5V 1A power supply to power up the NodeMCU. I have taken it from my mobile charger. It is easily available at local stores.
Software & Design:- Arduino IDE :
The code is developed in C and is uploaded using Arduino IDE. For interfacing Nodmcu with Arduino IDE just go here.
- Design:
For testing the SS-430, connect the sensor to the nodmcu. The comparator output of sensor is connected to the D1(GPIO5) of MCU,GND to GND and 3V to Vin. Upload this test code in to MCU.
int sensorPin=5;
void setup() {
pinMode(sensorPin,INPUT);
Serial.begin(9600);
}
void loop() {
int value=digitalRead(sensorPin);
Serial.println(value);
}
After the code uploaded. When you open the Serial monitor in Arduino IDE(make sure that the baud rate is 9600) as you can see like this.
If we move hands in front of the sensor, it will show like this
In this way we can easily check whether the sensor is working or not.
For this switch board we need to reduce the angle of detection(for proper working) so we are adding white lens at top of the sensor(as you can see below). So the angle is reduced, but the distance of detection is increased.
This can be avoided by making a Resin like case for the switch board. Here i bought a switch board from the local store,for this project. In this board i am replacing the mechanical switches with contact less one.
I have only one SS-430 with me, so i placed at the left side of the box.
The other side is just covered by the plastic sheet.
Let's get in to technical aspects of sensor.
When the hand approaches the embedded sensor, the signal from the sensor is 2 square waves of 200 msec each. When the IR presence is removed from the viewing area, then a second set of square waves can be detected.
So our code should be framed by remembering this technical aspects. Then only we get desired results. This is the basic code of switching mechanism with relay
unsigned long PyroRead = 0;
int Pyro=5; // D1 of MCU
unsigned long IR_threshold = 200000;
int state=1; //Defining state of the device
int IR_sensed = 0;
int relay=16; //D0 of MCU
void setup() {
pinMode (relay, OUTPUT);
pinMode (Pyro,INPUT);
Serial.begin(9600);
}
void loop() {
while ((IR_sensed < 2))
{
PyroRead = pulseIn(Pyro, HIGH);
if(PyroRead > IR_threshold)
{
IR_sensed++;
}
}
digitalWrite(relay,state);
if(state==1)
{
Serial.println("HIGH");
}
if(state==0)
{
Serial.println("LOW");
}
state=1-state;
PyroRead = 0;
IR_sensed = 0;
delay(1000);
}
As soon as the program starts, i have given the threshold value as 200ms as per the specs. When the data coming from the sesnor is greater than this value, it will mark that as good trigger(that is IR_sensed becomes 1). When we get two good triggers from the sensor(when we introduce our hand in to the box), the program exits the while loop and make the relay ON. Then we need to change the state, by this piece of code. Then this process is repeated.
state=1-state;
Then all the variables are made zero and it will look for another triggers with a delay of one second. This code is enough for working in two modes.
Here i connected the SS-430 with the digital pin of MCU because the NodMCU only contains one analog pin. That is being used by the current sensor.
- ACS712 Sensor & SS-430 With Blynk:
The energy is monitored by the current sensor. I have used his techniques to calculate the energy consumption of the load connected. The sensor is connected to A0 of NodmMCU. This is the code used for calculating Rate.
int Sensor_Pin = A0;
unsigned int Sensitivity = 185; // 185mV/A for 5A, 100 mV/A for 20A and 66mV/A for 30A Module
float Vpp = 0; //peak to peak voltage
float Vrms = 0; // rms voltage
float Irms = 0; // rms current
float Supply_Voltage = 230.0;// As of your household supply
float Vcc = 3.0; // ADC reference voltage // voltage at 3V pin of MCU
float power = 0; // power in watt
unsigned long last_time =0;
unsigned long current_time =0;
unsigned int calibration = 100;
unsigned int pF = 85;//power factor
float Wh =0 ;
float bill_amount = 0;
unsigned int energyTariff = 5.0;//As per the rate of your country
void setup() {
pinMode(Sensor_Pin,INPUT);//sensor is connected to A0
Serial.begin(9600);
}
void loop() {
timer.run();
Vpp = getVPP();
Vrms = (Vpp/2.0) *0.707;
Vrms = Vrms - (calibration / 10000.0);
Irms = (Vrms * 1000)/Sensitivity ;
if((Irms > -0.015) && (Irms < 0.008)){ // remove low end chatter
Irms = 0.0;
}
power= (Supply_Voltage * Irms) * (pF / 100.0);
Serial.println(power);
last_time = current_time;
current_time = millis();
Wh = Wh+ power *(( current_time -last_time) /3600000.0) ; //calculating energy in Watt-Hour
bill_amount = Wh*(energyTariff/1000);
Serial.println(bill_amount);
}
float getVPP()
{
float result;
int readValue;
int maxValue = 0;
int minValue = 1024;
uint32_t start_time = millis();
while((millis()-start_time) < 950)
//read every 0.95 Sec
{
readValue = analogRead(Sensor_Pin);
if (readValue > maxValue)
{
maxValue = readValue;
}
if (readValue < minValue)
{
minValue = readValue;
}
}
result = ((maxValue - minValue) * Vcc) / 1024.0;
return result;
}
The rate for that energy consumption is also shown in the Blynk application(for that device only). The current state of the device is also shown lively in the application.
Note:This code is not as much accurate.
Let's explore the Blynk app
Blynk is a Platform with IOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. It’s a digital dashboard where you can build a graphic interface for your project by simply dragging and dropping widgets.
First download the Blynk app and signup in it. Then create a new project. Select the hadrware as Nodmcu. Give some proper name for the project. It's connection type is wifi. After creating the project the Auth Token will be sent to your mail id corresponding to the project. This Token should include in your code for working with the project. Please refer the screen shots below.
Add three widgets to the project.
1. Gauge display - for showing the bill amount
2. Labelled Value - for showing the state
3. Calibrate Slider - for calibrating
Assign the virtual pin and name as follows
Virtual Pin is a concept invented by Blynk Inc. to provide exchange of any data between hardware and Blynk mobile app. Virtual pins are different than Digital and Analog Input/Output (I/O) pins. They are physical pins on your microcontroller board where you connect sensors and actuators.
The final outlook will be like this.
We need to install the blynk libraries in the Arduino IDE for the proper communication with the NodMCU and the Blynk app. Just follow this tutorial to done it.
These are to be included in the code to work with blynk application
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
#define BLYNK_PRINT Serial
char auth[] = "XXXXXXXXXXX";//Token send to email
char ssid[] = "Xxxxxx";// Hotspot password
char pass[] = "xxxxx";// password of the hotspot
This piece of code should be included in the void setup to start the blynk app
Blynk.begin(auth, ssid, pass);
This should be included in the void loop to run the blynk app
Blynk.run();
virtualWrite is a function in blynk. By using the function we can easily update the value in the code to the blynk app. Here we are updating the variable bill_amount with the code
Blynk.virtualWrite(V1, bill_amount);
Updating the state of the device by
Blynk.virtualWrite(V2,"ON");
OR
Blynk.virtualWrite(V2,"OFF") ;
for calibrating the slider we will use this function
BLYNK_WRITE(V4) { // calibration slider
calibration = param.asInt();}
That's all about the Blynk app. Full code is given in the github repo. So upload that code in to the NodMCU and run the blynk app. Just go here to get more information about Blynk.
Circuit:Connect the components as per the schematics given below. I have used jumpers and copper wires for the connection. Here as a load i connected a bulb. Any device can be connected,that's up to you.
So i enclose my circuit in that switch board as shown below.
So i made holes for giving 230v and load connection.
The final version......
When we introduce the hand in the switchboard, the Kemet sensor detects the motion and it switches the bulb,via the relay. The state of the device is instantly streamed to the Blynk application through Nodmcu over wifi. When the device becomes off, the rate of energy consumption is calculated for that time period when the load being driven and is shown in the Blynk app. There is a slider in the Blynk app for calibrating the energy consumption,for the user.
The Rate for the energy consumed for that load in the Blynk app is shown below.
By incorporating more Kemet sensors,in the future we are increasing the mode capability of switching. In addition to Toggle and Push-button mode we are adding some extra modes. They are
- Selector Mode: It has some sort to select one of two or more positions(rotary mode)
- Joystick Mode: This mode is actuated to freely moving in more than one axis of motion.
Comments