Upload sketch without USB

Hello everyone,

I am planning a small cluster (~9 Nanos and a RasPI as Master). As communication I will use RS485 modules since the distances are up to 15m. At least three Nanos are not very easy accessible (one is even 0.5m under earth). My problem is the maintenance of the code. It may needs to be changed dependent on the math I use for the devices connected. I would like to upload sketches without the need of the USB interface.

I already used the ISP interface for another problem (no bootloader on device), but for this I would need 4 extra wires to connect to the master (MISO,MOSI,SCK and RST). This might be possible since wire diameter is not an immediate problem, but I am not sure about the maximum length a stable connection is possible.

I have two questions:

  1. Is it possible to upload sketches using RS485 (similar this module)?
  2. Can I use the ISP interface (or the pins directly) over 15m?

Does the math really change, or just the parameter values that the math uses? Because the answer to your questions, is no.

The system depends on continuous measurement from the other devices. Therefore I need to change the 'dynamic' of the system. Parameters also change, but that I can manage over the RS485 und a getter-Method.

@aarg: Sorry, too fast. No to both suggestions?

Yes, no to both... please post a more specific explanation or the actual code.

You can't use ISP over 15 meters, so just forget about that right off :slight_smile:

The bootloader is just running over a serial connection: USB isn't specifically required. You can do this over RS485. The problem is that at the end of the upload you'll need to reset the CPU to run your new code. If you have another I/O line from the Pi that you could use to reset the Nano that would work, alternately you'd have to modify the bootloader code.

Actually, I can pretty much guarantee you that this problem has been solved many times. I've written enough bootloaders to know that. Should just be a matter of spending a few minutes with google.

[edit] here's a thread from earlier this year referencing the same thing: Flashing arduino board over rs485

You have equipment there, just try it!

What is this mysterious math that must be changed? I'm extremely doubtful of your need.

I am still in the planning phase. The prototypes are sitting in my laboratory and communicating correctly. Sensors, actors, etc behave as expected. I used the RS485 module before, so there is no problem there.

@cedarlakeinstruments maybe I use the wrong search words ("upload sketch via rs485, upload sketch without USB, bootloader ISP,...)

All the easier to avoid the requirement of remote updates.

Sorry for the crosswriting. I am still getting used to this format of the forum.

@cedarlakeinstruments Thanks for the link. Flashing was one the the right search words.

@aarg: the reality is that remote updates are pretty much expected these days, no matter how well you plan. So unless you're making the most basic of basic devices, at some point someone will want to change the code.

I spent the last few years working with wearable wireless devices and updating those things over BLE is a royal Pain In The Ass, but it's come to be expected. It's the engineer's job to suffer so the user doesn't have to :slight_smile:

if the RS485 modules are on hw Serial and the MCU has a serial bootloader, then you only need to send a message to the sketch to self reset and then upload with avrdude.

Possible. It may be better to use the slaves just as datalogger and send just raw data back to the master. Another side note: I am not that confident in my code to commit it to the devices.

esp8266 or esp32 with OTA?

In this case I am engineer and costumer. I would like this feature but also angry at the engineer that he hasn't implemented it yet :wink:

Does this not require a connection via a serial port (USB)?

no. only UART0 RX/TX. a bootloader listens there

Not maybe. Is better. It gives you so much more flexibility.

But there are still distance limitations?

why? it would go over RS485