6

I want to switch data reading from multiple sensors by line buffer IC (74F244). My problem is I can't read anything from sensor when I connect via IC but can when connect sensor to ESP32 directly. I found that endTransmission() in this code return 2 but return 0 when connect directly.

How can I use endTransmission via line buffer IC ?

void setBH1750Mode( byte i2c_addr, byte mode ) {
  Wire.beginTransmission( i2c_addr );
  Wire.write( mode );
  Wire.endTransmission();
  delay(200); // delay for 200 msec
}
2

I2C is a "bus", as in bi-directional. You signal the device at its address that you want some data from it, and it sends it back. Now I'm no electrical engineer graduate, but the 74F244 chips looks like a one-way buffer. You have "input" and "output" lines, and from the datasheet (link (pdf)), it does not look bi-directional to me.

What exactly are you trying to do? A normal I2C bus should be able to accommodate several devices, as long as their slave addresses are all different. The ESP32 has built in SDA/SCL pins, so you should just be able to hook up all your devices directly without having to use the buffer chip...unless there is some reason this won't work that you didn't mention :)

There is plenty of info about how I2C works on other Stack Exchange sites like this question that mentions the BH1750. Google for "ESP32 I2C" and it brings up a bunch of info that might help.

  • Yes, I have some reason for doing this. I chose 74F244 because I want to use 1-wire sensors along with i2c sensors. I knew that 1-wire sensor can't change address in same sensor type, same manufacturer, so that made me chose 74F244. However the problem I found happen with i2c sensor. PS. For 74F244 I adjust circuit by use 2 logic gates per sensor, that I assume it can operate as two-way buffer. – 3ORZ May 18 '18 at 10:37
  • The issue though is that even with the 74F244, your ESP32 still needs to signal an address, and the BH1750 board only has two addresses you can select from. If you had an array of buffers chips that could be switched, you could build some kind of logic tree of sensors for many BH1750 boards using just those two addresses...but it seems like a lot of work. If you are just trying to get multiple Luminescence readings, it might be easier to hook photoresisters up to analog ports and let the ESP32 compute the reading. – JD Allen May 18 '18 at 15:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.