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 Pi. 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 and works with my Uno but not with my Nano, which led me to believe it was a driver issue. 

14
  • This might help: raspberrypi.stackexchange.com/questions/96184/…. Cheers.
    – tlfong01
    Commented Aug 6, 2020 at 5:07
  • @tlfong01 The thing is I can't access the GPIO of the Pi Zero which is what I'm using so I didn't look at any solutions with regards to connecting them using the GPIO. If I don't get any answers, I'll solder on some headers and redo my project.
    – aditya
    Commented Aug 6, 2020 at 5:34
  • What on earth is the given serial cable - looks like USB code? What version of Arduino IDE are you using?
    – Milliways
    Commented Aug 6, 2020 at 5:58
  • @Milliways Here: modernelectronics.com.pk/wp-content/uploads/2017/09/2.jpg
    – aditya
    Commented Aug 6, 2020 at 6:07
  • 1
    @tlfong01 Thank you for all the help!
    – aditya
    Commented Aug 6, 2020 at 7:05

1 Answer 1

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.

4
  • 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.
    – aditya
    Commented Aug 6, 2020 at 9:06
  • @aklingam you obviously did not understand my post. The (unspecified) cable won't help.
    – Milliways
    Commented Aug 6, 2020 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/…
    – aditya
    Commented Aug 6, 2020 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
    Commented Aug 6, 2020 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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