Serial USB connection to Zumo shield while it is running

I need to stream data from a running zumo robot back to my computer over the usb-to-serial connection on my Arduino Uno. I do this regularly using Arduinos in other applications, but it doesn’t seem to be working on the zumo shield. Typically, I have the serial start and print a welcome message in the setup function:

Serial.begin(115200); Serial.print("zumo serial"); Serial.print("\n");
And then in the loop function I check for incoming serial commands from the computer:

if (Serial.available() > 0) { inByte = Serial.read(); Serial.println("hello from serial receive"); if (inByte == 1){ //main control case //send_ser = true; Serial.println("case 1:"); fresh = 1; } }//end if available
This code compiles fine but I never get any kind of response to print to the Arduino serial monitor. I am attaching my *.ino file.

Any tips on making serial communication work while the Zumo is doing some line following or something?

Thanks,

Ryan
krauss_serial_zumo.ino (2.59 KB)

Hello, Ryan.

I looked at your code briefly and did not see anything obviously wrong with it. However, I noticed that you are waiting for a button press before printing to the serial monitor in your setup function.

I tested your code on a Zumo Robot for Arduino (Uno) and was able to see “Z34 serial” outputted to the monitor. Did you try pressing the user pushbutton while your Zumo was running your Arduino sketch? If you have already tried that and the problem was not resolved, can you disconnect your Arduino Uno from the Zumo shield and verify that your Arduino can output data to the serial monitor? If your Arduino works, can you post pictures of your Zumo shield?

- Amanda

Thanks for your reply. I am making some progress and will post when I know more.

I have this more or less working to my satisfaction. I did not go back and test it on the Z34, but it works on the Zumo shield. I am attaching my code in case someone else wants to try something similar.
line_follower_with_serial.ino (4.59 KB)

I do have things working fairly well on the Zumo shield. For what it’s worth, I cannot get any response from the Z34 over serial. My sketch is attached.
z34_serial.ino (5.5 KB)

Hi.

It looks like the only place that you print anything to the serial monitor in the z34_serial sketch that you posted in in the startup routine right after the board is turned on. Since you cannot keep the Arduino serial monitor open when restarting the Zumo32U4, the serial print is probably just happening faster than you can open the serial monitor. If you add a long delay or wait for a button press before printing to the serial monitor, you should see it.

-Claire

The true Arduino boards reboot on a serial connection and the setup function runs then. So, I had no problem with putting serial print statements in the setup function for the zumo shield with an Uno. The Z34 seems to behave differently in this regard (i.e. opening the serial monitor does not re-trigger the setup function). I will have to alter my code to make it work with the Z34.

Hello.

I am not sure what type of Zumo you have. Please note that the Zumo 32U4 includes an ATmega32U4 microcontroller and is very different from the Zumo Shield for Arduino.

The Zumo 32U4 behaves similarly to official ATmega32U4-based Arduinos like the Arduino Leonardo and Arduino Micro, which are “true Arduino boards” that do not reset when you connect to the Serial Monitor. Since the main processor handles the USB connection on boards like this, it would be difficult to have the processor reset itself when the Serial Monitor is opened.

–David

Sorry, I guess I made up the Z34 model number and caused some confusion. I have one Zumo shield that I am using with an Arduino Uno and I also have one of the 32U4. I guess I was not aware of the behavior of the Leonardo or other Arduinos; I am really only familiar with the Uno and Mega. So, I guess I should not have used the phrase “true Arduino” when comparing the Uno and 32U4 behavior. I was trying to use code that worked for an Uno, but like you said this is very different from the 32U4.