Arduino_handler: serial_connection.readline() broken


So I’ve successfully installed everything on RPI 3 and flushing the firmware to Arduino had no errors, I’ve plugged in all my sensors into the OpenAg PCB (water temperature, liquid level, air temp and humidity, ph and EC) and when I run the rosrun command that should start up the food computer I keep getting a serial connection readline() broken error. I went into the arduino handler code to understand the error and I saw that it raises this exception when the empty reads exceed the maximum empty reads, but I don’t seem to figure out why these empty reads are happening or how to test if the Arduino is communicating with the RPI correctly (it seems to be connected at /dev/ttyACM0). Could somebody please, please help me? I have run out of ideas of what could be going wrong.

Getting the software up and running

@ferguman @sllo @david @Riggi Ideas?


?? Where is the Arduino MEGA 2560? I can not see it, just below the signal PCB? The Photo can not tell what’s happen any LED lights up /flashing ? after flash to Arduino may need to un-plug and re-plug to USB. May I see the Arduino Mega 2560 photo, is it a compatible or is the original. May be there a electrical short below the Signal PCB to the Arduino USB Port outer case, you can try a plastic sheet between them
I used to use a plastic tap to stick on top of the usb port.and a plastic sheet cut to size place between them.

I used to solder a longer header to avoid that


A bigger photo. Hope the dl speed not too slow but still seeing the details

I used a old PC, PSU, buy two extension cable, CPU 12V :more current for LEDs lighting,Relay broad and others and FDD:12V and 5V for ,RasPi, Andruino Mega .Cut out leads from the extension to get connection to a terminal block to deliver the 12V and 5V

DIY from DFRoboots Arduino I/O shield broad
: 10X2 header pins connect to flat cable to relays.
:5X2 Pin header pins connect to DB-9 . 4pin(i2c) , Water temp. use 3 pins, water level High and low 2 pins and get power form Water temp pins.
: watertight, clear face box you can see header connections inside . I2C for EC/PH have rooms for me to add back the isolation circuits.

I will connect two cam. one cam put img.jpg to /var/www/html for the WebUI.

Up to now all the electronic is running.(EC/PH not isolated). will go to green plants bigbox. then go to electrical to LEDs, Heater, Fan, Air…


HI Alexel333,

You can test that your PI is able to communicate with the Arduino using the OpanAg group’s test protocol that is documented here:[]=python&s[]=serial

Also Platform I/O has a serial monitor that can be invoked by issuing the command “pio device monitor --echo”.

I am currently at essentially the same stage as you are in terms of bringing up a new Food Computer. The Arduino won’t communicate with the PI when all the sensors and actuators are hooked up but it will communicate when I disconnect some of the sensors and actuators. If I discover any useful debugging techniques as I bring my FC up then I will post here again.


@sllo Thank you for your response, yes - the Arduino is just bellow the PCB and the lights are flashing. I checked for short circuits but it doesn’t really seem like I have any. Everything seems to be in order other than the fact the Arduino does not want to communicate with the Raspberry and I unplugged the Arduino several times already.

Maybe it’s a good idea to take some sensors out? Could an error on one of the sensors prevent proper communication?

Here are some photos:


@ferguman Thank you for your response! I found that test, but nothing happens when I use it because I’m guessing you have to have the grow lights wired up to the 16 channel relay board and I’m not yet at that phase. Am I wrong?

I will definitely try taking some sensors out - like the water temperature and see if the Arduino will communicate with the Raspberry this way because I don’t remember getting this error when I was having some difficulties with the CO2 sensor.


@Alexel333 How about removing the shield from the mega and test if the pi will connect? If that works then you know for a fact that it’s shield related.


Dear, @Alexel333 you may also need a usbweb connected to RasPi I used two command line, “rostopic” and “rosrun” you may aleady used "rosrun"
I will post the screen cap later :sweat_smile:

open one terminal

rosrun openag_brain main --screen personal_food_computer_v2.launch

the screen will pop out some message about the status of openag_brain.service

open another terminal

rostopic list

you will see many line of text come out ,copy and paste any one line ended like
behind rostopic echo may looked like

rostopic echo /sensors/…/raw

your may just leave all sensor not plug in to the signal PCB to see what will be. Then the water_temperature , and I2C bus.

:sweat_smile:Please forgive me, the text comes out just like I am blaming about the photo on you. My English level is not good enough.


Dear, @Alexel333

If your 20pin header is in the right place the header JP1, JP2 should be no header house on it, your sould use the other pair. for header pins.

you can cut all the long lead from “long leg pined header house” and use normal header pins and use top side as soldering side for it . you may insert all the pins to the Arduino MEGA 2560 then place openag_Signal on it and soldering them.


Hey @sllo,

I followed the pictures provided in the github repository when soldering the headers -

This is a more recent picture of how my PCB looks:


Thank you @adam, for your response.

Prior to mounting the PCB I checked for the Arduino to communicate with the Raspberry and it worked, but now I’m not getting any data whatsoever and even if I don’t connect all the sensors (i.e. having just the ph, EC, CO2 and temperature and humidity wired up) it still gives me serial_connection.readline() broken so I will take the PCB off and check again. Could flashing it with the firmware ruin anything?


I don’t think that flashing it with the firmware could ruin anything. As your Raspberry Pi is able to communicate with the Arduino just fine without the PCB, I’m pretty sure there is something up with your PCB. Maybe somewhere in your PCB you have a short circuit from either soldering or there’s a production error in your PCB. Have you tried going over all the connections with a multimeter to see if there’s a solid connection or not or if there’s anything connected with each other which shouldn’t be connected? If everything seems to be fine, I’m not sure what the problem would be. Maybe you could also try to upload a random basic program on your Arduino with the PCB on to see if it acts weird in any way or not (to verify if it’s PCB related or even Arduino related).


you can look more detail to the photo from github. it is look from top side of the pcb , you can see usb cable comes from arduino mega 2560. your photo was not .you no need to solder out the long leg header housing , just cut the legs ,and solder new header pin beside them.


Oh my God… I didn’t even see that. That means the PCB on the Arduino is mounted incorrectly. Well, in my defense it did light up making me think that everything was working correctly, buuuut turns out I’m just monumentally stupid. I will get back to you after I fix the issue, @sllo. I doesn’t seem like I ruined the PCB so fingers crossed.


Dear, you no need to disappointed, based on circuit connection, it still can work , but may cause short circuit between upper broad and lower broad. it seems that they were not damage.


Dear, What is the colour of the small LED on PH & EC small broad, turn them to blue/ i2c mode? you may use small switch beside EC broad to switch them UART <->i2c mode . you are almost complete the electronic parts.

EZO pH and EC Sensors in UART Mode


So I aligned everything correctly now, but I get the exact same error. Raspberry will communicate with the Arduino until I flash it with the firmware and after that it won’t read anything. I get errors if I don’t have some sensors connected like the air temp and humidity, once I connect it I don’t get any errors anymore even though PI can’t detect anything with i2cdetect. I can see the Arduino on /dev/ttyACM0, but I don’t get anything if I try to read from it.

The LEDs on the pH and EC circuits board flash from blue to green.


good news,blue to green flashing means reading from them by Arduino at least.
To day I upgrade a 1/4 FPC from 2.0 docker install to 2.1 install form source. After flash form an already tested good image file. I insert it to the Box only had 4 ways relay broad , DS18b20, AM2315 an a switch will short to gnd on DATA 3.

After reboot NOTHING HAPPEN. I forgot to reflash the Arduino. so I use

sudo systemctl stop openag_brain.service
rosrun openag_brain firmware
rosrun oepnag_brain firmware --taget upload
sudo systemctl start openag_brain.service

WebUI can controls the relays.
but no data shows up by rostopic echo " water temperature", "air temperature " the switch connect to data 3 to gnd or to vcc still can not turn on the water pump relay.

I thinking of delete unconnected sensor .py file before firmware upload.


I’ve been using the developer setup as I was afraid of not being able to make my LEDs work, but I will try the docker install just to see if it works like that. Maybe it’s something with my Raspberry PI.