When I run the code I get no response from the Attiny85. It is supposed to send a request to the Attiny85 and then the Attiny85 is supposed to send response. From what I can see I think I have every thing wired up correctly.
Can any one spot any problems in my setup or code?
My setup:
My Code:
I2C Master
//I2C Master for NODE MCU
#include <Wire.h>
#define SLAVE_ADDR 0x50
void setup()
{
Wire.begin(0,2); //set GPIO0 and GPIO2 pins
Serial.begin(9600);
Serial.println("");
Serial.println("I2C Test");
}
void loop()
{
Wire.requestFrom(SLAVE_ADDR, 1);
if (Wire.available())
{
byte byteReceived = Wire.read();
Serial.println(byteReceived, DEC);
}
delay (1000);
}
I2C Slave (Attiny85)
#include "TinyWireS.h"
#define SLAVE_ADDR 0x50
void setup()
{
TinyWireS.begin(SLAVE_ADDR);
TinyWireS.onRequest(requestEvent);
}
void loop()
{
}
void requestEvent()
{
byte byteToSend = 15;
TinyWireS.send(byteToSend);
}