please choosego to mobile | Continue to access the PC version
123
Return to list Post new posts
Author: Boten

GPIO ADDON & OPENELEC

[Copy link]

4

threads

1118

posts

9144

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9144
Published in 2016-12-12 00:40:32 | Show all floors
campioncino replied at 2016-12-11 12:09
I have some problem when i try to switch off the fan controlled by a pin.

I don't know why it remai ...

Thanks for reminding me to remove gpio_sunxi module. It is not better than standard sysfs gpio interface and Allwinner already stopped using it.

About your problem: oppai is right, shutdown in GUI actually does suspend. It was discussed before and I won't change it to shutdown. Your problem can be easily solved by using systemd service file. For example, LED systemd service file solves almost same problem, so you can reuse it:
https://github.com/jernejsk/Open ... nxi-suspend.service

ExecStart is executed when system goes to suspend and ExecStop is executed when system is resumed.

According to this page:
http://wiki.openelec.tv/index.php/Mounting_network_shares

you should place service file in /storage/.config/system.d/ and then execute command "systemctl enable <yourservice>.service"

Be aware that I didn't try this, so there might be some additional steps.

10

threads

55

posts

345

credits

Intermediate member

Rank: 3Rank: 3

credits
345
Published in 2016-12-12 02:27:58 | Show all floors
Thanks a lot jernej.
I'll try.

10

threads

55

posts

345

credits

Intermediate member

Rank: 3Rank: 3

credits
345
Published in 2016-12-17 19:47:21 | Show all floors
Edited by campioncino at 2016-12-17 20:16

According with the LED example I create my own service
  1. [Unit]
  2. Description=fan suspend service
  3. Before=sleep.target
  4. StopWhenUnneeded=yes

  5. [Service]
  6. Type=oneshot
  7. RemainAfterExit=yes
  8. ExecStart=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo "out" > /sys/class/gpio/gpio110/direction; echo 1 > /sys/class/gpio/gpio110/value"
  9. ExecStop=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"

  10. [Install]
  11. WantedBy=sleep.target
Copy code


Placed the service file in /storage/.config/system.d/ and then execute command "systemctl enable fan-suspend.service" And get :
Created symlink from /storage/.config/system.d/sleep.target.wants/fan-suspend.service to /storage/.config/system.d/fan-suspend.service.

But nothing happend, the fan still remain active.


I add also a fan-start service
  1. [Unit]
  2. Description=fan loader
  3. After=network.target

  4. [Service]
  5. Type=simple
  6. RemainAfterExit=no
  7. ExecStart=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo "out" > /sys/class/gpio/gpio110/direction; echo 1 > /sys/class/gpio/gpio110/value"
  8. ExecStop=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"
  9. [Install]
  10. WantedBy=network.target
Copy code
In this way I can start the fan...but I cannot switch off.

4

threads

1118

posts

9144

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9144
Published in 2016-12-18 00:17:10 | Show all floors
Try invert ExecStart and ExecStop. IIRC, start means action at suspend and stop means action at resume. AFAIK, export and direction settings need to be done only once, at first use.

10

threads

55

posts

345

credits

Intermediate member

Rank: 3Rank: 3

credits
345
Published in 2016-12-21 02:44:44 | Show all floors
Edited by campioncino at 2017-6-11 18:35

I feel stupid.


It's correct, now it works.That's the complete working solution
Fan-start.service
  1. #bin/sh
  2. [Unit]
  3. Description=fan loader
  4. After=network.target

  5. [Service]
  6. Type=simple
  7. RemainAfterExit=no
  8. ExecStop=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo out > /sys/class/gpio/gpio110/direction; echo 1 > /sys/cla$
  9. ExecStart=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"

  10. [Install]
  11. WantedBy=network.target
Copy code


Fan-suspend.service
  1. #bin/sh
  2. [Unit]
  3. Description=fan suspend service
  4. Before=sleep.target
  5. StopWhenUnneeded=yes

  6. [Service]
  7. Type=oneshot
  8. RemainAfterExit=yes
  9. ExecStop=-/bin/sh -c "echo 110 > /sys/class/gpio/export; echo "out" > /sys/class/gpio/gpio110/direction; echo 1 > /sys/c$
  10. ExecStart=-/bin/sh -c "echo 0 > /sys/class/gpio/gpio110/value"

  11. [Install]
  12. WantedBy=sleep.target
Copy code

So, I ask another "stupid" question. There is a way to wake it up after suspend? Using remote controller o CEC or ...

4

threads

1118

posts

9144

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
9144
Published in 2016-12-21 05:32:50 | Show all floors

There is FAQ for "stupid" questions, even for this. It is under IR remote.

0

threads

1

posts

14

credits

Novice

Rank: 1

credits
14
Published in 2017-7-31 14:40:54 | Show all floors
jernej replied at 2016-12-21 05:32
There is FAQ for "stupid" questions, even for this. It is under IR remote.

Good afternoon. How to program the automatic switching on or off the fan on the GPIO PIN when reaching a certain temperature to cool the Orange PI?
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list