Upload sketch without USB

I will try it using RS485 and the Serial pins. I will report back with code and schematic.

do you know how to do a self reset to bootloader with watchdog?

No.

I currently searching how the upload file needs to look or how to configure the ArduinoIDE in order to send the data over the RS485 module.

you can use avrdude on RasPI. point it to the com port with the RS485 adapter.
wdt_enable(WDTO_15MS); with #include <avr/wdt.h>
make sure you burn the 'new' bootloader. the 'old' bootloader would go into boot loop with watchdog

Is this a parameter before the init() ?

#define WDTO_15MS 0

In development my uploader is still my PC, but the ArduinoIDE is the same version.

Can't I use the one already on it? Do I need a new bootloader when uploading a sketch?

WDTO_15MS is in avr/wdt.h

but you don't have RS485 on PC. so you would have to transfer the hex file to RasPI and there use avrdude to upload over RS485.

the old bootloader is not compatible with watchdog.

do your RS485 modules have automatic TX EN or the sketch must activate TX EN to allow sending over RS485? because that would be complication

I use the code from this project. There are lines

digitalWrite (EnTxPin, HIGH ); //enable to transmit

which indicate that the Tx pin needs to be enabled\ disabled.

got it

i have a rs485-sniffer (link). Is it possible to use it for development purposes?

In the afternoon I have time to test a few setups. Currently I only connected three Nanos via RS485 and the RS485-Sniffer and made a simple protocol to verifiy communication.

I will report back with my attempts.

Do you really want to risk bricking the devices that are not easily accessible? Since everything is connected to the Raspberry Pi that would seem to be the place to do the processing, with the Nano's being used for data collection.

this is a problem. avrdude and standard bootloader will not switch the transmit enable pin

I tried reactivating my RS485 sketches and already ran into problems. Following is my current setup. The connection follows this project.

Mastercode:

#include <Arduino.h>

const int EnableTX = 3;

void setup() {
  Serial.begin(9600);
  pinMode(EnableTX,OUTPUT);
}

void loop() {  
  digitalWrite(EnableTX, HIGH);
  Serial.print("x");
  digitalWrite(EnableTX, LOW);  
  delay(1500);
}

Slavecode:

#include <Arduino.h>

const int EnableTX = 2;

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(EnableTX,OUTPUT);
}

void loop() {

  if(Serial.available()>0) {
    char x = Serial.read();
    digitalWrite(LED_BUILTIN, HIGH);
    delay(250);
    digitalWrite(LED_BUILTIN, LOW); 
    delay(250);  
  }
}

The idea is just to check communication between the two Nanos and listening in with the Sniffer. Sadly no messages are received. The Tx-Led on the Master blinks in the right frequency and on the oscilloscope I detect a signal between A-B (measuring channel 1 and subtracting channel 2)

01111000

this corresponds to the character 'x'. On the slave Rx-Led is not blinking and the built in LED also will also not blink. Therefore the serial.available() path is not reached. Listening in on COM14 (the RS485 sniffer) occasionally shows 'x'.

The sniffer and the Nanos are powered over the USB-Hub, but the monitors for the Nanos are closed.

My questions:

  1. Can I power the Nanos over USB since it is also used for the serial monitor?
  2. Can the Sniffer be used to send\read commands to either Master or Slave?