2

I'm currently working on a project where you essentially will have multiple Arduinos (1 Uno, multiple Nanos) daisy-chained, only connected through 2 digital pins and one wire for Serial communication (RX Pin -> TX Pin). (The first one is connected via USB to the PC.)

I figured the serial communication between the first Arduino and PC would also be forwarded through the RX and TX pins, but that doesn't seem to be the case.

As it's fairly tedious to update one at a time, is there a way of updating all of them at once, using only the one-way serial communication wire?

EDIT: Yeh so like imma just add a USB Port to every single component to the chain to update separately, and update every single one of them separately.

2
  • Serial communication between the first arduino and PC would also be forwarded through the RX and TX pins ... that would happen only if the bootloader sends back what it receives from avrdude ... you could modify the bootloader to do that ... I think that the avrdude expects some handshaking though
    – jsotola
    Jun 27, 2022 at 18:03
  • Might be better off making a program to feed nanos instead of a modified bootloader
    – Abel
    Jun 27, 2022 at 18:12

2 Answers 2

5

Try connecting only the RX and reset pins. Serial programming is done by the bootloader, but it needs to be switched into programming mode first, which is done by resetting the chip and then sending a special code to the RX pin within a certain time period. When you program through the serial port (as you are doing with the Uno) the FTDI chip drives this pin for you, but you'll need to cascade that reset signal through to the other chips as well. This still isn't guarenteed to work 100%, because it depends on a number of other factors as well, but at least you'll have a chance.

When I've done stuff like this commercially I've programmed via the ICSP connector instead and made programming rigs out of spring-loaded pin connectors that the target boards simply clip onto. If you're planning on doing this with any degree of frequency then I'd recommend investing a bit of time into doing this yourself.

UPDATE: ok, I can see now why this isn't working. The Nano's CH340 usb-to-serial chip is pulling RX low, preventing the data stream from being read. Would work fine with standalone chips, obviously doesn't on the Nano.

I think your best option is to use ICSP. It's an extra pin, but if you breadboard then it shouldn't make any difference. Plus there are a number of advantages to doing so, including faster programming, the ability to upload/replace the bootloader and the ability to change fuses (e.g. to protect your firmware or disable the bootloader altogether to give you app more Flash space etc).

If you don't already know how to do this then the layout is:

  • Connect Uno SCLK(D13)/MOSI(D11)/GND pins to all the corresponding Nano pins.
  • Connect Uno D10 to all the Nano's RESET pins.
  • Connect Uno MISO(D12) to only the first Nano's MISO pin.
  • Connect Uno VIN to all the Nano VINs (you don't want all the Nanos being driven from the Uno's regulator)

Should wind up looking something like this:

enter image description here

Prepare the Uno for programming:

  • Set your IDE board type to Uno
  • Set IDE programmer type to "AVR ISP"
  • Upload IDE ArduinoISP sketch to the Uno

And now you're ready to program the Nanos:

  • Set your IDE board type to Nano
  • Set IDE programmer type to "Arduino as ISP"
  • Upload your Nano sketch using "Upload Using Programmer"

Just tried it now with the two Nanos in the photo, worked fine.

9
  • What I've also heard so far is, that avrdude also expects handshakes/responses from the programmed board, and if the serial is simply forwarded, out of sync aka timing issues are likely to occur while uploading, but I'll definitely try this later!
    – Mikoyan
    Jun 28, 2022 at 13:12
  • @Mikoyan yes, that's true, although I would expect the pauses in between programming chunks to be long enough to accommodate that. But if it doesn't work then writing your own uploader is extremely easy, the Flash function in Device.cs in my Windows Arduino emulator has all the code to do this, and you could just add additional delays as needed. Jun 28, 2022 at 13:20
  • 1
    Connecting only the RX and Reset pins does not work, it appears like the Reset pin is not actually (un)firing (although it might've just been too fast to notice, still: no program on the nano) :/
    – Mikoyan
    Jun 28, 2022 at 14:21
  • @Mikoyan gimme a day or so to try it out, I'll reply here with an answer if I can get it working myself. Jun 28, 2022 at 21:11
  • 1
    As only one Nano has its MISO connected, the programmer can't get feedback from all the others. I wouldn't have dared such a setup, but it's really cool that it works! Note though that, in the “verify” phase of the upload, only the first Nano is effectively verified. Jun 29, 2022 at 7:27
0

There is a two-way protocol used by the bootloader which I describe here.

You could conceivably connect all the Rx wires together, and use the Tx wire from the first one (so it responds appropriately), and discard the responses from the other units. If they program at exactly the same rate, and reset at exactly the same moment, that might work.

You might be better off just uploading using a device designed to do that, as I describe on my forum. The Atmega328P programmed using that method can be reprogrammed in about one second (so the time to hook up the wires is the long part). Using the ICSP interface on the chips, and a suitable plug, could make that very quick, and easy.

There are also stand-alone devices, for example the Crossroads standalone programmer which uses the techniques described in my forum post. You can use that in the field because it doesn't require a monitor or PC. You just hook it up via the ICSP port, select what file you want to upload, and hit the "program" button.

2
  • "You could conceivably connect all the Rx wires together" - Actually no, as discussed in another reply, connecting just the RX pins (and reset to bring it into programming mode) does not work as: "The Nano's CH340 usb-to-serial chip is pulling RX low, preventing the data stream from being read. Would work fine with standalone chips, obviously doesn't on the Nano"
    – Mikoyan
    Jun 29, 2022 at 15:25
  • Hmm, OK. You could make up your own boards without a USB to serial chip, since that doesn't seem required in this setup. Or just desolder it from the boards.
    – Nick Gammon
    Jun 30, 2022 at 21:33

Your Answer

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

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