Monday, February 14, 2022

Multiple I2C Devices Arduino


Overview

Have you ever wanted to use 2 sensors with the same I2C address at the same time, not knowing what to do? Faced some serious challenges in doing that?

In a lot of projects, we have used different modules and sensors that support I2C communication protocol. Sometimes, we have interfaced some I2C modules with a microcontroller in our projects. If they all have different I2C addresses, we could easily interface them, facing no serious trouble. But, if 2 or more of the modules had the same I2C address, we would face some apparently unsolvable problems in using them all. This problem is a serious one which we all have definitely come across at least once. If you’re having the same problem, this tutorial can be helpful for you.

Generally speaking, this problem can be solved in both software and hardware. In this tutorial, we are going to present a hardware solution for this problem. In a nutshell, we are going to add the TCA9548A I2C Multiplexer to the project and expand the I2C addresses of the modules with the same I2C address.

What Is I2C Communication Protocol, and How Does It Work?

I2C, short for Inter-Integrated Circuit, is a communication protocol which can also be referred to with the short term IIC. This communication protocol is widely used in microcontrollers. In this communication, masters and slaves (Masters are usually the main components like microcontrollers and Slaves are sensors, modules and other components used in the circuit.) communicate through 2 lines:

  • SDA (Serial Data): The line to transmit and receive data between the Master and Slave
  • SCL (Serial Clock): The line to send the clock
  • The most important features of the I2C communication protocol are the following:

    • It’s not so fast (But fast enough for most applications)
    • Suitable for short distances (e.g. maximum distance in 100KHz is 1 meter)
    • Synchronous communication
    • Data is transmitted serially
    • Logic level can be both 3.3V and 5V
    • How I2C Communication Protocol Works

      The data being transmitted between 2 devices on the SDA line consists of the following parts:

      • Start: At first, the SDA line voltage drops from High to Low level. Then, the same thing goes for the SCL line, too.
      • Address: Including 7 bits (10 bit in some cases) is the I2C address of the module that the master intends to communicate with. These 7 bits (the address) is always sent from the master toward the slaves. After the address is sent, each slave compares it to its own address and in case it matches, the module will send a single bit (ACK Bit) in Low level to the master.
      • R/W Bit: This bit, which is sent alongside the 7-bit address (it’s the LSB) determines whether the master is the transmitter or the receiver. If this bit is in High level, the master is the receiver, and vice versa.
      • ACK/NACK Bit: Once each 8-bit data is received by the Master or Slave, this bit specifies whether the data has been properly received. If the receiver properly receives the data, it’s called the “Acknowledge” state and a bit with Low level will be sent through the SDA line.
      • Date: Once the ACK Bit sent from the slave is received by the master, the first byte of data is prepared to be sent. Pay attention that at the end of each data transition, the receiver must put the ACK bit in Low level to indicate full proper transition.
      • Stop: After the completion of all data, at first, the SCL line changes from Low to High and then the SDA line will change from High to Low.


Circuits Diagram: Click here

Circuits Diagram 1: Click here





Arduino Code: Click here
 

Friday, February 11, 2022

Keypad and 7 segment using Arduino





ABOUT THIS PROJECT

This is a simple project that shows you how to control a 7 Segment Display with a Numeric Keypad! Whatever number you press on the keypad will appear on the Seven Segment Display!

Making It

The schematic is down below. It should be pretty easy. You need to use a 3x4 matrix keypad so you have enough pins.













Arduino Code for Keypad with Arduino Click Here

 

Thursday, February 10, 2022

Arduino Book


Arduino Course: Click Here








                                                                   Arduino Book: Click Here

Kindly Request to Subscribe the channel 
 

Saturday, February 5, 2022

Thursday, February 3, 2022

Neopixel Arduino


 


o get started, let’s consider the example of an Arduino microcontroller connected to the computer’s USB port (though it works with many other microcontroller boards as well). We’ll elaborate on the finer points of powering NeoPixels later, but in general you’ll usually be using a 5V DC power supply (e.g. “wall wart”) or — for wearable projects — a 3.7 Volt lithium-polymer battery.

Identify the “input” end of your NeoPixel strip, pixel(s) or other device. On some, there will be a solder pad labeled “DIN” or “DI” (data input). Others will have an arrow showing the direction that data moves. The data input can originate from any digital pin on the Arduino, but all the example code is set up for digital pin 6 by default. The NeoPixel shield comes wired this way.

Some NeoPixel strips have extra wires so they can connect to both a microcontroller and power source, but these will always correspond to one of the same three inputs: +5Vground or data. If not using the extra wires, you can clip off any exposed tips and/or insulate with some heat-shrink tube.

If using a Flora, Feather or other microcontroller board with an attached lithium-polymer battery: connect the +5V input on the strip to the pad labeled VBAT or BAT on the board, GND from the strip to any GND pad on the microcontroller board, and DIN to Flora pin D6. If the board doesn’t have a pin #6, you’ll need to modify the example code to change the pin number.

For other Arduino boards with a separate +5V DC power supply for the NeoPixels: connect the +5V input on the strip to the + (positive) terminal on the power supply (don’t connect to the Arduino), DIN to digital pin 6 on the Arduino, and – (minus or GND) on the strip must connect to both the minus (–) terminal on the DC supply and a GND pin on the Arduino (there are usually several — any will do).

“DOUT” or “DO” (data out) at the end of a NeoPixel chain can be left unconnected. If adding more pixels later, data-out from one chain connects to data-in of the next.

The 144 pixel strips are so tightly packed, there’s no room for labels other than –, + and the data direction arrows. Data is the third, un-labeled pad.


Circuits Diagram :Click Here


Arduino Code :Click Here

Tuesday, February 1, 2022

Digital Temperature and LCD Arduino

                       Digital Temperature and LCD Arduino


In this project we are going to use a temperature sensor in order to read its value and displaying on a LCD screen.

We connected two potentiometer in order to adjust LCD backlight and contrast as well.

After sketch loading completed, your board will display current temperature, but only after computing an average of 100 samples read from temperature sensor. This to avoid crazy reading data every cycle.

Requirements:

Hardware components required:

  • Arduino UNO R3
  • LM35 temperature sensor
  • LCD Display – JHD162A 16×2
  • I2C adapter for LCD (optional)
  • Green LED light
  • Red LED light
  • 2 X 100 ohm resistors.
  • Connecting wires.

Software requirements:

  • Arduino IDE

LM35 Temperature sensor

The LM35 is a good performance temperature sensor at a low price. It has a working range from -55ºC to 150ªC. Its output is analog and linear type with a slope of 10mV / ºC. The sensor is factory calibrated to an accuracy of 0.5ºC.

It is a very popular sensor for its easy use and varied applications. It does not need any additional circuit to be used. It is powered directly from a 5V source and delivers an analog output between 0V to 1.5V. This analog voltage can be read by the ADC from a microcontroller like PIC or Arduino. Among its applications we can find thermometers, thermostats, monitoring systems and more.

Features of LM35

  • Operating Voltage: 4V – 30V (5V recommended)
  • Working Range: -55 ℃ to + 150 ℃
  • Accuracy in the range from -10 ° C to + 85 ° C: ± 0.5 ° C
  • Slope: 10mV / ºC
  • Low energy consumption: 60uA
  • No need for additional components
  • Pins: + VCC, V output, GND
  • Low output impedance

In above picture we connected lm35 temperature sensor to Arduino as first pin for power source is connected to 5V on the Arduino and the second pin is connected to A2 of Arduino analogue pin and the third one is connected to GND of Arduino UNO.

We connected 16 X 2 LCD display with the help of I2C adapter, all the connection pins are given in the image which has two pins for power and ground and another two for SDA and SCL.

We connected two small Red and Green 5mm LED light to digital pins 6 and 7 and we connected 100 ohms resistors along the ground of LED lights.

Working of Digital thermometer using Arduino:

After uploading the code you will notice the live temperature for the sensor is displayed on the 16 X 2 LCD display. If the temperature raised above 60 the red LED will light up and if the temperature is below 60 Green LED will light up.  You can adjust the threshold temperature in the above code to make the lights change at what temperature you want.

Build Digital Thermometer using LM35 and Arduino output

Arduino Code : Click Here
Advantages and Applications:

  • Monitor the components temperature but putting sensor beside them
  • Sensor is small so it can be used in wide variety of application.
  • It gives nearly accurate results with only ±0.5 C error .
  • Can be used to measure skin temperature
  • Can be used to measure liquids temperature but we need to cover the pins with water proof material.

Circuits Diagram : Click Here

BOM : Click Here

YouTube: https://www.youtube.com/channel/UCcwnTKWxSlkv_iarGQ_zbPg/featured



Instagram:
https://www.instagram.com/?hl=en



Facebook:

https://www.facebook.com/Creative-ideas-EEE-110709481470623/?ref=pages_you_manage

dc motor with encoder arduino

How to control dc motor with encoder: Arduino DC Motor Speed Control with Encoder-  I have been using different types of stepper motors, Ser...