Blinking a LED With Onion Omega

Yesterday, I received the Onion Omega, which I backed on Kickstarter a couple of months ago. Onion Omega is a single board Linux computer, running Open WRT and can be easily connected to the internet (it actually has two WiFi antennas). I believe I paid something around 25$, which I consider a fair price, especially after they have deployed their web interface, called Onion Console. This, will enable the Omega to interact easily via the cloud, making it a IoT development platform, full of potential.

Unfortunately, the guys over at Onion, are currently busy with trying to set up the web Console, so not many tutorials can be found, apart of their FAQ page.

Luckily, they have provided us with an easy interface to control the Omega's GPIO pins, so using a very simple bash script, I was able to create beginner friendly "Hello World" example, by blinking a LED lamp.

The materials you will need are:

  • Onion Omega
  • Onion Omega's Dock
  • LED lamp
  • Small resistance for the LED
  • Jumper cables
  • Breadboard

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Prepare the Circuit

Connect one of Onion Omega's IO pins to a small resistance (~300Ω) and that to a LED lamp's anode (the "long" leg). Connect the LED's cathode ("short" leg) to the Onion Omega's Ground.

Use the pictures above for reference. Note that the first sketch is not pin-accurate, but merely for illustration purposes.

Step 2: Setup the Environment

  1. Follow the official Get Started guide to connect the Onion Omega to your local WiFi and the internet. Linux users should not need to download any drivers.
  2. Connect to the Omega via shell (instructions on how to do that are included in the Get Started link above).
  3. Make sure you are running the latest firmware by running in the shell the following command: oupgrade -force
  4. (Optional) Update the package manager opkg, by typing: opkg update
  5. (Optional) Install a text editor of your choice, I used nano: opkg install nano

Then you are good to go!

Step 3: Blink the LED

Unfortunately, at the moment the Onion Console is not up and running yet, nor it is clear how to program the GPIOs with a common programming language, such as C or Python, even though, it is promised that this will be possible in the future.

Instead, we will use a common bash script and the fast-gpio interface, that enables the users to easily read and write to the IO pins (read more about it here). Our script shall do the following simple tasks, indefinitely, until we stop its execution:

  1. Declare a pin as an output.
  2. Set that specific pin to HIGH
  3. Wait for one second
  4. Set the pin to LOW
  5. Wait for one second
  6. Go to step 2

First, we need to create a file and start writing into it. We will name it:

If you downloaded nano previously, you can achieve this by typing: nano

Paste the following code into it:

## Simple script to blink a LED on the Onion Omega using fast-gpio

## the variable that will hold the pin number, where the LED lamp is connected

## declare the LED_PIN as output
fast-gpio set-output $LED_PIN

while true
## set LED_PIN to HIGH (turn LED on)
fast-gpio set $LED_PIN 1

## sleep for 1 second (equivalent to Arduino's delay(1000)
sleep 1

## set LED_PIN to LOW (turn LED off)
fast-gpio set $LED_PIN 0

## sleep for 1 second (equivalent to Arduino's delay(1000)
sleep 1

The code should be self explanatory, but let me know if you have questions. It will blink a LED connected to pin number 6.

After you have written the code, press control+o to save the file and control+x to exit nano.

Make the script executable by running the command: chmod +x

Finally, execute the script by typing: ./

If everything went as it should, you should see your LED blinking, every one second! You can stop the script by pressing control+c. That's all! :)

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    17 Discussions


    Reply 2 years ago

    The new version of the firmware nuked fast-gpio, there are a bunch of messages about it on the community hub.


    2 years ago

    When I try the code...

    Segmentation fault

    Segmentation fault

    Segmentation fault

    Segmentation fault

    3 replies

    Reply 2 years ago

    The newest firmware nuked fast-gpio, it segfaults constantly.


    Reply 2 years ago

    I'm using omega2+, and following is working for me,


    gpioctl dirout-low $LED_PIN

    while true


    gpioctl dirout-high $LED_PIN

    sleep 1

    gpioctl dirout-low $LED_PIN

    sleep 1


    Dimitris Platismasteruan

    Reply 2 years ago

    Maybe something has changed in the API for the GPIOs since then. Try just turning the light on however they do this nowadays and then it will be a piece of cake modifying the script. :)


    2 years ago

    Finally got all the equipment for this and was able to blink the LED :D

    Thanks so much for the tutorial!


    Reply 3 years ago

    You better hurry >


    3 years ago

    A nice tutorial thanks. Now that the console is up and running one can make the file at the prompt with something like:

    chmod a+rwx

    Then from the console, go to editor, and look in "root" to find the file where you can edit it from an easier GUI environment, or indeed even just paste in your code. The permissions could be tightened up later if desired.


    3 years ago

    Great simple tutorial, thank you!

    How would you make the omega run the sketch as soon as it is powered on, and without having to plug it to the computer?


    1 reply
    Dimitris Platisnlapo058

    Reply 3 years ago

    After you have successfully completed the above tutorial, edit the file: /etc/rc.local (for example if you have installed nano you can type nano /etc/rc.local)

    And add the full path to your script (mine is /usr/ BEFORE the "exit 0" which should be the last line in that file. For example my /etc/rc.local file looks like this now:

    # Put your custom commands here that should be executed once

    # the system init finished. By default this file does nothing.

    /usr/ || exit 1 #blinking script

    exit 0


    4 years ago

    Thanks! Just got my Omega and was trying to figure out how to use it to blink the eyes on a giant spider I'm building for Halloween.