getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python

At the beginning

I unexpectedly got RPi 3 (I bought RPi 2 on ebay and for some reason I received RPi 3), but the programs I've made so far haven't moved in various ways ^^ ;;; From November 24th Even within the range I noticed in a little over two weeks until today

--tty is now ttyS0 instead of ttyAMA0 --/ sys / class / leds / led1 / is gone and I can't turn the red LED on and off with the shell

There seems to be some places where you have to recognize whether it is RPi 3 and change the processing.

So, in any case, I can use it later also here As I reported in the supplement, [getpimodel](https://github. I made a package called com / UedaTakeyuki / getrpimodel) At that time, I made a brief report that was not very kind, so I am sorry to say that I will report the details again here.

Therefore, if there are any inefficient parts or mistakes, we would be very grateful if you could give us your frank guidance and suggestions. Thank you for your cooperation.

Installation

python


pip install getrpimodel

How to use

As a python program

python


python -m getrpimodel [--s] 

As a python library

python


import getrpimodel

print (getrpimodel.model())
print (getrpimodel.model_strict())

Return value

This table "model" column string without parentheses (--s and model_strict () leave parentheses as they are) Specifically, B, A, B +, etc. --s and model_strict () like B (Beta)

logic

Check according to this table

code

It is available on here.

Code usage example

Here, I use it like this

import getrpimodel

# setting

if getrpimodel.model() == "3 Model B":
  serial_dev = '/dev/ttyS0'
  stop_getty = 'sudo systemctl stop [email protected]'
  start_getty = 'sudo systemctl start [email protected]'
else:
  serial_dev = '/dev/ttyAMA0'
  stop_getty = 'sudo systemctl stop [email protected]'
  start_getty = 'sudo systemctl start [email protected]'```

#PyPI HereI registered with

#Acknowledgments How to register with PyPIHereI was allowed to refer to. It was very helpful and thank you.

#Impressions getrpimodel, convenient for sober

Recommended Posts

getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python
raspberry pi 1 model b, python
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
USB boot with Raspberry Pi 4 Model B (3) LVM edition
Use vl53l0x with Raspberry Pi (python)
Run BNO055 python sample code with I2C (Raspberry Pi 3B)
Using a webcam with Raspberry Pi
Control the motor with a motor driver using python on Raspberry Pi 3!
[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
USB boot on Raspberry Pi 4 Model B
Build a Tensorflow environment with Raspberry Pi [2020]
Make a wash-drying timer with a Raspberry Pi
Infer Custom Vision model with Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Create a car meter with raspberry pi
Working with GPS on Raspberry Pi 3 Python
Detect analog signals with A / D converter using python on Raspberry Pi 3!
[Python + PHP] Make a temperature / humidity / barometric pressure monitor with Raspberry Pi
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
Create a Python multi-user platform with JupyterHub + JupyterLab on Rapsberry Pi 3B +!
Discord bot with python raspberry pi zero with [Notes]
I tried L-Chika with Raspberry Pi 4 (Python edition)
Get CPU information of Raspberry Pi with Python
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Measure CPU temperature of Raspberry Pi with Python
Creating a temperature control system with Raspberry Pi and ESP32 (3) Recipient Python file
DigitalSignage with Raspberry Pi
Python3> round (a --b, 7)
Run LEDmatrix interactively with Raspberry Pi 3B + on Slackbot
Try debugging Python on Raspberry Pi with Visual Studio.
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
A memorandum when making a surveillance camera with Raspberry Pi
Display USB camera video with Python OpenCV with Raspberry Pi
Let's operate GPIO of Raspberry Pi with Python CGI
Raspberry Pi with Elixir, which is cooler than Python
[Note] Use a wired LAN connection device with WiFi-Eth bridge on Raspberry Pi 4B
Raspberry Pi 4B initial setting
Mutter plants with Raspberry Pi
[AtCoder explanation] Control ABC180 A, B, C problems with Python!
[AtCoder explanation] Control ABC188 A, B, C problems with Python!
Create a web surveillance camera with Raspberry Pi and OpenCV
Python beginner opens and closes interlocking camera with Raspberry Pi
I tried running Movidius NCS with python of Raspberry Pi3
Create an LCD (16x2) game with Raspberry Pi and Python
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
I made a resource monitor for Raspberry Pi with a spreadsheet
[AtCoder explanation] Control ABC158 A, B, C problems with Python!
SSD 1306 OLED can be used with Raspberry Pi + python (Note)
Recognize red objects with python
Create a python machine learning model relearning mechanism with mlflow
I made a surveillance camera with my first Raspberry PI.
Finding pi with a three-line function [Python / Monte Carlo method]
Creating a temperature / humidity monitor with Raspberry Pi (pigpio version)
Create a directory with python
[AtCoder explanation] Control ABC164 A, B, C problems with Python!
[AtCoder explanation] Control ABC168 A, B, C problems with Python!
Connect Raspberry Pi to Alibaba Cloud IoT Platform with Python
How to upload a file to Cloud Storage using Python [Make a fixed point camera with Raspberry PI # 1]
Getting Started with Heroku-Viewing Hello World in Python Django with Raspberry PI 3
I made a web server with Raspberry Pi to watch anime