13

I would like to identify which RaspberryPI hardware instance is booting on my network.

I have plans for using a LOT (not just 10) of them as clients in a larger solution, but I would like to reuse the SD-image for them all.

Is there any kinda way to identify them from each other, unless I place somekinda serial code in a file somewhere in the OS?

Btw. I use MONO/C# for programming, but I am just curious to know if the PI has a hardware serialnumber somehow or not?

BerggreenDK
  • 364
  • 1
  • 3
  • 14

3 Answers3

14

You can use the same number used for buying the MPEG license.

Quoting MPEG-2 license key:

To find your serial number, type cat /proc/cpuinfo at the command line as shown below:

pi@raspberrypi:~$ cat /proc/cpuinfo

Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7
Hardware        : BCM2708
Revision        : 1000002
Serial          : 000000000000000d

Serial is what you're looking for.

techraf
  • 4,353
  • 10
  • 32
  • 43
Remo.D
  • 544
  • 5
  • 11
6

You could use the MAC address of the ethernet adaptor; use a statement something like this to extract it into a variable:

mysn=`ifconfig eth0 | grep HWaddr |sed -e's/.*HWaddr\s\(\S*\).*/\1/'`
Jacobm001
  • 11,904
  • 7
  • 47
  • 58
TomG
  • 1,181
  • 2
  • 10
  • 22
4

In C# Mono I'm doing this:

private string GetRpiSerial()
{
    CommandSync("cat /proc/cpuinfo | grep Serial | cut -d ':' -f 2 > /home/pi/serial.txt");

    using (var sr = new StreamReader("/home/pi/serial.txt"))
    {
        return sr.ReadLine().Trim();
    }
}

public static void CommandSync(string cmd, string args)
{
    var info = new ProcessStartInfo();
    info.FileName = "/bin/bash";
    info.Arguments = string.Format("-c \"sudo {0} {1}\"", cmd, args);
    info.UseShellExecute = false;
    info.RedirectStandardOutput = true;

    var p = Process.Start(info);
    p.WaitForExit();
}

And retrieve anywhere with:

var rpiSerial = GetRpiSerial();
Jacobm001
  • 11,904
  • 7
  • 47
  • 58
Tico Fortes
  • 156
  • 2