0

I'm currently using an Arduino UNO with a raspberry pi 3b. I'm using the USB connector for both power and comms, i.e. the arduino is powered by the RPI via the USB cable, and also i use the same cable for serial communication between the pi and the UNO.

My question is, could i use the same code, and wiring if i were to change the UNO with a NANO or MICRO?

So for example, on the RPI side of things, could i still simply setup the arduino in my python code as

arduino = serial.Serial('/dev/ttyACM0', 9600)

and send commands with something like

arduino.write('2')

and on the arduino side of things, just check if there is serial data coming in and read it, like

if (Serial.available()) {
    command = Serial.read();

I know this may be a very stupid question, but to wrap it up, would anything change other than number of analogues, digitals etc, if i were to switch from an UNO to a MICRO or NANO?

1

The Nano uses the same chip (ATMEGA 328P) that is on the Uno. So putting the same code on the Nano should work the same as the Uno.

The Micro uses a different chip. Whether or not the code from your Uno will work on your Micro depends on what is in the code. You chose not to show anyone the code so that can't be answered yet.

  • Thanks for the answer. Would i still be able to communicate with serial libraries from both sides? From RPI to arduino and vice versa? and simply using just one USB cable for power and comms? That's my only worry regarding the code. – LecauseAndThePi Oct 9 '17 at 16:10
  • Let me say it one more time. The UNO and the Nano use the same chip. The difference is the shape of the board they are on. Code for one should work on the other. You haven't given enough information to answer about the micro. – Delta_G Oct 9 '17 at 16:59
  • 1
    The Raspberry Pi has to recognize the serial chip on the Arduino Uno. The Uno and Nano use both the Atmega328p microcontroller, but that chip has not to do with the usb-serial. The usb-serial chip could be different. Arduino clones could have yet another usb-serial chip. The Arduino Micro uses the Atmega32u4 itself as usb-serial chip. So far I have not encountered a problem, but I'm not sure that all three will work. Give it a try and tell us which usb-serial is on the Arduino board and if it is recogned ! – Jot Oct 9 '17 at 18:54

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.