Arduino to arduino i2c

Hi guys,

I’ve been researching arduino to arduino i2c using the master as the reader and the slaves as the writers. I got a basic circuit working, but I can’t get the code to work with my circuit.

This is what I have, but it is not working.

I have an OPT101 connected to the arduino analog pins to measure light intensity.
I don’t think there’s anything wrong with the master code. I have problems in my slave code under requestevent. I don’t know how to write the pVolt0 value to the master. I am using the arduino Leonardo


#include <Wire.h>

void setup()

  Wire.requestFrom(2, 8);
    char c =;

void loop()


#include <Wire.h>

#define inPin0 0
void setup() {
void loop() {


void requestEvent()
  int pinRead0 = analogRead(inPin0);
  int pVolt0 = pinRead0 / 1024.0 * 5.0;

When I set everything up, nothing appears on the serial monitor.
Can anyone help me?
Thank you!,148850.0.html


This is what I have, but it is not working.

In the same way you don't hand your keys to the mechanic and say "my car isn't working", you don't make a post here without describing both what the code is doing, and what you're expecting it to do.

And code tags avoid the smileys in your code and allows helpers to cut and paste to their IDE. You are only sending 1 byte but requesting 8)

The slave device needs an address for the master to communicate with it.

and to write, you need the standard