I have an easy circuit wired up, with an LED connected to pin 18 on the BOARD reference. I run a simple program to put pin 18 to HIGH, which turns the LED on, and then a couple of seconds later, I set pin 18 to LOW, and finally I end my program with GPIO.cleanup().

At this point the LED is off, which means that pin 18 is off (LOW). Now I reboot or restart my Raspberry Pi, and when it boots back up, the LED on pin 18 turns on again, even though the pin was off before I rebooted the Raspberry Pi.

Why may this be happening? How can I configure a specific pin, like pin 18 to be off when the Raspberry Pi boots up? And I don't want any GPIO pins to be on HIGH when the Raspberry Pi boots up.

I am concerned about this problem, because let's say that pin 18 is connected to a DC motor on a robot, and when the Raspberry Pi boots up, the motor will turn on, and this is not something that I want because that will interferes with the whole structure of the robot, and some motors might start and others won't, depending on the pins they are connected to. I want to manually turn on all the motors in a synchronized manner.

One other thing is that not all the pins have this problem. Some stay off when the Raspberry Pi boots, but others don't.

  • Is that LED on as brightly as it would be when you set it high, or is it just glowing dimly?
    – goldilocks
    Jun 18 '15 at 8:19
  • There is 3.3 volts applied to it. Jun 18 '15 at 12:07
  • So if you go into /sys/class/gpio and export pin 18, what state does the system then say it is in if you change nothing?
    – goldilocks
    Jun 18 '15 at 14:05
  • When I write "/sys/class/gpio" , it says "-bash: /sys/class/gpio: Is a directory". I am not sure how to export a specific pin. Jun 18 '15 at 15:43
  • There are oodles of explanations of that, so I won't bother to regurgitate. That example is kind of heavy on the echo, which writes, i.e., sets something. After you export it you want to refrain from that and just use cat, which reads, to check the direction and the value.
    – goldilocks
    Jun 18 '15 at 15:50

At powerup the GPIOs are pulled either high or low through the internal resistors. Whether the pull is high or low for a particular GPIO is detailed on page 102 of BCM2835 ARM Peripherals.

As the Linux kernel is started and if device tree is enabled (likely) then it will reconfigure the GPIOs according to the device tree settings. Modules loaded from /etc/modules could also update the GPIO state.

Any other software you have running at start up could potentially reconfigure the GPIOs subsequent to the device tree settings and module loads.

It is safest to find a hardware solution if you have hardware which could be incorrectly triggered at system startup.


When the Raspberry Pi boots the GPIO lines are reset to the chip default, then the OS is loaded and resets them to the OS default. There is no way to "remember" the settings across a reboot. See also What is the power on state of the GPIOs? and GPIO state after boot.


I know it's pretty late. To answer. You can write a python script or bash script which manually sets the pin to low and schedule a cron job to run at every boot. You won't need to modify any system/critical files. Apart from cron

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.