I tried to let my rpi3 with wiringPi as slave to receive data from master and data +1 send to master .
mater send 1 to slave (rpi3)
My rpi3 SDA is GPIO 18 ,SLC is GPIO 19
the code on my rpi3 :
#include<wiringPiI2C.h>
#include<stdio.h>
int main(){
int fd;
fd = wiringPiI2CSetup(0x35); //0x35 is my slave address
int cont=0;
while(1){
cont = wiringPiI2CReadReg8(fd,0x55); //0x55 is my regaddress
printf("readValue:%d\n",cont);//receive data from my master
delay(1000);
wiringPiI2CWriteReg8(fd,0x55,cont++);//send data to master
delay(1000);
}
return 0;
}
However it only show -1 , mean error
I tried to change SDA,SCL pin to GPIO 3 (SDA),5 (SCL) it would show 0 ,but it couldn't receive data
Any help on what Im doing wrong will be appreciated.