Hello
I am trying to make a machine data collection unit that transmits WIFI data to a network
Using ESP8266-01 & Nano.
I have managed to get this working but i have a problem on the I2c line, ESP can only be used in Master, so every 10 seconds it requests data from the Nano, this works fine, the problem i have is the Nano transmits on the same i2c line to an LCD, this works perfectly until the ESP and Nano connect to the i2c line at the same time.
I have been through loads of blogs and it seems possible to run 2 masters on the same line, the bit of information dont seem to be able to find is anything that shows me how to detect if the BUS is busy, i know SDA & SCL are pulled low when its being used but i cannot find anything on how to tell the other master how to detect a LOW and wait?
I have set up 2 Nano's with an LCD one with a delay offset so i know the crash will happen
Master A:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LCD.h>
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7);
void setup() {
Serial.begin(115200);
Wire.begin(0x10);
lcd.begin (20,4); // or for 16 x 2 LCD module
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // set cursor to 0,0
}
void loop() {
delay(100);
Wire.beginTransmission(0x3F);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Master 1");
}
Master B:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LCD.h>
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7);
void setup() {
Serial.begin(115200);
Wire.begin(0x11);
lcd.begin (20,4); // or for 16 x 2 LCD module
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // set cursor to 0,0
}
void loop() {
delay(99);
Wire.beginTransmission(0x3F);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Master 2");
}
Any help or pointers appreciated
Thanks
Simon