1

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.

Sogeking
  • 33
  • 1
  • 4

3 Answers3

8

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.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
0

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...

BJ Black
  • 586
  • 3
  • 6
0

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

Milliways
  • 62,573
  • 32
  • 113
  • 225