
Ashish Adhikari
-
Posts
31 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Events
Posts posted by Ashish Adhikari
-
-
On 3/23/2018 at 4:36 PM, davidjackson said:
Impressive. It is not easy to charge the 150ah battery with solar panel directly. For proper charging using solar panel you just need to use a solar charge controller. You must also place the batteries in parallel connection for fast charge. Using solar charge controller avoid reverse current flow from Battery to a solar panel and unharmed pannels from burning. For proper charging your solar panel must create power more than 150w 150w is the threshold point for your charging. More the power added ……charging rate improve.
-
DRIVING A RELAY WITH AN ARDUINO
Hello everyone, welcome back to my channel. This is my 4th tutorial on how to drive a RELAY (not a relay module) with an Arduino.There are hundreds of tutorial available on how to use a "relay module" but I could not find a good one that shows how to use a Relay and not a Relay module. So, here we are to discuss how a relay works and how we can hook it up to an Arduino.Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipments and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This projects is not intended for use by children.Step 1: Basics
A Relay is a large mechanical switch, which is toggled on or off by energizing a coil.Depending on the operating principle and structural features relays are of different types, such as:1. Electromagnetic Relays2. Solid State Relays3. Thermal Relays4. Power Varied Relays5. Reed Relays6. Hybrid Relays7. Multi-dimensional Relays and so on, with varied ratings, sizes and applications.However, in this tutorial we will only be discussing about an electromagnetic relays.Guide to Different Types of Relays:Step 2: My Relay (SRD-05VDC-SL-C)
The relay I am looking at is a SRD-05VDC-SL-C. It is very popular relay among Arduino and DIY electronics hobbyists.This relay has 5 pins. 2 for the coil. Middle one is COM (common) and the rest of the two are called NO (Normally Open) and NC (Normally Close). When current flows through the coil of the relay, a magnetic field is created that causes a ferrous armature to move, either making or breaking an electrical connection. When the electromagnet is energized the NO is the one which is on and NC is the one which is off. When the coil is de-energized the electromagnetic force disappears and the armature moves back to the original position turning on the NC contact. The closing and releasing of the contacts results in powering on and off of the circuits.Now, if we look at the top of the relay the first thing we see is SONGLE, it is the name of the manufacturer. Then we see the "Current and Voltage Rating": it is the maximum current and/or voltage that can be passed through the switch. It starts from [email protected] and goes down till [email protected] Finally the bottom bit says: SRD-05VDC-SL-C SRD: is the model of relay. 05VDC: Also known as "Nominal Coil Voltage" or "Relay Activation Voltage", it is the voltage necessary for the coil to activate the relay.S: Stands for "Sealed Type" structureL: is the "Coil Sensitivity" which is 0.36WC: tells us about the contact formI have attached the datasheet of the relay for more information.http://old.ghielectronics.com/downloads/man/20084...Step 3: Getting Hands on a Relay
Let’s start by determining the relay coil pins.You can do it either by connecting a multimeter to resistance measuring mode with a scale of 1000 ohm (since the coil resistance normally ranges between 50 ohm and 1000 ohm) or by using a battery. This relay has 'no' polarity marked on it since the internal suppressing diode is not present in it. Hence, the positive output of DC power supply can be connected to any one of the coil pins while negative output of DC power supply will be connected to the other pin of the coil or vice versa. If we connect our battery to the right pins you can actually hear the *clicking* sound when the switch turns on.If you ever get confused in figuring out which one is NO and which one is NC pin, follow the steps below to easily determine that:- Set the multimeter to resistance measuring mode.- Turn the relay upside-down to see pins located at its bottom part.- Now connect one on the multimeter's probe to the pin in between the coils (Common Pin)- Then connect the other probe one by one to the remaining 2 pins.Only one of the pins will complete the circuit and will show activity on the multimeter.Step 4: Arduino and a Relay
* The question is "Why to use a relay with an Arduino?"A micro controller's GPIO (general purpose input/output) pins cannot handle higher power devices. A LED is easy enough, but large power items such as light bulbs, motors, pumps or fans required more sneaky circuitry. You can use a 5V relay to switch the 120-240V current and use the Arduino to control the relay.* A relay basically allows a relatively low voltage to easily control higher power circuits. A relay accomplishes this by using the 5V outputted from an Arduino pin to energize the electromagnet which in turn closes an internal, physical switch to turn on or off a higher power circuit. The switching contacts of a relay are completely isolated from the coil, and hence from the Arduino. The only link is by the magnetic field. This process is called "Electrical Isolation".* Now a question arises, Why do we need the extra bit of circuit to drive the relay? The coil of the relay needs a large current (around 150mA) to drive the relay, which an Arduino cannot provide. Therefore we need a device to amplify the current. In this project the NPN transistor 2N2222 drives the relay when the NPN junction gets saturated.Step 5: Hardware Requirement
For this tutorial we need:1 x Breadboard1 x Arduino Nano/UNO (Whatever is handy)1 x Relay1 x 1K resistor1 x 1N4007 High Voltage, High Current Rated Diode to protect the micro-controller from voltage spikes1 x 2N2222 General purpose NPN transistor1 x LED and a 220 ohm current limiting resistor to test the connectivityFew connecting cablesA USB cable to upload the code to the Arduinoand general soldering equipmentsStep 6: Assembly
* Lets start by connecting the VIN and GND pins of the Arduino to the +ve and -ve rails of the breadboard.* Then connect one of the coils pin to the +ve 5v rail of breadboard.* Next we need to connect a diode across the electromagnetic coil. The diode across the electromagnet conducts in the reverse direction when the transistor is turned off to protect against a voltage spike or the backward flow of current.* Then connect the Collector of the NPN transistor to the 2nd pin of the coil.* The Emitter connects to the -ve rail of the breadboard.* Final, using a 1k resistor connect the Base of the transistor to the D2 pin of the Arduino.* Thats it our circuit is complete, now we can upload the code to the Arduino to turn on or off the relay. Basically, when +5v flow through the 1K resistor to the Base of transistor, a current of about .0005 amps (500 microamps) flows and turns on the transistor. A current of about .07 amps starts flowing through the junction turning on the electromagnet. The electromagnet then pulls the switching contact and moves it to connect the COM terminal to the NO terminal.* Once the NO terminal is connected a Lamp or any other load can be turned on. In this example I am just turning on and off a LED.Step 7: The Code
The code is very simple. Just start by defining the digital pin number 2 of the Arduino as the Relay pin.Then define the pinMode as OUTPUT in the setup section of the code. Finally, in the loop section we are going to turn on and off the relay after every 500 CPU cycles by setting the Relay pin to HIGH and LOW respectively.Step 8: Conclusion
* Remember: It is very important to place a diode across the coil of the relay because a spike of voltage (inductive kickback from the coil) is generated (Electromagnetic Interference) when the current is removed from the coil due to the collapse of the magnetic field. This voltage spike can damage the sensitive electronic components controlling the circuit.* Most Important: Same as capacitors, we always under-rate the relay to mitigate the risk of relay failures. Lets say, you need to work at [email protected], don’t use a relay rated for [email protected], instead use a bigger one such as [email protected] Remember, power = current * voltage so a [email protected] relay can handle up to a 6,000W device.* If you just replace the LED with any other electrical device like fan, bulb, fridge etc., you should be able to turn that appliance into a smart device with an Arduino controlled power outlet.* Relay can also be used to turn on or off two circuits. One when the electromagnet is on and the second one when the electromagnet is off.* A Relay helps in Electrical Isolation. The switching contacts of a relay are completely isolated from the coil, and hence from the Arduino. The only link is by the magnetic field.Note: Short circuits on Arduino pins, or attempting to run high current devices from it, can damage or destroy the output transistors in the pin, or damage the entire AtMega chip. Often this will result in a "dead" pin of the micro-controller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors, unless maximum current draw from the pins is required for a particular applicationStep 9: Thanks
Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video. -
Introduction
----------------
Hi Friends,
I am back again with another Arduino based home automation project. This time I am trying to make my partner's life easy by installing a collision avoidance system in the garage to help her park the car safely without hitting the garage wall.
So, in this video, I am going to use an ultrasonic sensor to calculate the car's distance from the garage wall and display it using green, yellow and red LEDs. The color of LEDs indicates whether to keep moving, slow down, stop or go back.
The total cost of the project is around $20 - $25.
Step 1: Logic
The project has 3 phases
Phase 1: Waiting for the car In this phase the device keeps looking for a moving object within the sensors proximity. If an object enters the proximity then one of the three LEDs turns on based on how far the moving object is. If the object is way too close, then a noise is made to make the moving object aware of the distance.
Phase 2: No car in the garage If there is no object in the proximity then turn off all the LEDs.
Phase 3: The car has stopped moving (Parked in the right spot) If the object has stopped moving and is still in the proximity wait for 20 CPU cycles and then turn off the LEDs.
Step 2: Hardware Requirement
For this very simple project we need:
- A Perfboard
- An Arduino nano/uno (whatever is handy)
- A Red, Green and a Yellow LED (Light Emitting Diode)
- 3 x 220ohm resistor for the LEDs
- One HC-SRO4 Ultrasonic Sensor
- A Buzzer shield or A buzzer and a 100 ohm resistor
- A 220v AC to 5v DC Buck step-down module
- One Female Pin Header Strip
- An Ethernet cable
- Some connecting cables
- A USB cable to upload the code to the Arduino
- and general soldering equipments
Step 3: Assembly
Let start by connecting the LEDs to the board.
Connect the Red LED to pin D2, Yellow LED to D3 and the Green LED to D4 of the Arduino by putting in a 220ohm resistor between the Arduino board and the LEDs. Now lets connect the Buzzer to analogue pin A0. Next, connect the Trig pin of the Ultrasonic Sensor to D5 and the Echo pin to D6 of the Arduino. Once all the modules are connected to the Arduino board, its time for us to connect all the positive and negative pins together. Connect all the positive pins of the modules to the +5v supplied by the Buck Step-Down Module and the negative pins to the -ve terminal of the Module. That's it, we can now upload our sketch to the board.
In this assembly I am using 3 LEDs to display the distance, however you can replace the 3 LEDs with a RGB LED, or you can also use an array of LEDs like an audio level indicator to display the movement of the car.
Step 4: My Setup
OK now lets see what I have made.
I have installed the Arduino, buzzer, the ultrasonic sensor and the three 220 ohms resistors on one Perfboard. The 3 LEDs and the power module is installed on a second Perfboard. I will be covering the LEDs with a translucent cover to give it a nice look.
The 220v power supply will be connected to the screw terminal block. The base unit will then be connected to the LEDs and the power supply with an Ethernet cable.
Step 5: The Code
int trigPin = PD5; // Sensor Trip pin connected to Arduino pin D5 int echoPin = PD6; // Sensor Echo pin connected to Arduino pin D6 int redLED = PD2; // Red LED connected to pin D2 int yellowLED = PD3; // Yellow LED connected to pin D3 int greenLED = PD4; // Green LED connected to pin D4 int buzzer = A0; // Buzzer connected to Analogue pin A0 long TempDistance = 0; // A variable to store the temporary distance int counter = 0; // Counter value to check if the object has stopped moving void setup() { Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(buzzer, OUTPUT); } void loop() { long duration, Distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); Distance = (duration/2) / 74; // Distance in Inches if(counter < 20){ // Do the rest if the car is still moving if (Distance > 200) { // Nothing in the garrage turnThemAllOff(); } if ((Distance > 55) && (Distance <= 200)) { // Turn on Green LED digitalWrite(greenLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(redLED, LOW); noTone(buzzer); } if ((Distance > 15) && (Distance <= 55)) { // Turn on Yellow LED digitalWrite(yellowLED, HIGH); digitalWrite(redLED, LOW); digitalWrite(greenLED,LOW); noTone(buzzer); } if (Distance <= 15) { // Turn on Red LED digitalWrite(redLED, HIGH); digitalWrite(greenLED,LOW); digitalWrite(yellowLED, LOW); noTone(buzzer); } if (Distance < 8) { // Item is way to close - start the buzzer tone(buzzer, 500); } } if ((Distance == TempDistance) || ((Distance+1) == TempDistance) || ((Distance-1) == TempDistance)){ if(counter >= 20){ // Turn off the lights if the object hasn't moved for 20 cycles (no change in distance) Serial.println("No movement detected, turning off the lights"); turnThemAllOff(); } else { counter++; } } else { counter = 0; // Reset counter if there is a movement } TempDistance = Distance; Serial.print(Distance); Serial.println(" inches"); Serial.print("Counter : "); Serial.println(counter); delay(500); } // Function to turn the LEDs off void turnThemAllOff(){ digitalWrite(redLED, LOW); digitalWrite(greenLED,LOW); digitalWrite(yellowLED, LOW); noTone(buzzer); }
Start the code by defining the constants and the global variables that will be used throughout the code.
Then define the pin modes in the setup section of the code.
Then create a function to turn off all the LEDs and the buzzer.
Now, calculate the "Distance" in inches by reading the values received from the Ultrasonic Sensor.
Then by checking the value of the "Distance" we will turn on and off the LEDs based on how far the object is. If the distance is greater than 200 then turn off all the LEDs and the buzzer as the object is out of range. Else if it is between 55 and 200 then turn on the green LED. If the object is between 15 and 55 then turn on the yellow LED, and if the object goes closer than 15 inches then turn on the red LED until it reaches 8 inches. When the distance becomes less than 8 start the buzzer along with the red LED.
Next bit of the code is to set the value of the counter based on the cars movement which then decides when to turn off the LEDs. It compares the value of "Distance" with the "TempDistance" and if the values are same (object hasn't moved) then increments the counter. If the object moves any-time during this process the counter is reset to 0. Finally the "TempDistance" is set to the value of "Distance".
Just before comparing the Distances we also need to check if the counter value has exceed 20. I am doing this to stop the below code from executing if the car is in a steady position.
Lastly we just need to add a small delay to our sketch to pause the code for a while.
Step 6: Quick Demo
So this is how I have installed the unit in my garage.
As I walk close to the sensor the light changes from green to yellow to red and ultimately the buzzer goes on when I am too close to the sensor. In my case I have installed the buzzer next to the Arduino however I will recommend you to install the buzzer along with the LEDs. If you want you can also flash the red LED when the buzzer goes on.
So now, my partner can park the car easily without making any assumptions. Doesn't matter how many times she fail her driving test she is not going to break my wall (even when she is drunk). Not that I am asking her to drive when she is drunk (just kidding).
Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video.
-
Introduction
---------------
Hi Everyone, This is my 1st Arduino's tutorial video. In this video i am going to show you how to use a LDR or Light Dependent resistor to turn on and off another circuit or a LED.
Wouldn’t it be really cool if whenever a room gets dark, a light bulb automatically turns ON and eliminates the darkness? In this very simple project, I am focusing on eliminating darkness. You can even use this as an emergency lighting system.
Step 1: Principle
The LDR is a special type of resistor which allows a lower voltage to pass through it (high resistance) whenever its dark and higher voltages to pass (low resistance) whenever there is a high intensity of light.
We are going to use a 10k resistor along with the LDR to create a voltage divider circuit. The varying resistance of the LDR is converted to a varying voltage that the analog pin of the Arduino will then be using in its logic.
Step 2: Harware Reqirement
For this very simple DIY Arduino project we need:
- a breadboard
- an arduino uno/nano (whatever is handy)
- LED (Light Emitting Diode)
- LDR (Photoresistor)
- A 10K Resistor for creating the voltage divider and a 220ohm resistor for the LED
- Few breadboard friendly connecting wires
- and a USB cable to upload the code to the Arduino
Step 3: Assembly
- Connect the 3.3v output of the Arduino to the positive rail of the breadboard
- Connect the ground to the negative rail of the breadboard
- Place the LDR on the breadboard
- Attach the 10K resistor to one of the legs of the LDR
- Connect the A0 pin of the Arduino to the same column where the LDR and resistor is connected (Since the LDR gives out an analog voltage, it is connected to the analog input pin on the Arduino. The Arduino, with its built-in ADC (Analog to Digital Converter), then converts the analog voltage from 0-5V into a digital value in the range of 0-1023). - Now connect the other end of the 10K resistor to the negative rail - And the the second (free) leg of the LDR to the positive rail
Pretty much this is what we need for the light sensing. Basic circuits like this can be done without an Arduino aswell. However, if you want to log the values and use it to create charts, run other logics etc. I will recomend an Arduino or ESP8266 or may be a ESP32 for this.
Now, as we want our circuit to do something in the real world other than just displaying the values on the computer screen we will be attaching a LED to the circuit. The LED will turn on when its dark and will go off when its bright. To achieve this we will:
- Place the LED on the breadboard
- Connect the 220ohm resistor to the long leg (+ve) of the LED
- Then we will connect the other leg of the resistor to pin number 13 (digital pin) of the Arduino
- and the shorter leg of the LED to the negative rail of the breadboard
Step 4: The Code
const int ledPin = 13; const int ldrPin = A0; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(ldrPin, INPUT); } void loop() { int ldrStatus = analogRead(ldrPin); if (ldrStatus <= 200) { digitalWrite(ledPin, HIGH); Serial.print("Its DARK, Turn on the LED : "); Serial.println(ldrStatus); } else { digitalWrite(ledPin, LOW); Serial.print("Its BRIGHT, Turn off the LED : "); Serial.println(ldrStatus); } }
Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next Instructable.
-
Hi Everyone,
In this tutorial I am going to show you how to charge a Lithium 18650 Cell using TP4056 chip utilizing the solar energy or simply the SUN.
Wouldn’t it be really cool if you can charge your mobile phones battery using the sun instead of a USB charger. You can also use this project as a DIY portable power bank.
The total cost of this project excluding the battery is just under $5. The battery will addup another $4 to $5 bucks. So the total cost of the project is some what around $10. All components are available on my website for sale for really good price, the link is in the description below.
Step 1: Hardware Requirement
For this project we need:
- A 5v Solar Cell (make sure it is 5v and not anything less than that)
- A general purpose circuit board
- A 1N4007 High Voltage, High Current Rated Diode (for reverse voltage protection). This diode is rated at forward current of 1A with peak reverse voltage rating of 1000V.
- Copper Wire
- 2x PCB Screw Terminal Blocks
- A 18650 Battery Holder
- A 3.7V 18650 Battery
- A TP4056 battery protection board (with or without the protection IC)
- A 5 V power booster
- Some connecting cables
- and general soldering equipments
Step 2: How the TP4056 Work
Looking at this board we can see that it has the TP4056 chip along with few other components of our interest.
There are two LEDs on board one red and one blue. The red one comes on when it is charging and the blue one comes on when the charging is done. Then there is this mini USB connector to charge the battery from an external USB charger. There are also these two points where you can solder your own charging unit. These points are marked as IN- and IN+ We will be utilizing these two point to power this board. The battery will be connected to these two point marked as BAT+ and BAT- (pretty mush self explanatory) The board requires an input voltage of 4.5 to 5.5v to charge the batteryThere are two versions of this board available in the market. One with battery discharge protection module and one without it. Both boards offer 1A charging current and then cut off when finished.
Furthermore, the one with protection switches the load off when the battery voltage drops below 2.4V to protect the cell from running at too low (such as on a cloudy day) - and also protects against over-voltage and reverse polarity connection (it will usually destroy itself instead of the battery) however please check you have it connected correctly the first time.
Step 3: Copper Legs
These boards gets really hot so I will be soldering them a bit above the circuit board.
To achieve this I am going to use a hard copper wire to make legs of the circuit board. I will then be sliding the unit on the legs and will solder them all together. I will put 4 copper wires to make 4 legs of this circuit board. You can also use - Male Breakable Pin Headers instead of the copper wire to achieve this.
Step 4: Assembly
The assembly is very simple.
The solar cell is connected to the TP4056 battery charging board's IN+ and IN- respectively. A diode is inserted at the positive end for the reverse voltage protection. Then the BAT+ and BAT- of the board is connected to the +ve and -ve ends of the battery. (That all we need for charging the battery). Now to power an Arduino board we need to boost up the output to 5v. So, we are adding a 5v voltage booster to this circuit. Connect the -ve end of the battery to the IN- of the booster and +ve to IN+ by adding a switch in between. OK, now lets have a look at what I have made. - I have connected the booster board straight to the charger however I will recommend putting a SPDT switch there. So when the device is charging the battery its only charging and not getting used
Solar cells are connected to the input of the lithium battery charger (TP4056), whose output is connected to the 18560 lithium battery. A 5V step-up voltage booster is also connected to the battery and is used to convert from 3.7V dc to 5V dc.
Charging voltage is typically around 4.2V. Voltage booster's input ranges from 0.9 to 5.0V. So it will see around 3.7V at it's input when the battery is discharging, and 4.2V when it's recharging. The output of the booster to the rest of the circuit will keep it's 5V value.
Step 5: Testing
This project will be very helpful to power a remote data logger. As we know, the power supply is always a problem for a remote logger and most of the times there is no power outlet available. A situation like that forces you to use some batteries to power your circuit. But eventually, the battery will die. Question is do you want to go there and charge the battery? Our inexpensive solar charger project will be an excellent solution for a situation like this to power an Arduino board.
This project can also solve the efficiency issue of Arduino when in sleep. Sleep saves battery, however, the sensors and power regulators (7805) will still consume battery in idle mode draining the battery. By charging the battery as we use it, we can solve our problem.
Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video.
PIR SENSOR TUTORIAL - WITH OR WITHOUT ARDUINO
in Electronic Projects Design/Ideas
Posted
Step 1: Basic
Step 2: Hardware
For this tutorial we need:
Step 3: Architecture
Step 4: Connecting Without Arduino
Step 5: Connecting With Arduino
Step 6: Code
Step 7: Areas of Application of PIR Sensors
Step 8: Demo