Device naming scheme

Hey! I dug up the device naming scheme from the chat logs, and I thought it would be a good idea to post it here so that it doesn’t get lost.

Here’s an example device name: CHASW-24AD43-1

We can split this up into 3 parts, separated by dashes -.

Part 1

This is a sequence of letters that describe the characteristics of the device.

Note that the letters should appear in the order they are shown in the table. For example CHASW is valid, but AWCHM is not.

Code Meaning
CH The device belongs to Connected Humber (or a member thereof)
A Air quality
S Static device - it doesn’t move around and change it’s location)
M Mobile device - it moves around
W Wemos
R Raspberry Pi
N NodeMCU

For example, CHASW-123abc-1 has the following properties:

  • CH - It’s a Connected Humber device
  • A - It measures air quality
  • S - It is not expected that it will be moving around any significant distance
  • W - It is a Wemos-based board

Part 2

The id of the device comes after the first dash -.

For Raspberry Pis

The last 8 digits of the CPU serial number should be used. This can be obtained with the following Bash for example: cat /proc/cpuinfo | awk '/^Serial/ { gsub("^0+", "", $3); print $3 }'.

CHASR-6f3bd82c-1
CHASR-ea086b27-1

For WiFi-based Arduinos

This is the last 6 digits of its MAC address. Example device models include the Wemos D1 R1, and the NodeMCU family of devices.

It is preferred that the device id be in hex.

CHASW-56AB6D-1
CHASN-623611-1

Part 3

The device number comes last, after the second dash -. This is a number that starts at 1 and increments every time a static device is moved for whatever reason.

For example, CHASW-123abc-1 is moved to a new house up the road.

The device number would be incremented and a new entry in the device table created, giving it the new name CHASW-123abc-2.

To this end, does CHASN-084568-1 have the correct name? It actually measures temperature, pressure and humidity - and it’s CHASW-0451C4-1 and CHASN-74F12C-1 at the same location that measure air quality.

They are both valid devices. Check my 4. It doesnt actually matter what they measure.

1 Like

The scheme is design to give it a unique ID, the first part is to make it easy to work out which project it is for. Easy at the moment, but hopefully as people add other projects to connectedhumber it expands.
For RaspberryPi the serial is used by me, so it’s a bit longer. For nodeMCU send binary not hex serial as that’s what it reports in ESPeasy.

So on a RaspberryPi in Python3 (on GitHub but is still a pull request waiting)

def get_serial():
    # Extract serial from cpuinfo file
    cpuserial = "N0N0N0N0"
    try:
        f = open('/proc/cpuinfo','r')
        for line in f:
            if line[0:6]=='Serial':
                cpuserial = line[18:26]
        f.close()
    except:
        cpuserial = "ERROR000"

     return cpuserial

and

def get_clientid():
    clientid = list("CHAtR-dddddddd-x")
    clientid[3] = DEVICE_TYPE
    clientid[6:14] = get_serial()
    clientid[15] = LOCATION_NUMBER

     return "".join(clientid)

DEVICE_TYPE and LOCATION_NUMBER are constants set at the start (there is also an override for the full string)

DEVICE_TYPE = "S"  # "M" for mobile
LOCATION_NUMBER = "1" # increase if location is moved for the same device

dev is then set to this at the start

Cool! Just wanted to make sure I had it right, @BNorman :slight_smile:

…I see? Could you give some example device names please? That might help make it a bit clearer.

I’ll update my original post with the new information.

It is just two digits longer, that’s all.
The ‘serial’ part can be anything really. It is just the part that tries to keep them unique.
123abc

e.g. For a RaspberryPi,
CHASR-6f3bd82c-1 and CHASR-ea086b27-1

I could trim the 6f and ea off, but it seems daft since I have them. Less change of duplicated appearing. A RaspberryPi uses a RandomID for its ‘serial’, there are know duplicates out there. Also as they can have, no, one or two inbuilt MAC addresses, that cannot be used, which is why you can’t rely on it for a LoraWAN device, but have to make your own. (Ethernet is given the last 6 from the serial number)

The ESP’s with its shorter ID will have more duplicates out there (there must be way more ESPs out there in all the devices too)
Chances are still low for the amount we will use, unless the supplier has made a load of cheap duplicate MAC address setups.

Thanks!

I’ve updated the original post.