0

Simply: I'm trying to find what physical pin on the Raspberry PI 4B that attributes like board.D5 map to.

QUESTIONS:

  1. Can I simply get or create a mapping of the board.py pin attributes to actual physical pins? I.e. board.D5 = ?

  2. If not, I need to figure out what board.py attribute is associated with pin 33 (GPIO 23, PWM1)?


DETAILS:

I'm using the kiln-controller.py software from here. The code was working fine with an older Pine64a, but I'm converting to a Raspberry Pi 4B. kiln-controller.py uses the Adafruit_Python_PlatformDetect board.py to configure the input and output pins.

I have the thermocoupler working - but the pinouts do not seem to correspond to the instructions in the project page.

enter image description here

The kiln-controller's config.py file is setting the MAX31855-CS to board.D5. With CS = board.D5 and MY wiring (with CS physically connected to GPIO21 GPCLK1 PIN29)- the thermocoupler works ... which leads me to believe that board.D5 != GPIO5.

Ultimately, the point of all this is that the config.py also sets the signal output to the kiln heater control as gpio_heat = board.D23. The output wire is physically attached to pin33 (GPIO 23, PWM1.) But with gpio_heat = board.D23 the wire is getting no signal out. How can I find which board.X pin to use in the config file for pin 33?

config.py

# To control the kiln, one gpio pin is used as an output. Pick any 
# you like. I chose gpio pin 23. This output is used to control a
# zero-cross solid-state-relay.
try:
    import board
    spi_sclk  = board.D11 #spi clock
    spi_mosi  = board.D10 #spi Microcomputer Out Serial In (not connected) 
    spi_miso  = board.D9  #spi Microcomputer In Serial Out
    spi_cs    = board.D5  #spi Chip Select
    gpio_heat = board.D23 #output that controls relay
except NotImplementedError:
    print("not running on blinka recognized board, probably a simulation")

1
  • 1
    Ask Adafruit for documentation and why they want to use this obscure code.
    – Milliways
    Commented Apr 15 at 11:09

1 Answer 1

1

It looks as if your board.<n> IS associated with GPIO <n>. You can deduce this from Raspberry Pi's SPI0 port. This is on GPIO pins 9, 10 and 11:

- GPIO 10 (SPI0 MOSI) 19
- GPIO 9 (SPI0 MISO) 21
- GPIO 11 (SPI0 SCLK) 23

It corresponds with your:

spi_sclk  = board.D11 #spi clock  
spi_mosi  = board.D10 #spi Microcomputer Out Serial In (not connected)   
spi_miso  = board.D9  #spi Microcomputer In Serial Out  

I have added this pinout from raspberrypi.com in response to your comments, and you can see from this that GPIO5 is pin 29 - so board.D5 DOES correspond to GPIO5 (and the fact that CS on pin 29 works as intended proves it).

enter image description here

7
  • Perhaps. I did find this: learn.adafruit.com/circuitpython-essentials/… which describes how to figure out which physical pins are associated with the board.Ax or board.Dx objects. They provide a script code.py which is supposed to enumerate it - but it seems to only work in CircuitPython - which I'm trying to figure out on the RPi4b. However, in your answer above you show SPI0 MOSI as pin 19 (correct) but GPIO 10 (incorrect according to the diagram I got from the RPi4B schematics page. <cont> Commented Apr 18 at 10:16
  • I'm also curious as to why pin 18 (GPIO5) does NOT work with the thermocoupler when the config says spi_cs = board.D5 #spi Chip Select, but DOES work when I attach the CS cable to GPIO21/GPclk1/Pin29? Commented Apr 18 at 10:18
  • 1
    This is because your pinout map has to be wrong. I have added a pinout from raspberrypi.com to my answer, and you can see from this that GPIO5 is pin 29 - so board.D5 DOES correspond to GPIO5 (and the fact that CS on pin 29 works as intended proves it).
    – Lee-xp
    Commented Apr 19 at 14:17
  • 1
    That makes sense. Thanks! Can you link where you got this image, so I can bookmark it? Commented Apr 19 at 14:22
  • 1
    Cool. It is at: raspberrypi.com/documentation/computers/raspberry-pi.html.
    – Lee-xp
    Commented Apr 19 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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