Created
May 20, 2017 16:29
-
-
Save xmichaelx/26853d711fa9731e0066b7694a157e8d to your computer and use it in GitHub Desktop.
gets name of the raspberry pi device it operates on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_revision(): | |
try: | |
with open('/proc/cpuinfo','r') as f: | |
for line in f: | |
if line.startswith('Revision'): | |
return line.split(":")[1].strip() | |
except: | |
return None | |
# sourced from: http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/ | |
def get_model(): | |
revision = get_revision() | |
return { | |
'0002' : 'Model B Rev 1', | |
'0003' : 'Model B Rev 1', | |
'0004' : 'Model B Rev 2', | |
'0005' : 'Model B Rev 2', | |
'0006' : 'Model B Rev 2', | |
'0007' : 'Model A', | |
'0008' : 'Model A', | |
'0009' : 'Model A', | |
'000d' : 'Model B Rev 2', | |
'000e' : 'Model B Rev 2', | |
'000f' : 'Model B Rev 2', | |
'0010' : 'Model B+', | |
'0013' : 'Model B+', | |
'900032' : 'Model B+', | |
'0011' : 'Compute Module', | |
'0014' : 'Compute Module', | |
'0012' : 'Model A+', | |
'0015' : 'Model A+', | |
'a01041' : 'Pi 2 Model B v1.1', | |
'a21041' : 'Pi 2 Model B v1.1', | |
'a22042' : 'Pi 2 Model B v1.2', | |
'900092' : 'Pi Zero v1.2', | |
'900093' : 'Pi Zero v1.3', | |
'0x9000C1' : 'Pi Zero W', | |
'a02082' : 'Pi 3 Model B', | |
'a22082' : 'Pi 3 Model B' | |
}.get(revision, None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment