1

My attempt is to know how to identify the board I'll be sending parameters to in a serial connection like rs485. I'm asking because I will have about 11 or so mcu's as "Rx slaves" while my pc is the Master "Tx". I want to know how my code block is being sent to a specific board will be received by just that board and not all the other boards connected to that Rx port COM?

If I send 'LT2|LP3|LM5|LR4|LI6' and I want that to be for one specific Arduino, I don't want all the other 10 arduinos to take those parameters in this serial Rx line.

@Federico Fissore you mentioned in another post "Some boards, when connected to a computer, publish their serial number. My Arduino Uno R3 says"

[16818.451423] usb 3-2: SerialNumber: 85235353137351E02242

how and where can i find this info?

  • You can't; it's locked up in the other chip. – Ignacio Vazquez-Abrams Sep 3 '15 at 16:55
  • @ Ignacio Vazquez-Abram dam! ok thanks thought i can just use that to add to my const unique address before i Tx to serial – Frank Sep 3 '15 at 17:20
  • The simplest thing would be to burn a serial number into each chip's EEPROM, and interrogate that at startup. – Nick Gammon Sep 3 '15 at 21:39
  • @Nick Gammon i dont think that could have sounded more advance for me then anything thus far lol any links on how to go about that ? im just not getting the big picture thanks! – Frank Sep 4 '15 at 0:08
1

I dont think that could have sounded more advanced for me then anything thus far. Any links on how to go about that?

First, run a sketch like this for each board:

#include <EEPROM.h>

const int SERIAL_NUMBER_ADDRESS = 1023;
const byte SERIAL_NUMBER = 42;
void setup ()
  {
  // don't do it if it has been done before
  if (EEPROM.read(SERIAL_NUMBER_ADDRESS) != SERIAL_NUMBER)
    EEPROM.write(SERIAL_NUMBER_ADDRESS, SERIAL_NUMBER);
  }  // end of setup

void loop () { }

The serial number address can be any address in range for that chip - a Uno has 1024 bytes. I chose 1023 to leave the other addresses free, but it could be 0. Anything you don't need for any other purpose.

Then write a different serial number to each board (eg. 42, 43, 44, 45). Obviously you change the sketch each time you upload to a different board.


Once you have done this (once per board) now each board "knows" its serial number. You can detect this in your main sketch:

#include <EEPROM.h>

const int SERIAL_NUMBER_ADDRESS = 1023;
byte serialNumber;
void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  serialNumber = EEPROM.read(SERIAL_NUMBER_ADDRESS);
  Serial.print (F("Serial number of this board is: "));
  Serial.println (int (serialNumber));
  }  // end of setup

void loop () { }

Output for me in this case was:

Serial number of this board is: 42

Also I have a post about RS485 on my forum.

1

Just assign every node a variable like "const int ID = 5" and so on and then before sending the instructions send a line terminator, the ID, line terminator and the data you need to send to the nodes. Every device listens but they all wait their ID to accept the commands. For example:

Serial.write('\n');
Serial.print(ID);
Serial.write('\n');
Serial.print(|LT2|LP3|LM5|LR4|LI6);
Serial.write('\n');

NOTE: This is the easiest way. Most likely not the most reliable or optimized.

  • Comments are not for extended discussion; this conversation has been moved to chat. (cc @Frank'sDesig'Nature) – Anonymous Penguin Sep 4 '15 at 0:58
  • 2
    why not just use a usb tower and connect all my arduino's to that tower usb style just like when they plug into my pc and connect the other end of the usb tower into my pc ? doesn't that sound more easy and less complex? this way i can just use the # of the com port as the address? – Frank Sep 4 '15 at 17:51
  • @Frank Yes that would work. – Avamander Jan 21 '16 at 21:15

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.