- Thu Jun 11, 2015 1:06 pm
#20181
Hi everyone....
I need a little help on Wire library... I can't get wire.read() , to return the correct value....
I'm trying to read a slave (an arduino, with the Slave Sender template) from an esp8266...
Firstly, I flashed the slave and try it with other arduino as master, it worked fine!
Then I tried the same program using an esp8266... I flashed it with arduino esp8266 IDE it also worked fine...
Then I tried the program with Sming and I can't get it to work...
With Sming and i2c scanner I can "find" the slave and also I can write to the slave but I can't read from it... It always return some garbage... Even if it only have to read one byte...
This is my recive function :
void recive()
{
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
while(Wire.available()) // slave may send less than requested
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
}
Does anyone knows how to read from a slave, or if I'm doing something wrong...
Thanks in advance!