I am porting a tool developped with Python from RPi2 to RPi3, it uses the /dev/ttyAMA0 port to communicate.

The problem is that in Raspberry 3 models, this is now used by the BlueTooth (no disabling it). The different RPis using the tool could be on Wheezy or Jessy, so no serial0 for me.

I need a simple method, like a command to compare hardware, or so, allowing the tool to know if it runs on RPi2 or 3.

Would some of you know any trick to achieve this ?

Thanks in advance.


3 Answers 3


cat /proc/cpuinfo | grep Revision

RPi 2 boards will show board revisions a*1040, a*1041 or a*2042, while an RPi 3 board will give you a*2082. Here's a list of board revisions.

See also: Getting Your Raspberry Pi Revision Number Using Python.

  • is there a published list anywhere of what board returns what revision ? Sep 13, 2016 at 13:26
  • 1
    @KennetRunner elinux.org/RPi_HardwareHistory
    – joan
    Sep 13, 2016 at 13:34
  • Perfect ! Works like a charm. The revision will still go up with the newer versions, right ?
    – Sogeking
    Sep 13, 2016 at 13:38
  • @Sogeking I'd say yes.
    – Aloha
    Sep 13, 2016 at 23:35

I can't recommend using a board revision to determine capabilities in this way; any such method is unlikely to be forward compatible.

See How do I make serial work on the Raspberry Pi3 for a discussion on the serial ports and particularly /dev/serial0. Looks like the pi3's UART serial has been nerfed a bit and requires some clock help to behave...

  • I do not need forward compatibility, and I cannot use serial0 because some boards are on Wheezy. The thing is these boards will be left alone and not touched. Thanks for your help.
    – Sogeking
    Sep 14, 2016 at 8:46

You could try to check model, but a better solution is to use '/dev/serial0' which selects the appropriate port. Note serial is disabled by default on Pi3

  • As I said, some boards are on Wheezy and the alias serial0 does not exist here. But thanks
    – Sogeking
    Sep 14, 2016 at 8:45
  • @Sogeking It works on Jessie. Wheezy does not work on Pi3. If '/dev/serial0' does not exist you know you are using an obsolete OS. Either way you would be better testing for the existence of the port you want to use rather than some proxy.
    – Milliways
    Sep 14, 2016 at 10:36
  • I agree with you, but I have directives limiting me :/
    – Sogeking
    Sep 14, 2016 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.