1

I wanted to connect an Arduino Nano to either my Pi 3B+ or my Zero W preferably my Zero. When I connected my Nano to my Pi Zero and ran a simple script with the python 3 serial library, it didn't work. I did the same with a 3B+ which didn't work either. I then tried connecting a normal Arduino Uno which worked just fine with both the Pis. I tried looking up the issue, but I didn't find any solutions related to connecting a Nano to any kind of Raspberry Pi. I think it might have something to do with the drivers because my Windows laptop recognizes my Nano.

A shortened version of my python script:

import serial
from time import sleep

string = ""

sleep(2)
arduinoSerialData = serial.Serial('/dev/ttyACM0', 9600)
sleep(2)

#print statements are for debugging

while(True):
    sleep(1)
    arduinoSerialData.write(b's')
    sleep(1.3)
    string = arduinoSerialData.readline().decode('ascii')
    string = string[0]+string[1]+string[2]+string[3]
    f = open("soil.txt","w+")
    f.write(string)
    f.close
    print(string)

I'm using a standard Arduino Uno and Nano With the given Serial Cable.

Note: I'm using the "Arduino IDE Linux ARM 32 bit" on my Pi to code the Arduino. It recognizes my Uno and works with it but does not work on my Nano which is why I suspected it's some kind of driver issue.

14
1

The "the given serial cable" is a bog standard miniUSB to USB-A cable. This information belongs in your Question - as does ALL technical detail.

The reference to "Serial Cable" is misleading the cable is USB; the serial interface is on the Arduino - no additional serial interface is needed. (It is technically possible to connect the Pi serial pins to Arduino serial, but far from straightforward, and not necessary).

Similarly the reference to "the GPIO of the Pi Zero" in your Comments is misleading - NO GPIO is involved.

It is unclear what you have connected to what, as the Pi Zero does NOT have a USB-A port (unlike the Pi 3B+) and requires an adapter.

Note the current version is ARDUINO 1.8.13 (some early versions did not support all Arduino models). All Arduino IDE versions have a serial terminal function.

Many Arduino clones DO NOT have the standard USB chips and substitute cheap clones, which are unreliable, and the manufacturer of the official chips has included code to prevent these working with their drivers.

I suggest you first ask on the https://arduino.stackexchange.com/ site to clarify the Arduino issues, then if you still have problems ask a new Question.

5
  • Hi, thanks for the answer. I'm really sorry if I confused anyone: the standard USB cable that came with Arduino Uno was called the "Serial Cable" in the book I used to learn Arduino, so I just called it that. I'm pretty certain the Nano I used is not a clone as it worked on windows as I stated in my question. Also, I used a micro A USB to USB A Converter to connect to the Micro B to USB A Cable. Thanks a lot for the help, I just ordered a USB to UART adaptor/cable, so I'll be using that.
    – aklingam
    Aug 6 '20 at 9:06
  • @aklingam you obviously did not understand my post. The (unspecified) cable won't help.
    – Milliways
    Aug 6 '20 at 9:53
  • @Millways What did you mean by the (unspecified) cable are you talking about the USB to UART adaptor/cable. roboticsnepal.com/media/catalog/product/cache/1/image/1800x/…
    – aklingam
    Aug 6 '20 at 10:05
  • @aklingam I don't know how to make this any clearer - you DON'T need any "USB to UART adaptor/cable" - indeed it is unclear just what you think this will do or what you plan to connect it to - although if you have an Arduino Pro Mini it might help. Incidentally a picture of a device is meaningless without specifications.
    – Milliways
    Aug 6 '20 at 12:41
  • @Millways Then how am I supposed to transfer data from my Arduino to my Pi 0. I had issues with my method of connecting the p 0 I to an Arduino Nano using a micro A USB to USB A Converter to connect to the "bog" Micro B to USB A Cable. Which worked when I used the same code and connected to an Audrino Uno with the "Bog" Micro B cable replaced with a B, it did not work, because I could not find a solution to my issue I'm using an alternate method of communication between the devices that works out for my project that was suggested by tlfong01 because the cable is cheap and I'm not time-bound.
    – aklingam
    Aug 6 '20 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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