Notes on using the Robotics Connection I2C line following sensor with Arduino based boards

After many of wasted hours of trying to get the I2C line following sensor from Robotics Connection working with an Arduino based controller board I was finally able to get it to communicate and since there was no other information out there on this issue I decided to write this post.

To start off the I2C master sends and 8 bit word onto the I2C bus consisting of a 7-bit address and a 1-bit read or write command for a total 8-bit word looking like <7-bit address><R/W bit> with the R/W bit being the LSB. The 7-bit address is set by the device it’s self either in it’s firmware or through switches (In some cases like the I2C line following sensor this can be change through I2C). The read or write bit lets the device that you want to communicate with know if you want to receive data from it or write data to it. This bit is set to 0 if the master wants to receive data or to 1 if it wants to send data. When a device on the I2C bus that has this address detects a packet with it’s address it will read the last bit of the word and either wait to receive more data or start sending out data at the proper time.

The problem I had with the I2C line following sensor was that Robotics Connection lists the default address of the sensor in there documentation as 0×50. What they do not mention is that this is the full 8-bit word that you must send to receive data not the 7-bit address of the device. So the actual 7-bit default address of the sensor is 0×28 (which is 0×50 shifted 1-bit to the right). This might not be an issue on other boards where you must specify the full 8-bit word when sending over I2C but in the Arduino language the Wire.requestFrom command adds the final R/W bit for you. So when i was attempting to communicate on the address 0×50 the the wire library was adding the extra bit resulting in the word being 0xA0 while when using the proper address of 0×28 results in the word being 0×50. So in the end, when using the I2C line following sensor from Robotics Connection with an Arduino based board any values in their documentation must be shifted to the right one place for it to work.

One Response to “Notes on using the Robotics Connection I2C line following sensor with Arduino based boards”

  1. This was driving me crazy! Thanks for the tip!

Leave a Reply