• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Get free circuit help 24/7

New Projects | Privacy Policy | About us | Contact | Disclaimer | Copyright | Videos 

You are here: Home / Home Electrical Circuits / Ultrasonic Smart Automatic ON/OFF Switch Circuit

Ultrasonic Smart Automatic ON/OFF Switch Circuit

Last Updated on November 7, 2019 by Swagatam 13 Comments

In this article we are going to build a smart automatic ON/OFF switch using Arduino, which can turn on or off gadgets automatically by sensing the presence of human nearby through the concept of ultrasonic.

We are going to use ultrasonic module and Arduino to sense the presence of human which activates the gadgets such as table lamp or table fan.

We sometimes forget to turn off the lights or fan while leaving home, at the middle of a trip; we’ll realize that we forgot to turn off “something”. This is enough to ruin our joyful trip. But some don’t even realize it; the energy gets wasted until we return to home.

In this project we are concentrating on gadgets which we use frequently such as table lamps/ table fan and other gadgets, where we sit and move frequently. Leaving these gadgets on for long period may lead to potential energy and money loss.

The Design:

The heart and brain of this smart automatic ON/OFF switch using Arduino is an ultrasonic module, and arduino respectively. The ultrasonic module senses the presence of human, but the ultrasonic module can’t differentiate between a human and an obstacle such as chair in front of the table. Therefore in order to enable this feature we are going to set a threshold distance between the sensor and human.

The distance between the sensor and an object will reduce when new obstacle comes in between them such a human. If Arduino detects the distance between two object the set level goes below the threshold value and this triggers the relay.

When the person moves out of the threshold range it turns off the relay.

caution electricity can be dangerous

The above diagram illustrates the triggering of the relay in the presence of human, since Arduino detected the distance below the threshold value.

The above diagram illustrates that relay is held switched off in the absence of human, since the arduino continues to detect the distance above threshold value.

The program is written in such a way that it measures the distance between the sensor and obstacle in real time.

The users need to input the threshold value in centimeter before uploading to arduino.

How it Works

Ultrasonic Smart Automatic ON/OFF Switch Circuit

The ultrasonic sensor can be directly inserted on analog pins from A0 to A3, sensors facing outward, this may reduce wire congestion while prototyping the circuit.

 

NOTE: #PIN 7 is the output to relay

//--------------------Program developed by R.Girish-------------------//
const int trigger = A1;
const int echo = A2;
int vcc = A0;
int gnd = A3;
int OP = 7;
long Time;
float distanceCM;
float distance = 15;  // set threshold distance in cm
float resultCM;
void setup()
{
pinMode(OP,OUTPUT);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
pinMode(vcc,OUTPUT);
pinMode(gnd,OUTPUT);
}
void loop()
{
digitalWrite(vcc,HIGH);
digitalWrite(gnd,LOW);
digitalWrite(trigger,LOW);
delay(1);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
Time=pulseIn(echo,HIGH);
distanceCM=Time*0.034;
resultCM=distanceCM/2;
if(resultCM<=distance)
{
digitalWrite(OP,HIGH);
delay(4000);
}
if(resultCM>=distance)
{
digitalWrite(OP,LOW);
}
delay(10);
}
//-----------------Program developed by R.Girish-------------------//

NOTE:

In the program replace the value 15 with your distance between the sensor and table’s edge + 7 to 10cm.

float distance = 15; // set threshold distance in cm

For example: if the distance between sensor and table is 100cm, add 7 to 10 cm more and place the value. The values are in centimeter. It may take up to 4 seconds to turn off the relay after the person moved away from the sensor’s range.

You'll also like:

  • 1.  Using Triacs for Controlling Inductive Loads
  • 2.  Ultrasonic Fuel Level Indicator Circuit
  • 3.  Simple Hobby Circuit Projects
  • 4.  Automatic Voltage Regulator (AVR) Circuit
  • 5.  Natural Mosquito Repellent Using High Watt Resistor
  • 6.  Making a “Helping Third Hand” for Aiding Soldering Jobs

About Swagatam

I am an electronic engineer (dipIETE ), hobbyist, inventor, schematic/PCB designer, manufacturer. I am also the founder of the website: https://www.homemade-circuits.com/, where I love sharing my innovative circuit ideas and tutorials.
If you have any circuit related query, you may interact through comments, I'll be most happy to help!

Have Questions? Please Comment below to Solve your Queries! Comments must be Related to the above Topic!!

Subscribe
Notify of
13 Comments
Newest
Oldest
Inline Feedbacks
View all comments

Primary Sidebar

Categories

  • 3-Phase Power (15)
  • 324 IC Circuits (19)
  • 4017 IC Circuits (52)
  • 4060 IC Circuits (26)
  • 555 IC Circuits (99)
  • 741 IC Circuits (20)
  • Arduino Engineering Projects (83)
  • Audio and Amplifier Projects (115)
  • Battery Chargers (83)
  • Car and Motorcycle (94)
  • Datasheets (73)
  • Decorative Lighting (Diwali, Christmas) (33)
  • Electronic Components (101)
  • Electronic Devices and Circuit Theory (36)
  • Electronics Tutorial (120)
  • Fish Aquarium (5)
  • Free Energy (34)
  • Fun Projects (13)
  • GSM Projects (9)
  • Health Related (20)
  • Heater Controllers (29)
  • Home Electrical Circuits (103)
  • How to Articles (20)
  • Incubator Related (6)
  • Industrial Electronics (28)
  • Infrared (IR) (40)
  • Inverter Circuits (98)
  • Laser Projects (12)
  • LED and Light Effect (93)
  • LM317/LM338 (21)
  • LM3915 IC (25)
  • Meters and Testers (66)
  • Mini Projects (149)
  • Motor Controller (67)
  • MPPT (7)
  • Oscillator Circuits (26)
  • PIR (Passive Infrared) (8)
  • Power Electronics (34)
  • Power Supply Circuits (79)
  • Radio Circuits (10)
  • Remote Control (48)
  • Security and Alarm (62)
  • Sensors and Detectors (121)
  • SG3525 IC (5)
  • Simple Circuits (75)
  • SMPS (29)
  • Solar Controllers (61)
  • Timer and Delay Relay (53)
  • TL494 IC (5)
  • Transformerless Power Supply (8)
  • Transmitter Circuits (41)
  • Ultrasonic Projects (16)
  • Water Level Controller (45)

Calculators

  • AWG to Millimeter Converter
  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator

© 2023 · Swagatam Innovations

wpDiscuz