Electronic DIY Project – Understanding Arduino Board

Spread the love
  • 4
    Shares

The first DIY IoT project which we are going to build is a wireless temperature and humidity monitor and alarm system for your home using Arduino. It can be used to monitor your room temperature to control AC or if you have a store where you put perishable items you can monitor that as well.

This project will be based on Arduino board and it is very important to understand the IoT development board you are working with. And since Arduino is a generic development board, it provides a lot many functionalities that we all should be completely aware of.

Arduino Uno Board

Arduino has become quite popular for electronic project development because it doesn’t need a separate programming board. You can plug your USB and load the application program directly from Arduino IDE in your PC. Also, Arduino has inbuilt ADC and various onboard communication interfaces like SPI and I2C to easily connect sensors and relay for various purpose. Following are the major components of an Arduino Uno Board –

The Microcontroller

All our code gets executed by microcontroller present on Arduino Uno board. Arduino Uno features an AVR family 8-bit ATmega328 microcontroller. 8-bit means that its data-bus architecture and internal registers are designed to handle 8 parallel data signals. That is also why our website is called 8bitworks :).

ATmega328 has 3 types of memory. 32KB flash memory where our application code gets stored, 2KB of SRAM where application code stores its variable while it is running and 1KB EEPROM to store data.

Pins

The Arduino has several different kinds of pins, each of which is labeled on the board and used for different functions.

5V & 3.3V – These pins are used supply 5V or 3.3V power from the board to external circuit. Most of the simple components used with the Arduino run happily off of 5 or 3.3 volts.

Ground (GND) – There multiple GND pins on the Uno board, any of which can be used to ground your circuit.

Analog Pins – A0 through A5 on the UNO are Analog pins. These pins can read the signal from an analog sensor (like a temperature sensor) and convert it into a digital value that we can read.

Digital Pins –  0 through 13 on the UNO board are digital pins. These pins can be used for both digital input (like taking digital input) and digital output (like powering an LED).

PWM – Digital pins 3, 5, 6, 9, 10, and 11 on the UNO can also be used as PWM (Pulse-Width Modulation). We will discuss more on these pins later. A quick example can be dimming LED.

AREF – This is called Analog Reference and we don’t use it most of the time. It is sometimes used to set an external reference voltage (between 0 and 5 Volts) as the upper limit for the analog input pins.

Onboard Communication Interface

There is 3 onboard communication available in Arduino – UART, SPI, and I2C. The purpose of any communication interface is the same, transferring data back and forth. They only differ in method, speed, number of devices that can be attached etc.

 UART is Universal Asynchronous Reciever Transmitter is a type of serial communication protocol which uses 2 pins Tx and Rx for sequentially transmitting and receiving data with a serial compatible device or interface. Digital pin 0 and 1 acts as UART pins (Tx and Rx respectively).

You can also use the SoftwareSerial Arduino library (SoftwareSerial.h) to use other GPIO pins as Serial RX and TX lines. We will discuss this later. It is basically an implementation of UART via software. There are multiple limitations to UART, the first limitation is that at a time only 2 devices can communicate with each other. Another limitation is that UART is half-duplex so at a time only one device can send the data and other will receive data. Both devices can’t send and receive simultaneously.

UART

SPI (Serial Peripheral Interface) overcomes the limitations of UART by allowing multiple devices to connect on the same line using a master-slave architecture.  Also, SPI is full duplex allowing simultaneous data transfer between connected devices. It uses 4 wire for connection –

  • MOSI (“Master Out Slave In”): Data transmission line from master to slave
  • SCK (“Clock”): Clock line defining transmission speed and transmission start/end characteristics
  • SS (“Slave Select”): Line for the master to select a particular slave to communicate with
  • MISO (“Master In Slave Out”): Data transmission line from slave to master

SPI

SPI digital pin connections for SCK, MOSI, and MISO are predefined on Arduino boards.  For the Arduino Uno, the connections are as follows:

  • SCK: GPIO 13 or ICSP 3
  • MOSI: GPIO 11 or ICSP 4
  • MISO: GPIO 12 or ICSP 1
  • SS: GPIO 10

Any digital pin can be also used for the SS pin.  To select the device, this digital pin must be driven low.  There is a significant limitation with SPI. As the number of slave increases, the number of CS lines increases, this results in hardware complexity as the number of pins required will also increase.

SPI

 

I2C (Inter-Integrated Circuit) solve various limitations in other protocols and it only uses 2 pins. I2C allows multiple masters to multiple slaves which were not possible with SPI hence the number of devices can that can be connected in I2C is way higher than SPI.

On the Arduino, I2C implementation occurs through the Wire library (Wire.h).  The Arduino can be configured as either an I2C master or slave device.  On the Arduino Uno, the connections are as follows:

  • SDA: Analog Pin 4
  • SCL: Analog Pin 5

I2C is also half-duplex because multiple master devices cannot communicate with each other over that same I2C bus. Multiple masters can be connected over an I2C bus just by connecting their SDA and SCL lines to the bus’s lines.  However, only one master can communicate with slaves at a time, because having multiple devices attempting to communicate with each other would lead to bus contention.  Similarly, communication cannot occur bidirectionally from master to slave and from slave to master at the same time because that would also lead to bus contention.  This makes I2half-duplex, just like UART!

Reset Push Button

The reset button on Arduino is very useful if your code doesn’t repeat, but you want to test it multiple times. Pushing it will temporarily connect the reset pin to ground and restart any code that is loaded on the Arduino.

LED Indicators

There is a power LED on Arduino board as an indicator of the board is powered on. When you plug your board to a power source and if it is not on, there’s a high chance something is wrong. Time to re-check your circuit!

There is another set of LEDs for Tx(Transmit) and Rx(Recieve).  They are the indicator for serial communication from Arduino to any serial device. Digital pin 0 and 1 also acts as Tx and Rx for the Arduino board.

Voltage Regulator

You will never do anything with the onboard voltage regulator on the board but it is good to know what it does. It controls the amount of voltage that is let into the Arduino board tough it has its limits, so don’t hook up your Arduino to anything greater than 20 volts. It can only regulate below 20V.

That is all about the Arduino board. It is very important that you understand the board very well. Most useful is the digital I/O and analog I/O pins and how to program the Microcontroller using Arduino IDE. Once you have a good idea about board it is very easy to plug and play sensors or attach a shield and start working.


Comments

Spread the love
  • 4
    Shares

You may also like...