book collections email follower instructable user
Picture of 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

Step 1: Prepare the circuit

Picture of Prepare the circuit
IMG_20151002_221753.jpg

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.

GabrielC552 years ago

I'm getting the segmentation fault error. how can i fix this?

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

https://community.onion.io/search/fast-gpio%20segmentation%20fault?in=titlesposts

Dimitris Platis (author)  GabrielC552 years ago

Are you trying to run exactly the same code?

masteruan2 years ago

When I try the code...

Segmentation fault

Segmentation fault

Segmentation fault

Segmentation fault

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

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

LED_PIN=1

gpioctl dirout-low $LED_PIN

while true

do

gpioctl dirout-high $LED_PIN

sleep 1

gpioctl dirout-low $LED_PIN

sleep 1

etc..

Dimitris Platis (author)  masteruan2 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. :)
sanushinp2 years ago

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

Thanks so much for the tutorial!

nunibyes3 years ago

where can i buy the onion omega 2?

Dimitris Platis (author)  nunibyes3 years ago
You can pledge for it on Kickstarter!
so its not avalible yet?

RooX1 nunibyes3 years ago

You better hurry > https://www.kickstarter.com/projects/onion/omega2-5-iot-computer-with-wi-fi-powered-by-linux

ProfCTurner3 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:

touch blink.sh
chmod a+rwx blink.sh

Then from the console, go to editor, and look in "root" to find the file blink.sh 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.

tim_smith843 years ago

Awesome! Thanks

nlapo0583 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?

Thanks!

Dimitris Platis (author)  nlapo0583 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/blink.sh) 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/blink.sh || exit 1 #blinking script

exit 0

chrispix3 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.