Fiverr gig
$15 โ€” I will help you with your project and simulate it for you
Hire me
๐ŸŒ IoT Projects

I2C example

EmbedLab TeamDecember 16, 20245 min read
I2C example

 I2C (Inter-Integrated Circuit) communication is a protocol widely used for connecting microcontrollers and peripherals. This tutorial demonstrates how to implement I2C communication between two Arduino Uno boards in Proteus. We'll configure one Arduino as the Master and the other as the Slave. The Master sends data to the Slave, and the Slave responds by displaying the data on its Serial Monitor and blinking an LED.

The schematic of I2C



Hardware Requirements

  • 2 Arduino Uno boards

  • A computer with Proteus simulation software

  • Virtual connections in Proteus for the I2C communication (SDA and SCL)


I2C Overview

The I2C protocol uses two wires for communication:

  1. SDA (Serial Data Line): Transfers data between devices.

  2. SCL (Serial Clock Line): Synchronizes the communication.

Each device in the network has a unique address. In our example, the Slave Arduino has been assigned the address 6.

The Master Code

Below is the code for the Master Arduino, which transmits data to the Slave.


#include <Wire.h>


int LED = 13; // Initialize pin 13 to drive LED


void setup() {

  Wire.begin(); // Join I2C bus (address optional for Master)

}


byte x = 0;


void loop() {

  Wire.beginTransmission(6); // Transmit to device #6

  Wire.write("x is");        // Sends five bytes

  Wire.write(x);             // Sends one byte

  Wire.endTransmission();    // Stop transmitting

  

  x++;

  delay(500);

}


Explanation:

  1. The Wire.begin() function initializes the I2C bus in Master mode.

  2. The Wire.beginTransmission(6) function specifies the Slave address (6).

  3. Wire.write() sends a message and an incrementing value (x) to the Slave.

  4. The delay(500) function provides a half-second interval between transmissions.

The Slave Code

Below is the code for the Slave Arduino, which receives and processes data from the Master.

#include <Wire.h>


int LED = 13;


void setup() {

  pinMode(LED, OUTPUT);             // Set LED pin as output

  Wire.begin(6);                    // Join I2C bus with address #6

  Wire.onReceive(receiveEvent);     // Register receive event

  Serial.begin(9600);               // Start Serial Monitor for output

}


void loop() {

  delay(100); // Wait for data from Master

}


void receiveEvent(int howMany) {

  while (1 < Wire.available()) {    // Loop through all but the last byte

    char c = Wire.read();           // Receive byte as a character

    Serial.print(c);                // Print the character to Serial Monitor

    digitalWrite(LED, HIGH);        // Turn LED on

    delay(1000);

    digitalWrite(LED, LOW);         // Turn LED off

    delay(500);

  }

  int x = Wire.read();              // Receive the last byte as an integer

  Serial.println(x);                // Print the integer to Serial Monitor

}


Explanation:

  1. The Wire.begin(6) function assigns address 6 to the Slave.

  2. The Wire.onReceive(receiveEvent) function registers receiveEvent as the callback for received data.

  3. The receiveEvent function processes incoming data:

    • Characters are printed to the Serial Monitor.

    • The LED blinks with each received message.

    • The last byte (an integer) is printed separately.


Simulation in Proteus

  1. Set Up the Components:

    • Place two Arduino Uno boards in Proteus.


Schematic


    • Connect the SDA (A4) and SCL (A5) pins of both boards.

    • Add a virtual terminal to display Serial Monitor output by rightclicking and selecting PLace > Virtual instrument > Virtul terminal

      Place

Virtual terminal



    • Connect an LED to pin 13 of the Slave Arduino.

  1. Load the Codes:

    • Load the Master and Slave codes into the respective Arduinos.

  2. Run the Simulation:

    • Start the simulation in Proteus.

    • Observe the data being sent from the Master to the Slave.

    • Watch the LED blink on the Slave and verify the output in the Serial Monitor.

The data snipet from the virtual instrument

Download the full project from here, subscribe to my channel in youtube, and get some products from amazon using my links!

https://drive.google.com/file/d/1Kks9b--2dEbAKdhZacAFlNccbe-49aVk/view?usp=drive_link



ET

EmbedLab Team

Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.

Related projects

Top 5 IoT projects with Arduino UNO and ESP32 โ€” Blynk app, Wi-Fi and smart home
๐ŸŒ IoT Projects

Top 5 IoT Projects with Arduino UNO & ESP32 โ€” Blynk, Wi-Fi & Smart Home Tutorials (2026)

The top 5 IoT projects every Arduino UNO and ESP32 maker should build in 2026 โ€” Blynk IoT control, Wi-Fi blink, ESP-WROOM-32 dev board guide, ESP32 Proteus 8 simulation and an Arduino smart home parking system. Each pick links to the full tutorial with free Arduino IDE code, library and wiring.

May 30 8 min
Blynk IoT app controlling Arduino UNO and ESP32 over Wi-Fi
๐ŸŒ IoT Projects

Blynk IoT with Arduino UNO & ESP32 โ€” Free Arduino IDE, Library & App Tutorial

Complete Blynk IoT tutorial for Arduino UNO and ESP32 Arduino: install the Arduino IDE, add the Blynk Arduino library, wire LEDs, LCD and sensors, and control everything from the Blynk app over Wi-Fi โ€” a free, beginner-friendly Arduino IoT project.

Nov 19 6 min
Arduino UNO and ESP32 Blink IoT project with Blynk app
๐ŸŒ IoT Projects

Arduino UNO Blink IoT Guide โ€” ESP32 Arduino, Blynk App & Arduino IDE Code

Complete Arduino UNO Blink IoT guide using ESP32 Arduino and the Blynk app: free Arduino IDE code, Arduino library and LED wiring โ€” the easiest Arduino IoT project for beginners to download and try online.

Oct 27 9 min
How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide
๐ŸŒ IoT Projects

How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide

&nbsp; How to Control LEDs Using Blynk and Arduino Uno: A Complete Guide Controlling LEDs remotely using Blynk and an Arduino Uno is a simple yet powerful project for IoT (Internet of Things) enthusia

Apr 4 4 min
Proteus 8 Blynk
๐ŸŒ IoT Projects

Proteus 8 Blynk

Connect Proteus 8 with Blynk Using Arduino: A Complete Step-by-Step Guide Looking to seamlessly connect Proteus 8 with Blynk using Arduino ? This detailed tutorial covers everything from setting up a

Apr 4 7 min
Browse all 50+ projects