Rock64 Webserver / NAS project
#8
I also written some scripts for the GPIO pins first off all I wrote a script to initialize all the pins that I have connected

Code:
#!/bin/sh
#RED - RGB-strip
echo 79 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio79/direction
#BIG - Case Button
echo 80 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio80/direction
#POWER - Case Led
echo 81 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio81/direction
#FAN - Case fan
echo 82 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio82/direction
#RPM_FAN - Case fan
echo 83 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio83/direction
#GREEN - RGB-strip
echo 84 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio84/direction
#SMALL - Case Button
echo 85 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio85/direction
#BLUE - RGB-strip
echo 86 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio86/direction
#HDD - Case Button
echo 87 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio87/direction


To test all these pins I also wrote a script
Code:
#!/bin/bash
#MikeD
#Test all pins in use
LOOPS=5
ON_TIME=.5
OFF_TIME=.25
echo " "
echo " _________________________ "
echo "|                         |"
echo "|  Test script  voor I/O  |"
echo "|  ***** BY MIKE D. ****  |"
echo "|-------------------------|"
echo "|      ~~ INPUTS ~~       |"
echo "| BIG =" `cat /sys/class/gpio/gpio80/value` "                |"
echo "| SMALL =" `cat /sys/class/gpio/gpio85/value` "              |"
echo "| RPM_FAN =" `cat /sys/class/gpio/gpio83/value` "            |"
echo "| PRESS BIG button        |"
while [ `cat /sys/class/gpio/gpio80/value` -gt 0 ]; do
sleep .1
done
echo "| BIG == OK !             |"
echo "| PRESS SMALL button      |"
while [ `cat /sys/class/gpio/gpio85/value` -gt 0 ]; do
sleep .1
done
echo "| SMALL == OK !           |"
echo "| Rotate case fan         |"
while [ `cat /sys/class/gpio/gpio83/value` -gt 0 ]; do
sleep .1
done
echo "| RPM_FAN == OK           |"
echo "|-------------------------|"
echo "|   ~~ ALL INPUTS OK ~~   |"
echo "|-------------------------|"
echo "|     ~~ OUTPUTS ~~       |"
echo "| RED - RGB-strip         |"
read -p "| Press enter to toggle   |"
LOOP=0
while [ $LOOP -lt $LOOPS ]; do
echo 1 > /sys/class/gpio/gpio79/value
sleep $ON_TIME
echo 0 > /sys/class/gpio/gpio79/value
sleep $OFF_TIME
LOOP=$(($LOOP+1))
done
echo "| GREEN - RGB-strip       |"
read -p "| Press enter to toggle   |"
LOOP=0
while [ $LOOP -lt $LOOPS ]; do
echo 1 > /sys/class/gpio/gpio84/value
sleep $ON_TIME
echo 0 > /sys/class/gpio/gpio84/value
sleep $OFF_TIME
LOOP=$(($LOOP+1))
done
echo "| BLUE - RGB-strip        |"
read -p "| Press enter to toggle   |"
LOOP=0
while [ $LOOP -lt $LOOPS ]; do
echo 1 > /sys/class/gpio/gpio86/value
sleep $ON_TIME
echo 0 > /sys/class/gpio/gpio86/value
sleep $OFF_TIME
LOOP=$(($LOOP+1))
done
echo "| FAN - Case-fan          |"
read -p "| Press enter to toggle   |"
LOOP=0
while [ $LOOP -lt $LOOPS ]; do
echo 1 > /sys/class/gpio/gpio82/value
sleep $ON_TIME
echo 0 > /sys/class/gpio/gpio82/value
sleep $OFF_TIME
LOOP=$(($LOOP+1))
done
echo "| POWER - Case-led        |"
read -p "| Press enter to toggle   |"
LOOP=0
while [ $LOOP -lt $LOOPS ]; do
echo 1 > /sys/class/gpio/gpio81/value
sleep $ON_TIME
echo 0 > /sys/class/gpio/gpio81/value
sleep $OFF_TIME
LOOP=$(($LOOP+1))
done
echo "| HDD - Case-led          |"
read -p "| Press enter to toggle   |"
LOOP=0
while [ $LOOP -lt $LOOPS ]; do
echo 1 > /sys/class/gpio/gpio87/value
sleep $ON_TIME
echo 0 > /sys/class/gpio/gpio87/value
sleep $OFF_TIME
LOOP=$(($LOOP+1))
done
echo "|-------------------------|"
echo "|  ~~ ALL OUTPUTS OK ~~   |"
echo "|-------------------------|"
echo "|  ***** BY MIKE D. ****  |"
echo "|_________________________|"
echo " "


At last I wrote a script to power my fan in function of the temperature
Code:
#!/bin/bash
#MikeD Automatic fan on cpu temp
 
CHECK_TIME=10 #IN SEC
 
function pwm(){
LOOP=0
while [ $LOOP -lt $(($CHECK_TIME*75)) ]; do
        echo 1 > /sys/class/gpio/gpio82/value
        sleep $1
        echo 0 > /sys/class/gpio/gpio82/value
        sleep $2
        LOOP=$(($LOOP+1))
done
}
 
function fanOff() {
                echo 0 > /sys/class/gpio/gpio82/value
                sleep $CHECK_TIME
}
 
function fanTweFiv() {
                pwm .025 .075
}
 
function fanFifty() {
                pwm .050 .050
}
 
function fanSevFiv() {
                pwm .075 .025
}
 
function fanFull() {
                echo 1 > /sys/class/gpio/gpio82/value
                sleep $CHECK_TIME
}
 
while [ 1 ]; do
        TEMP=$(cat /sys/class/thermal/thermal_zone0/temp)
 
if [ $TEMP -le 20000 ]
then
                fanOff
fi
 
if [ $TEMP -gt 20000 -a $TEMP -le 25000 ]
then
                fanTweFiv
fi
 
if [ $TEMP -gt 25000 -a $TEMP -le 35000 ]
then
                fanFifty
fi
 
if [ $TEMP -gt 35000 -a $TEMP -le 45000 ]
then
                fanSevFiv
fi
 
if [ $TEMP -gt 45000 ]
then
                fanFull
fi
 
done
  Reply


Messages In This Thread
Rock64 Webserver / NAS project - by mikedhoore - 03-21-2018, 09:59 AM
RE: Rock64 Webserver / NAS project - by tllim - 04-02-2018, 09:44 PM
RE: Rock64 Webserver / NAS project - by mikedhoore - 04-21-2018, 12:35 PM
RE: Rock64 Webserver / NAS project - by tazthecat - 07-19-2018, 05:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Are HW design files available for ROCK64? irenek 3 6,232 12-11-2023, 09:31 PM
Last Post: tllim
  Rock64 is unreliable after 3 years of service - power problem? ReleaseTheGeese 0 612 11-23-2023, 05:05 AM
Last Post: ReleaseTheGeese
  Rock64 PoE compatbility with Pi4 Hatt recent Single Board Computer offering from PINE kharak 1 1,510 04-26-2023, 11:38 PM
Last Post: tllim
  Case for the rock64 that supports the POE hat. o1CRiMSON1o 0 866 03-21-2023, 03:48 PM
Last Post: o1CRiMSON1o
Brick Rock64 usb2.0 Power Control Floating GPIO Tutorial Files & Notes MarkHaysHarris777 6 14,567 01-15-2023, 10:36 AM
Last Post: ds00
  rock64 totally brick dakobg 2 2,327 11-07-2022, 05:45 PM
Last Post: olivercfc
  3D-Printable Button Pegs for the ROCK64 Aluminium Case CounterPillow 2 4,084 08-04-2022, 01:31 AM
Last Post: Vicky Weimann PhD
  Where can I find the ROCK64 POE HAT Zoz 2 3,346 06-08-2022, 12:44 AM
Last Post: Zoz
Smile wooden case for ROCK64 killor 13 18,501 03-04-2022, 06:56 AM
Last Post: killor
  1wire DS18b20 on Rock64? mypineme 6 8,248 09-28-2021, 03:07 PM
Last Post: TRS-80

Forum Jump:


Users browsing this thread: 2 Guest(s)