I want to make pin no.15 (GPIO 22) as HIGH automatically, when the RPi is powered up. (Raspberry Pi 3 Model B)
The status of the pin is used for a power on logic. This pin is used to check whether the device is ON or OFF.
Any help is appreciated.
You cannot control the state of a pin on power up. The default state of pins is given in https://raspberrypi.stackexchange.com/a/32643/8697
You can set the state of pins in Device Tree, but there will be some delay. The answer https://raspberrypi.stackexchange.com/a/32643/8697 discuses this. Whether that delay is acceptable depends on what you are connecting.
The default Device Tree settings configure most pins as inputs.
You would be better selecting a pin which is high by default, but the choices are limited. Another option is to reverse your circuitry so a Low is the default.
It occurred to me you could use the inbuilt
gpio-poweroff if you are prepared to invert your logic.
dtoverlay=gpio-poweroff,gpiopin=22 would cause the pin to go low after the Pi powers up (still NOT on power up, but using DT very shortly after). When the Pi is shut down it would go high.
There is an option
active_low, but this seems to require custom code.
Info: Drives a GPIO high or low on poweroff (including halt)
Params: gpiopin GPIO for signalling (default 26)
active_low Set if the power control device requires a high->low transition to trigger a power-down. Note that this will require the support of a custom dt-blob.bin to prevent a power-down during the boot process, and that a reboot will also cause the pin to go low.
Found the solution.
made an executable with the pin I want to be HIGH all the time (I've used wiringPi library) after the Pi is powered up. Then I put the file in
sudo nano /etc/rc.local
exit 0 , append the following :
sudo /path/to/the/executable/my_prgm &
The '&' is a must( for continuous running in background -- for producing pulses, otherwise will execute once -- good for pin state change). Don't forget to put it there.
Ctrl+X , followed by Y and Enter, to save the file. And `reboot'
To kill it, in the terminal ,
sudo killall my_prgm