2
$\begingroup$

This might be a out of league question and may seems to be very odd.I am using multiple Arduino UNO boards over network and want to assign a GUID and Serial number to each board so that when ever they send any data to a central server, server is able to find which Device it is if we have assign name for each device.

  • first way to do this is to assign GUID and serial number of device before each message that is send to central server manually while programming and then burn that hex to arduino.

Now is there any way out that we can burn a program that always give a output as a string (GUID+Serial number of device) like we program EEPROM for this and then burn our main code in Arduino which pick the GUID+Serial ID combo from EEPROM and write it before every message which arduino is pushing to central server.

Or my another way of asking is can we program EEPROM with a different program and our Arduino separately like 2 files running in parallel or is it not possible?

Is there any other way of doing this?

$\endgroup$
3
  • $\begingroup$ Instead of a GUID, check out the UUID (en.wikipedia.org/wiki/Uuid) $\endgroup$
    – ott--
    Aug 16 '13 at 20:18
  • $\begingroup$ Please post whatever details you can about your GSM module. $\endgroup$
    – Ian
    Aug 29 '13 at 19:41
  • $\begingroup$ I used Arduino as an AVR (non of that Arduino language/IDE nonesense), and yes it was entirely possible to program different ranges of even flash, let alone programming flash and EEPROM separately. avrdude is the name of the programmer. $\endgroup$
    – Shahbaz
    Aug 1 '17 at 17:06
3
$\begingroup$

I would create a small sketch that allows you to communicate over serial port that will let you create a GUID on the desktop computer and write it to the EEPROM of your uno to a known location.

Then later on in your networked arduino code you can use that saved value. I've done this before and it's pretty simple to implement. You can even copy / paste guid values from the web like this Online GUID Generator.

See this for simple usage. Arduino EEPROMWrite Command

Another option if you have networking already active is to setup a server on your network and have the machines request a GUID from a network server if they don't have one already present on the device, then write that to the EEPROM.

Either way it should be a small step you perform when first programming your devices.

$\endgroup$
3
$\begingroup$

The answer to this question depends entirely on the type of connection you are using to build your network.

Assuming that when you say you have arduinos "on a network" you are using ethernet shields or similar to put them on an ethernet network, one way to accomplish your goal would be to take advantage of the MAC address on the ethernet shield as this is a pre-existing globally-unique identifier. The MAC address is appended to every ethernet frame. Now, you only have access to that data at Level 2 (the "link layer") of ethernet and you are not going through a switch / hub which will modify the frames which you almost certainly are.

So instead, you could have your hub or switch assign IP addresses through DHCP based on the MAC address of the ethernet shield. This is sometimes referred to as "link layer filtering." Then when you get packets with data from the Arduino, you know which one it comes from by the source IP address on the packet.

You suggested you might be using cellular data, IP addresses are probably dynamic and the problem becomes more difficult. You would need to talk to your provider and see if you can get static IP addresses.

If you are using SMS, then simply identify by phone number.

$\endgroup$
11
  • $\begingroup$ You can't read the MAC address from a TCP/IP packet -- you only get the data payload. However, one thing you might be able to do is have the Arduino boards read their own MAC address and explicitly append that onto the payload portion of the packets they send. $\endgroup$
    – Ian
    Aug 27 '13 at 18:56
  • $\begingroup$ @lan: so that is what i was asking.If i am not using Ethernet shield as suggested by foobarbecue, how i am able to access the MAC ID of the arduino board i am using? $\endgroup$
    – shailendra
    Aug 28 '13 at 8:00
  • $\begingroup$ @shailendra if you aren't using an Ethernet interface, then you don't have a mac address. $\endgroup$ Aug 28 '13 at 17:55
  • 1
    $\begingroup$ @foobarbecue: The MAC address is indeed part of what gets sent "on the wire" (and received by the destination host), but this information is not available to the reader of the network socket -- it's discarded by the lower layer. If you have a coded-up example that demonstrates otherwise, I'd really like to see it. Ordinarily if you want to get the MAC address of an IP address (which you can get from the packet), you use arp. $\endgroup$
    – Ian
    Aug 28 '13 at 19:24
  • 1
    $\begingroup$ @foobarbecue - It would be better to add information in comments to your answer, that way all of these comments can be tidied up (deleted) and they will no longer distract readers from your answer. $\endgroup$
    – Mark Booth
    Aug 31 '13 at 17:26
1
$\begingroup$

(I know it's old but I still feel I need to add my solution)
I have a similar issue, multiple units sending data and need a way to know what unit it is. I create a random unitId and save it in eeprom. If needed I can read it on serial port or by activating one at a time and check on the receiver side.
I guess I could easily write a small sketch to write a specific unitId if that was needed.
Code I have in setup()

long unitId;
...
Setup(){
 long notunitId;
 ..
 pinMode(RESET_PIN, INPUT_PULLUP);
 unitId = (long)EEPROM.read(0) << 24 | (long)EEPROM.read(1) << 16 | (long)EEPROM.read(2) << 8 | (long)EEPROM.read(3);
  notunitId = (long)EEPROM.read(4) << 24 | (long)EEPROM.read(5) << 16 | (long)EEPROM.read(6) << 8 | (long)EEPROM.read(7);
  if (digitalRead(RESET_PIN) == LOW) {
    Serial.println("Force generation of a new unitId");
    unitId = notunitId = 4711;
  }
  if (unitId == -notunitId) {
    Serial.print("unitId from eeprom: ");
    Serial.print(unitId, HEX);
  } else {
    randomSeed(analogRead(7)*analogRead(6)*analogRead(5)+micros());
    unitId = random();
    notunitId = -unitId;
    EEPROM.write(0, unitId >> 24 & 0xFF);
    EEPROM.write(1, unitId >> 16 & 0xFF);
    EEPROM.write(2, unitId >> 8  & 0xFF);
    EEPROM.write(3, unitId     & 0xFF);
    EEPROM.write(4, notunitId >> 24 & 0xFF);
    EEPROM.write(5, notunitId >> 16 & 0xFF);
    EEPROM.write(6, notunitId >> 8  & 0xFF);
    EEPROM.write(7, notunitId     & 0xFF);

    Serial.print("Generated new unitId: ");
    Serial.print(unitId, HEX);
  }
  Serial.println();

And in loop I then just add unitId to the message wherever needed.

$\endgroup$

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.