nod64
New Member
Posts: 5
|
Post by nod64 on Oct 6, 2019 12:53:42 GMT -8
I need to make the WeatherPlus Board act as a I2C slave and arduino uno as master,
I try insert this code to WeatherPlus Board Using Arduino IDE
void setup() {
... Wire.begin(DEVICE_ADDRESS); //i tried to change many number as an address Wire.onRequest(requestEvent); ... }
void requestEvent() { ........... ........... {
The problem is the master can't see the slave address But it can see all device on the WeatherPlus Board like this
I2C scanner. Scanning ...
Found address: 60 (0x3C)
Found address: 73 (0x49)
Found address: 87 (0x57)
Found address: 104 (0x68)
Found address: 119 (0x77)
Done.
Found 5 device(s).
Here this code is use i try to scan I2C address
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
} // end of good response
} // end of for loop
Serial.println ("Done.");
How should it do. I need suggestion.
Thanks for help.
|
|
|
Post by SDL on Oct 6, 2019 16:26:46 GMT -8
Boy, that is an interesting problem. I assume you are programming the ESP8266 and you have researched whether it will even work with the ESP8266? I have done programming like that with an Arduino (make it a slave) but never with the ESP8266.
If you have an Arduino, test your code on that and make sure you don't have some software problem.
BP
|
|
nod64
New Member
Posts: 5
|
Post by nod64 on Oct 7, 2019 9:13:50 GMT -8
Boy, that is an interesting problem. I assume you are programming the ESP8266 and you have researched whether it will even work with the ESP8266? I have done programming like that with an Arduino (make it a slave) but never with the ESP8266. If you have an Arduino, test your code on that and make sure you don't have some software problem. BP OK, I try on ESP8266 Board as master and Arduino UNO as slave, it work. Arduino UNO as master and Arduino UNO as slave, it work too. But, Arduino UNO as master and ESP8266 as slave, it not work. However, i found this. I2C (Wire library)
Wire library currently supports master mode up to approximately 450KHz. Before using I2C, pins for SDA and SCL
need to be set by calling Wire.begin(int sda, int scl), i.e. Wire.begin(0, 2) on ESP-01, else they
default to pins 4(SDA) and 5(SCL).from ESP8266 Arduino Core Documentation Release 2.4.0 atpece.files.wordpress.com/2018/05/arduino-esp8266.pdfit does not mention about as slave. i am not sure it have newest version. thank for your advice.
|
|
|
Post by SDL on Oct 7, 2019 10:29:16 GMT -8
Looks like the ESP8266 does not support slave mode. Note on the WeatherPlus board wire.begin(5,4) (the 4 and 5 pins were swapped) are needed.
BP
|
|