corny / luftdaten-python

Python program for the luftdaten.info sensor network (e.g. usage with Raspberry-Pi)
MIT License
20 stars 16 forks source link

raspberry pi serial #1

Closed ricki-z closed 7 years ago

ricki-z commented 7 years ago

The following function will read the raspberry pi serial no.:

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

  return cpuserial

So the users don't need to look for this.

corny commented 7 years ago

thanks a lot!