1

This is in reference to this thread where they are all using GPIO4. I've got A0 of an arduino going into an arduino nano (using firmata) and then into GPIO4 since it appears to be the only pin that'll work. I have tried other pins and noticed that other pins do not work and I was wondering if someone could explain why only GPIO4 works for this?

Thanks guys, Dave

2
  • 1
    Please compose the question so that readers don't have to click and read something else to understand what you ask about.
    – techraf
    Commented Jan 27, 2017 at 5:49
  • Because that's the only pin providing GCLK signal. For the same reason you can only use GPIO11 as SPI clock. Commented Feb 10, 2017 at 14:15

1 Answer 1

2

The DS18B20 is a (Dallas) 1-wire bus temperature sensor. It uses one wire for control and data.

Early versions of Pi software only allowed for the 1-wire bus to be started on GPIO4. You are looking at old or incomplete tutorials.

Recent versions of Pi software allow the 1-wire bus to started on any spare GPIO. There is still the limit of just one bus though.

To configure the 1-wire bus use device tree.

See /boot/overlays/README for details.

Name:   w1-gpio Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *don't* need a GPIO to drive an external
        pullup.
Load:   dtoverlay=w1-gpio,<param>=<val>
Params: gpiopin                 GPIO for I/O (default "4")
        pullup                  Non-zero, "on", or "y" to enable the parasitic
                                power (2-wire, power-on-data) feature

E.g. to use GPIO12 (pin 32) use

dtoverlay=w1-gpio,gpiopin=12

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