CharlyDelta
Posts: 97
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

.sh at startup (Solved)

Wed May 23, 2018 3:12 am

Hello..

I try to make the leds (BrightPi) turn on when starting the RPI.
In command line, sudo ./led.sh works.

I created a bash script :

Code: Select all

#! /bin/bash
 i2cset -y 1 0x70 0x00 0xa5
i2cset -y 1 0x70 0x09 0x0f
i2cset -y 1 0x70 0x01 0x32
i2cset -y 1 0x70 0x03 0x32
i2cset -y 1 0x70 0x06 0x32
i2cset -y 1 0x70 0x08 0x32

exit

chmod a+x led.sh
chmod 777 led.sh

/home/pi/.config/lxsession/LXDE-pi/autostart

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@bash sudo /home/pi/led.sh
What's wrong with that ?,... any idea ?
Last edited by CharlyDelta on Wed May 30, 2018 10:27 am, edited 3 times in total.

CharlyDelta
Posts: 97
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: .sh at startup

Thu May 24, 2018 12:17 pm

Is there another way to make the leds light up at startup??

User avatar
thagrol
Posts: 858
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: .sh at startup

Thu May 24, 2018 12:54 pm

CharlyDelta wrote:
Thu May 24, 2018 12:17 pm
Is there another way to make the leds light up at startup??
/home/pi/.config/lxsession/LXDE-pi/autostart does run at start up. It runs when the pi user logs in to the GUI desktop. WIth no user logged in it won't run. With the pi user logged into to more than one desktop (console and vnc) it'll run more than once.

Make sure your script can be run by everyone then try adding

Code: Select all

/home/pi/led.sh &
to /etc/rc.local but make sure you put it above the line that reads "exit 0"
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

CharlyDelta
Posts: 97
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: .sh at startup

Fri May 25, 2018 2:49 am

Thanks, it's working!!

CharlyDelta
Posts: 97
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: .sh at startup (partially closed)

Sun May 27, 2018 12:44 pm

Now that the lights turn on automatically when the RPI starts, how can I turn them off when the RPI shutdown?

I tried in rc6.d without success. Another place to insert the script?

Thank you

CharlyDelta
Posts: 97
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: .sh at startup (partially closed)

Sun May 27, 2018 1:14 pm

The more I search, the more complicated it seems.

It is only a question of executing a script somewhere in the process of closing the RPI in order to interrupt the current in a pine of the GPIO because the leds remain lit after the closing of the RPI

Any leads?

User avatar
thagrol
Posts: 858
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: .sh at startup (partially closed)

Tue May 29, 2018 6:19 pm

CharlyDelta wrote:
Sun May 27, 2018 1:14 pm
Th more I search, the more complicated it seems.

It is only a question of executing a script somewhere in the process of closing the RPI in order to interrupt the current in a pine of the GPIO because the leds remain lit after the closing of the RPI

Any leads?
If all you need to do is switch a pin to low on shutdwon, the gpio-poweroff device try overlay might be enough. From https://github.com/raspberrypi/firmware ... ays/README

Code: Select all

Name:   gpio-poweroff
Info:   Drives a GPIO high or low on poweroff (including halt). Enabling this
        overlay will prevent the ability to boot by driving GPIO3 low.
Load:   dtoverlay=gpio-poweroff,<param>=<val>
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.
        input                   Set if the gpio pin should be configured as
                                an input.
        export                  Set to export the configured pin to sysfs
Give that you're not controlling the pi's power you can probably ignore note about active low

Whether this can be used will depend on your LED circuit and driving software.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

CharlyDelta
Posts: 97
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: .sh at startup (partially closed)

Wed May 30, 2018 10:26 am

G0od idea ! Thank you !

Return to “General programming discussion”

Who is online

Users browsing this forum: No registered users and 3 guests