June 05, 2020

PIR Sensor Interfacing with Arduino

PIR stands for Passive Infrared Radiation. PIR sensors are more complicated than many of the other sensors explained in these tutorials because there are multiple variables that affect the sensor's input and output. To begin explaining how a basic sensor works, we'll use this rather nice diagram.

PIRs are basically made of a pyroelectric sensor (which you can see below as the round metal can with a rectangular crystal in the center),
which can detect levels of infrared radiation. Everything emits some low-level radiation, and the hotter something is, the more radiation is emitted. The sensor in a motion detector is actually split into two halves. The reason for that is that we are looking to detect motion (change), not average IR levels. The two halves are wired up so that they cancel each other out. If one half sees more or less IR radiation than the other, the output will swing high or low.
The second important thing is the lens of the sensor. PIR sensors are rather generic and for the most part, vary only in price and sensitivity. Most of the real magic happens with the optics. This is a pretty good idea for manufacturing: the PIR sensor and circuitry is fixed and costs a few dollars. The lens costs only a few cents and can change the breadth, range, sensing pattern, very easily. In the diagram up top, the lens is just a piece of plastic, but that means that the detection area is just two rectangles. Usually, we'd like to have a detection area that is much larger. To do that, we use a simple lens such as those found in a camera: they condense a large area (such as a landscape) into a small one (on film or a CCD sensor). For reasons that will be apparent soon, we would like to make the PIR lenses small and thin and moldable from cheap plastic, even though it may add distortion. For this reason, the sensors are actually Fresnel lenses:
proximity_frenelling.jpg
OK, so now we have a much larger range. However, remember that we actually have two sensors, and more importantly, we don't want two really big sensing-area rectangles, but rather a scattering of multiple small areas. So what we do is split up the lens into multiple sections, each section of which is a fresnel lens.
To interface, this module all you have to do is to read the OUT pin signal with Aduino's digital pin using the digitalRead(DataPin) function frequently and if there is any signal keep the output high.
Pinout:
  • VCC supplies power for the module. You can directly connect it to the 5V pin on the Arduino.
  • DATA pin logical voltage changes from 0 or 5 Volt with the pH value.
  • GND is the Ground Pin and needs to be connected to the GND pin on the Arduino.
Connecting This device with Arduino is very easy. VCC pin goes to Arduino 5v pin GND pin goes to Arduino Ground Pin and the OUT pin goes to Arduino D2 pin.

Circuit Diagram:


Video Example:

Software:
Interfacing part Only

Introduction to ESP-01

ESP-01 Module is basically a low-cost esp8266 module, with built-in WIFI. It was created as an Arduino WIFI module but it can also be programmed to work as standalone. Although this module is cheap but working with it is a little difficult. As it is not a breadboard-friendly module it would be a bad choice for a beginner.

Less I/O pins make it a little difficult to use in standalone mode in projects. It has 8 pins.

  • Pin1: Ground Pin
  • Pin2: GPIO2 Pin 
  • Pin3: GPIO0 Pin
  • Pin4: RXD is UART data receive pin.
  • Pin5: Vcc is for powering the Module. Only 3.3V power is required.
  • Pin6: RST is for external reset. It's active Low in nature.
  • Pin7: CH_PD is an active-high pin for Chip enable.
  • Pin8: TXD is UART data send pin.
Programming this module is a little difficult as it does not have any type of connector. Although programming can be done using Jumper Wires, NodeMCU and Arduino IDE.

Get the Datasheet from the link below:

January 24, 2020

pH Sensor Interface With Arduino

In chemistry, pH is a scale used to specify how acidic or basic a water-based solution is. Acidic solutions have a lower pH, while basic solutions have a higher pH. At room temperature (25°C or 77°F), pure water is neither acidic nor basic and has a pH of 7.
Here is a chart of different pH of different items.
This tutorial is about the interfacing of the Analog pH sensor with Arduino Nano. Then we display the data using a serial terminal.

What is an analog pH sensor?
Analog pH meter is specifically designed to measure the pH of the solution and reflect the acidity or alkalinity. It is commonly used in various applications such as aquaponics, aquaculture, and environmental water testing.
The sensor signal from the sensor goes to a circuit board that converts the signal to a (0-5) V analog signal easily readable from the Arduino board. All we have to do is to put the analog signal to any Analog pin of the Arduino (Arduino Nano in my case) and read the voltage using ADC.


Pinout:
  • VCC supplies power for the module. You can directly connect it to the 5V pin on the Arduino.
  • Data pin voltage varies from (0-5) Volt with the pH value.
  • GND is the Ground Pin and needs to be connected to the GND pin on the Arduino.
Connecting This device with Arduino is very easy. VCC pin goes to Arduino 5v pin GND pin goes to Arduino Ground Pin and the OUT pin goes to Arduino A0 pin.


Software:



Temperature Measuring Device

OLED and Digital Temperature Sensor(DS18B20) With Arduino.
In the previous section, we interfaced OLED with Arduino and Digital Temperature Sensor (DS18B20) with Arduino separately. Now we are going to merge them together to make a temperature measuring device powered by a standard 5 Volt power supply or a power bank.


Items required:

  • Arduino Nano
  • OLED Display
  • Digital Temperature Sensor (DS18B20)
  • Vero Board
  • Female Header
  • Terminal Block
  • 4.7k Resistance
  • Jumper Wire

Circuit Diagram:

Video Example:

Software:

January 12, 2020

Digital Temperature Sensor (DS18B20) Iterface with Arduino

This project is about the interfacing of a DS18B20 module with Arduino UNO. The data for temperature is displayed on the Serial Terminal and on the next phase we will display the data on OLED Display.

What is Digital Temperature Sensor?

Digital Temperature Sensor(DS18B20) has two parts one measures the data another very basic chip inside that does some analog to digital conversion and spits out a digital signal with the temperature. The digital signal is fairly easy to read using any microcontroller.
Pinout:
  • VCC supplies power for the module. You can directly connect it to the 5V pin on the Arduino.
  • Data pin transmits the temperature and humidity data in digital form.
  • GND is the Ground Pin and needs to be connected to the GND pin on the Arduino.
To connect this sensor to Arduino first we have to include two libraries specially designed for this sensor OneWire.h, DallasTemperature.h
Then its time to tell the Arduino in which pin the sensor is connected. For this, we use this code OneWire oneWire(ONE_WIRE_BUS);
Now we have to tell the Arduino what sensor it is, for this we use DallasTemperature sensors(&oneWire);
Finally, we have to start the library by sending sensors.begin();
Then we have to ask the ic to send the temperature by sensors.requestTemperatures();
We can store the temperature in a variable by int temp = sensors.getTempCByIndex(0); 0 (Zero) stands for the first sensor, we can connect more than one sensor in one pin.

After connecting please double-check the connections before powering up the Arduino.












DS18B20 Sensor Library

Functions under this library
sending sensors.begin(); --------------------- Starts the library 
sensors.requestTemperatures(); ------------ Requestes for the reading
sensors.getTempCByIndex(0); -------------- Gives the value of temperature.

Video Example:


LCD Display Interface with Arduino

LCD Stands for Liquid Crystal Display. A liquid-crystal display is a flat-panel display, electronically modulated optical device that uses the light-modulating properties of liquid crystals combined with polarizers. Liquid crystals do not emit light directly, it works using a backlight or reflector to produce images in color or monochrome.



The LCD we are going to discuss is Arduino Interfaceble display modules. They have size variety like 16x2, 20x4 and many more but the working process is the same for almost every one of them. But the price increases with the display capacity.
These Displays have different colors too. Color varies with the backlight. Blue ones are a little different actually. they are called  Inverted displays. No Matter what size or color it has all of them work just like the same even all of them have the same pin configuration.
All of them have 16 Pins. A list of them is given here. These LCDs are loaded with a table where all the characters are stored. All we have to tell it which character to display and where to display that's all.
Let's skip the theory and go to the interfacing part. As we have limited pin in Arduino we will be using the 4bit mode of this led. In 4bit mode, we use only 4 pin D4-D7 of the LCD data bus. 

What to Do?

Hardware part:
Connect the LCD pins accordingly. For this purpose, a connection diagram is given. Once the connection is done recheck the wiring and connect the Arduino to the computer.

Software part:
Arduino has a header file named LiquidCrystal.h which takes care of all the things. We just need to include this header in our program. 
The next step is to tell the Arduino in which pin the LCD is connected for that purpose we use this line LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Now as we have said the pins, we have to tell the controller to start the LCD with the capacity of the LCD. Here we are using a 16x2 LCD so we wrote lcd.begin(16, 2);. 
This is time to tell the LCD to display what we want it to display. In my case its "hello, world!" we the command for this is, lcd.print("hello, world!");


  • Comes with Arduino IDE
Software:

  • Coming Soon







December 31, 2019

Ultrasonic Sensor Interface With Arduino

In this project, we will introduce you to the HC-SR04 Ultrasonic sensor. It works by sending sound waves from the transmitter, which then bounce off of an object and then return to the receiver. You can determine how far away something is by the time it takes for the sound waves to get back to the sensor. Let's get right to it!


This project is about the interfacing of an Ultrasonic Sensor module with Arduino UNO. This Project could measure the distance from a 2-400cm distance by using sound wave at 40000hz.


Components Required:
1.     Arduino Uno
2.     HC-SR04 Ultrasonic module
3.     Data Cable
4.     Jumper wires

How Ultrasonic sensor works?
First, the transmitter sends an ultrasonic wave that reflects from an abject nearby. When the sound waves hit the receiver, it turns the Echo pin high for however long the waves were traveling for. To get that, we can use a handy Arduino function called pulseIn(). It takes 2 arguments, the pin you are listening to(In our case, the Echo pin), and a state(HIGH or LOW). What the function does is waits for the pin to go whichever state you put in, starts timing, and then stops timing when it switches to the other state. In our case, we would put HIGH since we want to start timing when the Echo pin goes high. We will store the time in the duration variable. (It returns the time in microseconds)

Now that we have the time, we can use the equation speed = distance/time, but we will make it time x speed = distance because we have the speed. What speed do we have? The speed of sound, of course! The speed of sound is approximately 340 meters per second, but since the pulseIn() function returns the time in microseconds, we will need to have a speed in microseconds also, which is easy to get. A quick Google search for "speed of sound in centimeters per microsecond" will say that it is .0343 c/μS. You could do the math, but searching for it is easier. Anyway, with that information, we can calculate the distance! Just multiply the duration by .0343 and then divide it by 2 (Because the sound waves travel to the object AND back). We will store that in the distance variable.

How To Use?
In order to generate the ultrasound, you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm, we need to multiply the received travel time value from the echo pin with the velocity of sound and divide it by 2.

     distance = (velocity of sound x time)/2

     velocity of sound = 0343 cm/μS;
     
Pinout:

  • VCC supplies power for the module. You can directly connect it to the 5V pin on the Arduino.
  • GND is the Ground Pin and needs to be connected to the GND pin on the Arduino.
  • Trig 
  • Echo 
HC-SR04-sensor-library
coming soon

Functions under this library
coming soon

Video Example:
coming soon

SOFTWARE:
coming soon