Arduino (Atmega 328P)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

ARDUINO (ATMEGA 328P)

Figure 3.2 Aurdino

The Atmel AVR® core combines a rich instruction set with


32 general purpose working registers. All the 32 registers are
directly connected to the Arithmetic Logic Unit (ALU),
allowing two independent registers to be accessed in a single
instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving
throughputs up to ten times faster than conventional CISC
microcontrollers. The ATmega328/P provides the following
features: 32Kbytes of In-System Programmable Flash with
Read-While-Write capabilities, 1Kbytes EEPROM, 2Kbytes
SRAM, 23 general purpose I/O lines, 32 general purpose
working registers, Real Time Counter (RTC), three flexible
Timer/Counters with compare modes and PWM, 1 serial
programmable USARTs , 1 byte-oriented 2-wire Serial
Interface (I2C), a 6- channel 10- bit ADC (8 channels in
TQFP and QFN/MLF packages) , a programmable Watchdog
Timer with internal Oscillator, an SPI serial port, and six
software selectable power saving modes.

This allows very fast start-up combined with low power


consumption. In Extended Standby mode, both the main
oscillator and the asynchronous timer continue to run. Atmel
offers the QTouch® library for embedding capacitive touch
buttons, sliders and wheels functionality into AVR
microcontrollers. The patented charge-transfer signal
acquisition offers robust sensing and includes fully debounced
reporting of touch keys and includes Adjacent Key
Suppression® (AKS™) technology for unambiguous
detection of key events. The easy-to-use Q Touch Suite
toolchain allows you to explore, develop and debug your own
touch applications. The device is manufactured using Atmel’s
high density non-volatile memory technology. The On-chip
ISP Flash allows the program memory to be reprogrammed
In-System through an SPI serial interface, by a conventional
non-volatile memory programmer, or by an On-chip Boot
program running on the AVR core.

Pin diagram of ATMEGA328

The ATmega328/P is supported with a full suite of program


and system development tools including: C Compilers, Macro
Assemblers, and Program Debugger/Simulators, In-Circuit
Emulators, and Evaluation kits. Below figure 3.2.1 pin
diagram of ATMEGA328.
FEATURES OF ATMEGA328

28-pin AVR Microcontroller

Flash Program Memory: 32 kilo bytes

EEPROM Data Memory: 1 kilo bytes

SRAM Data Memory: 2 kilo bytes

I/O Pins: 23

Timers: Two 8-bit / One 16-bit

A/D Converter: 10-bit Six Channel

PWM: Six Channels


RTC: Yes with Separate Oscillator

MSSP: SPI and I²C Master and Slave Support

USART: Yes

External Oscillator: up to 20MHz

ADVANTAGES/ IMPROVEMENTS IN ATMEGA328

Still runs on 5 V, so legacy 5 V stuff interfaces cleaner

Even though it's 5 V capable, newer parts can run to 1.8 V.


This wide range is very rare.

Nice instruction set, very good instruction throughput


compared to other processors (HCS08, PIC12/16/18).

High quality GCC port (no proprietary crappy compilers!)

"PA" variants have good sleep mode capabilities, in micro-


amperes.

Well rounded peripheral set

Q Touch capability

Pin Descriptions table

VCC

Digital supply voltage.


GND

Ground.

Port B (PB [7:0]) XTAL1/XTAL2/TOSC1/TOSC2

Port B is an 8-bit bi-directional I/O port with internal pull-up


resistors (selected for each bit). The Port B output buffers
have symmetrical drive characteristics with both high sink and
source capability. As inputs, Port B pins that are externally
pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a
reset condition becomes active, even if the clock is not
running.
Depending on the clock selection fuse settings, PB6 can be
used as input to the inverting Oscillator amplifier and input to
the internal clock operating circuit.

Depending on the clock selection fuse settings, PB7 can be


used as output from the inverting Oscillator amplifier.

If the Internal Calibrated RC Oscillator is used as chip clock


source, PB [7:6] is used as TOSC [2:1] input for the
Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set.

Port C (PC [5:0])


Port C is a 7-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). The PC [5:0] output buffers
have symmetrical drive characteristics with both high sink and
source capability. As inputs, Port C pins that are externally
pulled low will source current if the pull-up resistors are
activated. The Port C pins are tri-stated when a reset condition
becomes active, even if the clock is not running.

PC6/RESET

If the RSTDISBL Fuse is programmed, PC6 is used as an I/O


pin. Note that the electrical characteristics of PC6 differ from
those of the other pins of Port C.

If the RSTDISBL Fuse is unprogrammed, PC6 is used as a


Reset input. A low level on this pin for longer than the
minimum pulse length will generate a Reset, even if the clock
is not running. Shorter pulses are not guaranteed to generate a
Reset.

The various special features of Port ‘C’ are elaborated in the


Alternate Functions of Port C

section.

Port D (PD [7:0])


Port D is an 8-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). The Port D output buffers
have symmetrical drive characteristics with both high sink and
source capability. As inputs Port D pins that are externally
pulled low will source current if the pull-up resistors are
activated. The Port D pins are tri-stated when a reset condition
becomes active, even if the clock is not running.

AVCC

AVCC is the supply voltage pin for the A/D Converter, PC


[3:0], and PE [3:2]. It should be externally connected to VCC,
even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter. Note that PC
[6:4] use digital supply voltage, VCC.

Arduino Uno Board Description

We will learn about the different components on the Arduino


board. We will study the Arduino UNO board because it is the
most popular board in the Arduino board family. In addition,
it is the best board to get started with electronics and coding.
Some boards look a bit different from the one given below
figure 3.2.2, but most Arduinos have majority of these
components in common.
Arduino board can be powered by using the USB cable from
computer. All we need to do is connect the USB cable to the
USB connection (1).

Power (Barrel Jack)


Arduino boards can be powered directly from the AC mains
power supply by connecting it to the Barrel Jack.

Voltage Regulator

The function of the voltage regulator is to control the voltage


given to the Arduino board and stabilize the DC voltages used
by the processor and other elements.
Crystal Oscillator

The crystal oscillator helps Arduino in dealing with time


issues. How does Arduino calculate time? The answer is, by
using the crystal oscillator. The number printed on top of the
Arduino crystal is 16.000H9H. It tells us that the frequency is
16,000,000 Hertz or 16 MHz.

Arduino Reset

We can reset wer Arduino board, i.e., start wer program from
the beginning. We can reset the UNO board in two ways.
First, by using the reset button (17) on the board. Second, we
can connect an external reset button to the Arduino pin
labelled RESET (5).

Pins (3.3, 5, GND, Vin)

3.3V (6) − Supply 3.3 output volt

5V (7) − Supply 5 output volt

Most of the components used with Arduino board works fine


with 3.3 volt and 5 volt.

GND (8) (Ground) − There are several GND pins on the


Arduino, any of which can be used to ground wer circuit.
Vin (9) − This pin also can be used to power the Arduino
board from an external power source, like AC mains power
supply.

Analog pins

The Arduino UNO board has five analog input pins A0


through A5. These pins can read the signal from an analog
sensor like the humidity sensor or temperature sensor and
convert it into a digital value that can be read by the
microprocessor.

4.6 POWER SUPPLY

TRANSFORMER:

This document presents the solution for a 12V 1A flyback


converter based on the Infineon OPTIREG™ TLE8386-2EL
controller and IPD50N08S4-13 OptiMOS™-T2. The user is
guided through the component selections, the circuit design
and, finally, an overview of the experimental results are
presented. The TLE8386-2EL is part of the Automotive
OPTIREG™ family and it implements a low-side-sense
current mode controller with built in protection features. The
device is AECQ-100 qualified. The IPD50N08S4-13 is an
AEC-Q101 qualified 80V N-channel enhanced mode
MOSFET, it is part of the OptiMOS™-T2 family. Intended
audience This document is intended for power supply design
engineers, application engineers, students, etc., who need to
design a Flyback converter for automotive power applications
where a galvanic isolation between two voltage domains is
required. In particular the focus is on a battery connected
flyback that delivers up to 12W at 12V output voltage; the
intention is to provide the user with all of the needed
information to fully design and characterize the SMPS
bringing it from an engineering concept to its production.
Specific features and applications are: - 48V to 12V
Automotive applications - Isolated current mode SMPS -
Flyback regulators with auxiliary sensing
Centre Tapped Transformer Specifications

 Step-down Centre tapped Transformer


 Input Voltage: 220V AC at 50Hz
 Output Voltage: 24V, 12V or 0V
 Output Current: 1A
 Vertical mount type
 Low cost and small package

A centre-tapped transformer also known as two phase


three wire transformer is normally used for rectifier circuits.
When a digital project has to work with AC mains a
Transformer is used to step-down the voltage (in our case, to
24V or 12V) and then convert it to DC by using a rectifier
circuit. In a center-tapped transformer the peak inverse
voltage is twice as in bridge rectifier hence this transformer is
commonly used in full wave rectifier circuits.

The operation and theory behind a Center tapped transformer


is very similar to a normal secondary transformer. A primary
voltage will be induced in the primary coil (I1 and I3) and due
to magnetic induction the voltage will be transferred to the
secondary coil. Here in the secondary coil of a centre tapped
transformer, there will be an additional wire (T2) which will
be placed exactly at the center of the secondary coil, hence the
voltage here will always be zero.

If we combine this zero potential wire (T2) with either T1 or


T2, we will get a voltage of 12V AC. If this wire is ignored
and voltage across T1 and T2 is considered then we will get a
voltage of 24V AC. This feature is very useful for the function
of a full wave rectifier.

Let us consider the voltage given by the first half of the


secondary coil as Va and the voltage across the second half of
the secondary coil as Vb as shown

RECTIFER CIRCUIT:
We have learnt in rectifier circuits about converting a
sinusoidal ac voltage into its corresponding pulsating dc.
Apart from the dc component, this pulsating dc voltage will
have unwanted ac components like the components of its
supply frequency along with its harmonics (together called
ripples). These ripples will be the highest for a single-phase
half wave rectifier and will reduce further for a single-phase
full wave rectifier. The ripples will be minimum for 3-phase
rectifier circuits. Such supply is not useful for driving
complex electronic circuits. For most supply purposes
constant dc voltage is required than the pulsating output of the
rectifier. For most applications the supply from a rectifier will
make the operation of the circuit poor. If the rectifier output is
smoothened and steady and then passed on as the supply
voltage, then the overall operation of the circuit becomes
better. Thus, the output of the rectifier has to be passed though
a filter circuit to filter the ac components. The filter is a
device that allows passing the dc component of the load and
blocks the ac component of the rectifier output. Thus the
output of the filter circuit will be a steady dc voltage. The
filter circuit can be constructed by the combination of
components like capacitors, resistors, and inductors. Inductor
is used for its property that it allows only dc components to
pass and blocks ac signals. Capacitor is used so as to block the
dc and allows ac to pass. All the combinations and their
working are explained in detail below. Series Inductor Filter
The circuit diagram of a full wave rectifier with a series
inductor filter is given below. As the name of the filter circuit
suggests, the Inductor L is connected in series between the
rectifier circuit and the load. The inductor carries the property
of opposing the change in current that flows through it. In
other words, the inductor offers high impedance to the ripples
and no impedance to the desired dc components. Thus the
ripple components will be eliminated. When the rectifier
output current increases above a certain value, energy is
stored in it in the form of a magnetic field and this energy is
given up when the output current falls below the average
value. Thus all the sudden changes in current that occurs in
the circuit will be smoothened by placing the inductor in
series between the rectifier and the load. The waveform below
shows the use of inductor in the circuit. From the circuit, for
zero frequency dc voltage, the choke resistance Ri in series
with the load resistance RL forms a voltage divider circuit,
and thus the dc voltage across the load is Vdc = RL/(Ri + RL)
Vdc is the output from a full wave rectifier. In this case, the
value of Ri is negligibly small when compared to RL. The
effect of higher harmonic voltages can be easily neglected as
better filtering for the higher harmonic components take
place. This is because of the fact that with the increase in
frequency, the reactance of the inductor also increases. It
should be noted that a decrease in the value of load resistance
or an increase in the value of load current will decrease the
amount of ripples in the circuit. So, the series inductor filter is
mostly used in cases of high load current or small load
resistance. A simple series inductor filter may not be properly
used. It is always better to use a shunt capacitor (C) with
series inductor (L) to form an LC Filter. Shunt Capacitor
Filter As the name suggests, a capacitor is used as the filter
and this high value capacitor is shunted or placed across the
load impedance. This capacitor, when placed across a rectifier
gets charged and stores the charged energy during the
conduction period. When the rectifier is not conducting, this
energy charged by the capacitor is delivered back to the load.
Through this energy storage and delivery process, the time
duration during which the current flows through the load
resistor gets increased and the ripples are decreased by a great
amount. Thus for the ripple component with a frequency of ‘f’
megahertz, the capacitor ‘C’ will offer a very low impedance.
The value of this impedance can be written as: Shunt
Capacitor Impedance = 1/2 fC Thus the dc components of the
input signal along with the few residual ripple components, is
only allowed to go through the load resistance RLoad. The
high amount of ripple components of current gets bypassed
through the capacitor C. Now let us look at the working of
Half-wave rectifier and Full-wave rectifier with Capacitor
filters, their output filtered waveform, ripple factor, merits and
demerits in detail.

SOFTWARE DESCRIPTION

5.1 INTRODUCTION

Arduino Development Environment

The Arduino development environment contains a text editor


for writing code, a message area, a text console, a toolbar with
buttons for common functions, and a series of menus. It
connects to the Arduino hardware to upload programs and
communicate with them.

Writing Sketches

Software written using Arduino are called sketches. These


sketches are written in the text editor. Sketches are saved with
the file extension .ino. It has features for cutting/pasting and
for searching/replacing text. The message area gives feedback
while saving and exporting and also displays errors. The
console displays text output by the Arduino environment
including complete error messages and other information. The
bottom righthand corner of the window displays the current
board and serial port. The toolbar buttons allow you to verify
and upload programs, create, open, and save sketches, and
open the serial monitor.

NB: Versions of the IDE prior to 1.0 saved sketches with the
extension pde It is possible to open these files with version
1.0, you will be prompted to save the sketch with the .ino
extension on save.

The Arduino environment uses the concept of a sketchbook: a


standard place to store your programs (or sketches). The
sketches in your sketchbook can be opened from the File
Sketchbook menu or from the Open button on the toolbar. The
first time you run the Arduino software, it will automatically
create a directory for your sketchbook. You can view or
change the location of the sketchbook location from with
the Preferences dialog.

'''Beginning with version 1.0, files are saved with a .ino file
extension. Previous versions use the .pde extension. You may
still open .pde named files in version 1.0 and later, the
software will automatically rename the extension to .ino.

Tabs, Multiple Files, and Compilation

Allows you to manage sketches with more than one file (each
of which appears in its own tab). These can be normal
Arduino code files (no extension), C files (.c extension), C++
files (.cpp), or header files (.h).

Uploading

Before uploading your sketch, you need to select the correct


items from the Tools Board and Tools Serial Portmenus.
The boards are described below. On the Mac, the serial port is
probably something like /dev/tty.usbmodem241(for an Uno or
Mega2560 or Leonardo) or /dev/tty.usbserial-1B1 (for a
Duemilanove or earlier USB board),
or/dev/tty.USA19QW1b1P1.1 (for a serial board connected
with a Keyspan USB-to-Serial adapter). On Windows, it's
probably COM1 or COM2 (for a serial board)
or COM4, COM5, COM7, or higher (for a USB board) - to
find out, you look for USB serial device in the ports section of
the Windows Device Manager. On Linux, it should
be /dev/ttyUSB0,/dev/ttyUSB1 or similar.

Once you've selected the correct serial port and board, press
the upload button in the toolbar or select the Upload item
from the File menu. Current Arduino boards will reset
automatically and begin the upload. With older boards (pre-
Diecimila) that lack auto-reset, you'll need to press the reset
button on the board just before starting the upload. On most
boards, you'll see the RX and TX LEDs blink as the sketch is
uploaded. The Arduino environment will display a message
when the upload is complete, or show an error.

When you upload a sketch, you're using the


Arduino bootloader, a small program that has been loaded on
to the microcontroller on your board. It allows you to upload
code without using any additional hardware. The bootloader is
active for a few seconds when the board resets; then it starts
whichever sketch was most recently uploaded to the
microcontroller. The bootloader will blink the on-board (pin
13) LED when it starts (i.e. when the board resets).

Libraries

Libraries provide extra functionality for use in sketches, e.g.


working with hardware or manipulating data. To use a library
in a sketch, select it from the Sketch Import Library menu.
This will insert one or more  statements at the top of the
sketch and compile the library with your sketch. Because
libraries are uploaded to the board with your sketch, they
increase the amount of space it takes up. If a sketch no longer
needs a library, simply delete it from the top of your code.

There is a list of libraries in the reference. Some libraries are


included with the Arduino software. Others can be
downloaded from a variety of sources. Starting with version
1.0.5 of the IDE, you do can import a library from a zip file
and use it in an open sketch. See these instructions for
installing a third-party library.
PROGRAMMING

The Arduino Uno can be programmed with the Arduino


software (download). Select "Arduino Uno from the Tools
Board menu (according to the microcontroller on your board).
For details, see the reference and tutorials.

The ATmega328 on the Arduino Uno comes preburned with


a bootloader that allows you to upload new code to it without
the use of an external hardware programmer. It communicates
using the original STK500 protocol (reference, C header
files).

You can also bypass the bootloader and program the


microcontroller through the ICSP (In-Circuit Serial
Programming) header; see these instructions for details.

The ATmega16U2 (or 8U2 in the rev1 and rev2 boards)


firmware source code is available . The ATmega16U2/8U2 is
loaded with a DFU bootloader, which can be activated by:
• On Rev1 boards: connecting the solder jumper on the
back of the board (near the map of Italy) and then resetting the
8U2.

• On Rev2 or later boards: there is a resistor that pulling the


8U2/16U2 HWB line to ground, making it easier to put into
DFU mode.

You can then use Atmel's FLIP software (Windows) or


the DFU programmer (Mac OS X and Linux) to load a new
firmware. Or you can use the ISP header with an external
programmer (overwriting the DFU bootloader). See this user-
contributed tutorial for more information.

Automatic (Software) Reset

Rather than requiring a physical press of the reset button


before an upload, the Arduino Uno is designed in a way that
allows it to be reset by software running on a connected
computer. One of the hardware flow control lines (DTR) of
theATmega8U2/16U2 is connected to the reset line of
the ATmega328 via a 100 nanofarad capacitor. When this line
is asserted (taken low), the reset line drops long enough to
reset the chip. The Arduino software uses this capability to
allow you to upload code by simply pressing the upload
button in the Arduino environment. This means that the
bootloader can have a shorter timeout, as the lowering of DTR
can be well-coordinated with the start of the upload.

This setup has other implications. When the Uno is connected


to either a computer running Mac OS X or Linux, it resets
each time a connection is made to it from software (via USB).
For the following half-second or so, the bootloader is running
on the Uno. While it is programmed to ignore malformed data
(i.e. anything besides an upload of new code), it will intercept
the first few bytes of data sent to the board after a connection
is opened. If a sketch running on the board receives one-time
configuration or other data when it first starts, make sure that
the software with which it communicates waits a second after
opening the connection and before sending this data.

The Uno contains a trace that can be cut to disable the auto-
reset. The pads on either side of the trace can be soldered
together to re-enable it. It's labeled "RESET-EN". You may
also be able to disable the auto-reset by connecting a 110 ohm
resistor from 5V to the reset line; see this forum thread for
details.
LIQUID CRYSTAL DISPLAY (LCD)

A Liquid Crystal Display (LCD) is an electronically-


modulated optical device shaped into a thin, flat panel made
up of any number of colour or monochrome pixels filled with
liquid crystals and arrayed in front of a light source
(backlight) or reflector. It is often utilized in battery-powered
electronic devices because it uses very small amounts of
electric power. LCD has material, which continues the
properties of both liquids and crystals. Rather than having a
melting point, they have a temperature range within which the
molecules are almost as mobile as they would be in a liquid,
but are grouped together in an ordered from similar to a
crystal. They are used in similar applications where LEDs are
used. These applications are display of display of numeric and
alphanumeric characters in dot matrix and segmental displays.
LCD consists of two glass panels, with the liquid crystal
materials sandwiched in between them. The inner surface of
the glass plates is coated with transparent electrodes which
define in between the electrodes and the crystal, which makes
the liquid crystal molecules to maintain a defined orientation
angle. When a potential is applied across the cell, charge
carriers flowing through the liquid will disrupt the molecular
alignment and produce turbulence.
When the liquid is not activated, it is transparent. When
the liquid is activated the molecular turbulence causes light to
be scattered in all directions and the cell appears to be bright.
Thus the required message is displayed. When the LCD is in
the off state, the two polarizer’s and the liquid crystal rotate
the light rays, such that they come out of the LCD without any
orientation, and hence the LCD appears transparent. The fig.
6.1 shows the LCD display.

Fig. 6.1 LCD Display


6.2 WORKING OF LCD DISPLAY

When sufficient voltage is applied to the electrodes the


liquid crystal molecules would be aligned in a specific
direction. The light rays passing through the LCD would be
rotated by the polarizer, which would result in
activating/highlighting the desired characters. The power
supply should be of +5V, with maximum allowable transients
of 10mV. To achieve a better/suitable contrast for the display
the voltage (V) at pin 3 should be adjusted properly. A
module should not be removed from a live circuit.
The ground terminal of the power supply must be
isolated properly so that voltage is induced in it. The module
should be isolated properly so that stray voltages are not
induced, which could cause a flicking display. LCD is
lightweight with only a few, millimetres thickness since the
LCD consumes less power, they are compatible with low
power electronic circuits, and can be powered for long
durations. LCD does not generate light and so light is needed
to read the display. By using backlighting, reading is possible
in the dark. LCDs have long life and a wide operating
temperature range. Before LCD is used for displaying proper
initialization should be done. LCD is used to display the blood
group and blood glucose level.
6.2.1 LCD Pin description
The function of each pins of LCD is described below
VCC, VSS and VEE while VDD and VSS provide +5V and ground,
respectively, VEE is used for controlling LCD contrast.
6.2.2 Register select
There are two important registers inside the LCD. The
RS pin is used for selection as follows. If RS=0, the
instruction code register is selected, allowing the user to send
a command such as clear display, cursor at home, etc. If RS=1
the data register is selected, allowing the user to send data to
be displayed on the LCD.
6.2.3 Read/Write
R/W input allows the user to write information to the
LCD or read information from it. R/W=1 when reading;
R/W=0 when writing.
6.2.4 Enable
The enable pin is used by the LCD to latch information
presented on its data pins. When data is supplied to data pins,
a high to low pulse must be applied to this pin in order for the
LCD to latch in the data present at the data pins.
6.2.5 D0 - D7
The 8-bit data pins, D0 – D7, are used to send
information to the LCD or read contents of the LCD’S
internal registers. There are also instruction codes that can be
sent to the LCD to clear the display or force the cursor to the
home position or blink the cursor. RS=0 is used to check the
busy flag bit to see if the LCD is ready to receive information.
The busy flag is D7 and can be read when R/W=1 and RS=0,
as follows: if R/W=1, RS=0.when D7=1, the LCD is busy
taking care of internal operation and will not accept any new
information, when D7=0, the LCD is ready to receive new
information.

6.3 PIN DESCRIPTION FOR LCD

The table 6.1 illustrate the pin descriptions of LCD.

Table: 6.1 Pin Descriptions of LCD


Pin Symbol Function
No.
1 Vss Ground terminal of
Module
2 Vdd Supply terminal of
Module, +5v
3 Vo Power supply for liquid
crystal drive
4 RS Register select

RS=0…Instruction
register

RS=1…Data register
5 R/W Read/Write

R/W=1…Read

R/W=0…Write
6 EN Enable
7-14 DB0-DB7 Bi-directional Data Bus.
Data Transfer is performed
once, through DB0-
DB7,incase of interface
data length is 8-bits;and
twice, thru DB4-DB7 in the
case of interface data length
is 4-bits.Upper four bits first
then lower four bits.

15 LAMP-(L-) LED or EL lamp power


VOLTAGE SENSOR:

The Voltage Sensor is a simple module that can used with


Arduino (or any other microcontroller with input tolerance of
5V) to measure external voltages that are greater than its
maximum acceptable value i.e. 5V in case of Arduino.

Following is the image of the Voltage Sensor Module used in


this project.

Pins of the Voltage Sensor


Before going into the details of the Voltage Sensor like its
functionality and schematic, let me give you an overview of
the available Pins of the Voltage Sensor Module.

Basically, a 25V Voltage Sensor, like the one used here, has 5
pins in total. Two of them are on the two-pin screw terminal
and three are male header pins.
The Screw Terminal pins are marked as VCC and GND and
they must be connected to the external source of voltage i.e.
the voltage that needs to be measured.

Coming to the three male headers, they are marked as S, + and


–. The S pin is the “Sense” pin and it must be connected to the
Analog Input of the Arduino. The “–” pin must be connected
to the GND of the Arduino. The pin marked as “+” is not
connected to anything (it is an N/C Pin).

The following image shows the pins of a Voltage Sensor


Module.
 VCC: Positive terminal of the voltage to be measured (0-
25V)
 GND: Negative terminal of the voltage to be measured
 S: Analog Input of Arduino
 +: Not connected (N/C)
 –: GND of Arduino
Schematic of Voltage Sensor
Now, let us talk about the important thing about the voltage
sensor: its schematic. The Voltage Sensor is basically a
Voltage Divider consisting of two resistors with resistances of
30KΩ and 7.5KΩ i.e. a 5 to 1 voltage divider.

The following image shows the schematic of the Voltage


Sensor Module with an input voltage limit of 25V.
Make your Own Voltage Sensor
Using a pre-built voltage sensor module is very easy and if
you don’t have one then you can easily build one yourself. All
you need are two resistors.

If you want to make your own voltage sensor that can


measure voltages up to 25V like this Voltage Sensor Module,
then you have to get a 30KΩ and a 7.5KΩ resistor.
Interfacing a Voltage Sensor with Arduino
Now that we have seen a little about the Voltage Sensor, let us
now proceed with Interfacing a Voltage Sensor with Arduino
and measure some external voltages.

The Arduino Voltage Sensor Interface is pretty straight


forward. Connect the voltage to be measured to the screw
terminal of the Voltage Sensor, connected the output of the
voltage divider to the Arduino. That’s it.

After interfacing the Voltage Sensor with Arduino, you can


either view the results on the serial monitor of the Arduino
IDE or on a 16×2 LCD Display. I have gone with the LCD
Display.

You might also like