Homepage Wiki Forum Buy
embedded Linux Gnublin

Command line / scripts

Easy scripts for beginners

consoleThe easiest way to start into the world of automation is to build small shell scripts. You can build small loops, where you can for example the temperature for an limit. It the limit is reached you can start an motor or an fan.

It must not be always a huge software. Oft simple solution are a smart and quick way for solving a problem.

Example temperature sensor:

You can start reading out the temperature with the following command:


You get the actual temperature in ° Celsius as output:

21 °C

You can also get JSON compatible output:

gnublin-lm75 -j

Then the output looks like this




An easy blinking LED you can create with this script:

# Blink the onboard LED


cleanup() { # Release the GPIO port
  echo $GPIO > /sys/class/gpio/unexport

# Open the GPIO port
echo $GPIO > /sys/class/gpio/export
echo "high" > /sys/class/gpio/gpio$GPIO/direction

trap cleanup 2 # call cleanup on Ctrl-C

# Blink forever
while [ "1" = "1" ]; do
  echo 1 > /sys/class/gpio/gpio$GPIO/value
  sleep 1
  echo 0 > /sys/class/gpio/gpio$GPIO/value
  sleep 1

cleanup # call the cleanup routine



On this way you can build easy programs, like to measure temperature and if a value is reached to move an motor, send a mail or start the webcam and so on.