I2C communication with libpololu_arduino

Hi Expert,

I am utilizing an Arduino Uno along with a Pololu QTR 8RC sensor (we are using 5 sensors), and the libpololu-Arduino library for a line following robot competition. Due to the limited number of I/O pins on the Uno, I am employing an Arduino Nano to connect ultrasonic sensors, color sensors, and servo motors.

Additionally, we need to establish communication between the Arduino Uno and Nano. Therefore, we have opted to utilize the I2C protocol.

During the communication between the Uno and NanoUsing I2C , we first stop the robot by changing the state of pin 2.of Uno

My question is, since the SDA and SCL pins (A4 and A5) are being used for the IR sensor, is it reliable to use them for I2C communication? …Note that we initiate I2C communication when the robot is stopped, and when the robot is following the line, I2C communication is halted.

Please advise.
Thanks in advance.

Hi team
I am using libpololu-arduino for my root
I need to build the communication between Arduino Uno ( PID Line follower code uploaded ) and Arduino Nano

Is it possible with using libpololu-arduino library

Please advice
Thanks in advanced


I merged your threads since they were about the same topic.

I am doubtful you will be able to use the same pins for reading the QTR RC sensors and doing I2C communication. The QTR sensors will be trying to pull the lines down, which will probably be fighting the I2C pull-ups; also, if the pull-ups on the I2C are strong enough to overcome that, it will probably interfere with the QTR sensor’s function. Additionally, using the QTR sensors involves briefly driving the lines high, which the devices on the I2C bus might not like.

I do not know the pin restrictions of the rest of your system, but if you cannot move the QTR sensors to different pins, you might consider using TTL serial to communicate between your Arduino boards and use Arduino’s softwareSerial library (which works on any pins on the Arduino Uno) to give you more flexibility.

By the way, it is not entirely clear to me why you’re using the libpololu library (which is generally intended for our old Orangutan controllers and discontinued original 3pi Robot), but if you’re only using it for the QTR sensor, you might consider using our Arduino library for the QTR Reflectance Sensors instead.


Hi Brandon
Thanks for the reply
We are utilizing the entire libpololu-arduino library for the robot, not just the QTR sensors. we are using Pins 3, 11, 5, and 6 are allocated for the motors, pin 12 for the start switch, and pin 10 for the buzzer. pin 8 and 9 for Servo Motors…We tried to employed the RX and TX pins for serial communication, but the receiver side (Nano) is receiving incorrect characters. We attempted to adjust the board rate, but the issue persists.

Since you mentioned that this libpololu-arduino library is obsolete, are there any newer libraries available that we can utilize for Arduino Uno? Additionally, we are using the Pololu USB AVR Programmer ( Old Version ) to upload the codes
Please advise
Thaks in advanced

There generally shouldn’t be a problem communicating between those boards via serial, so you might consider troubleshooting that some more. For example, make sure you know the difference between what to expect with the serial write() and print() commands. Additionally, if you’re using hardware serial, the Uno and Nano might send some erratic bytes when starting up, so you might start your program by waiting for a short time (to make sure they boot) then clearing the serial buffer.

From your description, it sounds like you have enough pins available for your 5 QTR sensors while leaving pins A4 and A5 available for I2C (e.g. pins 2, 4, 7, 13, A0, A1, A2, A3).

There’s nothing particularly wrong with the libpololu Arduino library, so if it’s working for you then it might not be worth changing now. I cannot recommend any alternative libraries without knowing more about your hardware. For future reference, it sounds like one of our A-Star 32U4 Robot Controllers might be a good option for a robot like yours with its built-in dual motor drivers, power switch, buzzer, 3 user LEDs, 3 user pushbuttons, and a battery monitoring circuit. It also has its own Arduino library.

By the way, it’s not clear to me why you’re using our USB programmer to upload your code, but since you’re using an Arduino Uno and Nano, you should be able to use their on-board USB with the Arduino bootloader.


Hi BrandonM
Thanks for the reply
Can we program using the standard Arduino USB port with the libpololu-arduino library? I recall asking your team a few years ago, and their response mentioned that the Arduino bootloader utilizes Timer Zero for millis(), potentially conflicting with QTR sensor readings. However, I may be mistaken. Could you please advise


following error is showing during upload but program is successfully compiled

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

An error occurred while uploading the sketch

When using the Pololu programmer, the program uploads successfully via the ISP port. However, when attempting to upload using the standard Arduino USB port, an error occurs. Please note that prior to attempting to upload the program using the standard USB port of the Arduino, we successfully uploaded the Arduino bootloader and the blank sketch can be uploaded by selecting board as Arduino Uno

After refamiliarizing myself with the Arduino usage of that library, I realized that the way we have it set up, you need to select the 3pi or one of Orangutan boards in order for the library to be accessible. In general, I don’t recommend using this library with boards other than the 3pi or one of the Orangutan controllers. If you’re using an Arduino Uno or switching to an Arduino Mega 2560 like you mentioned in your other thread, there are probably much more appropriate libraries for your hardware, as Patrick suggested there.