Help getting started with programming on the Onion
-
I am a total newbie at the Onion AND at Linux. Are there any tutorials and/or videos available to show how to write, store, and run a program on this nifty device? I'm initially interested in reading from and/or writing to the GPIO pins. I have some familiarity with Python, but would also like to know how to program the Onion in Ruby. Thanks for ANY help y'all can provide.
-
@Jeff-Verive , not much, but I've been writing down a cheat-sheet of my own exploration:
-
Connect at 115200 bps with TeraTerm
-
To setup wifi,
run wifisetup command
wifisetup -checkconnection
run ifconfig to verify -
Web interface
root/onioneer -
Upgrade F/W
run oupgrade -check
See https://onion.freshdesk.com/support/solutions/articles/6000069919-how-do-i-update-the-firmware-
Upgrading the firmware will delete/overwrite all of the files that are not in /etc or /usr -
Most built-in linux commands redirect to /bin/busybox (multi-call binary)
-
Update packages list
opkg update
opkg list -
Change Dock RGB LED
expled FF0000 -> red
expled 00FF00 -> green
expled 0000FF -> blue
expled 00FFFF -> cyan
expled FFFF00 -> yellow
expled FF00FF -> purpleThis actually drives pwm GPIO on I/O pins 15,16,17:
fast-gpio pwm 17 200 0
fast-gpio pwm 16 200 100
fast-gpio pwm 15 200 0To flash slowly:
fast-gpio pwm 15 2 80 -> blue
fast-gpio pwm 16 2 80 -> green
fast-gpio pwm 17 2 80 -> red -
OLED expansion
Use oled-exp command
oled-exp -i power on
oled-exp write Hello
oled-exp -c power on cursor 3,6 write "zoulou was here"
oled-exp scroll diagonal-right -
Run in background
To send to background, use Ctrl-z
bg command to resume
jobs command to list
fg %job_id to bring back to front
Or append & at the end of command to put in background directly -
Mosquitto setup
opkg install mosquitto
opkg install mosquitto-client
[opkg install libmosquitto] -> done by install mosquitto-clientsubscribe in background:
mosquitto_sub -v -t /test/#&
publish message:
mosquitto_pub -m 'Hello' -t /test/pub -
Node.js setup
nodejs - 0.1-1 - Event-driven I/O server-side JavaScript environment based on V8
reports v0.10.5 (history says it is 2013-04-26), see https://nodejs.org/en/download/releases//usr/bin/node (or just node, since /usr/bin is in the path)
Test Node, copy this to hello.js
var http = require("http");
http.createServer(function (req, res) {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end("Hello World\n");
}).listen(8000);
Run as node hello.js&npm is supposed to be standard with node.js since 0.6.3, should have npm 1.2.18, not sure how to get it...
-
-
Hi @Jeff-Verive, you can install ruby with these simply commands:
opkg update opkg install ruby
However, we are still working on wrappers for the scripting languages. Currently we have finished the majority of the expansion drivers for python, and are working on wrappers for javascript and PHP.
Since you are already familiar with python, you can start writing program with the Omega by taking a look at these tutorials on our libraries: https://wiki.onion.io/pages/Tutorials/Libraries/. There is a section on how to use our Python library in each article.
Please let me know if it helps.
-
I put that in better form on my blog here: link text
-
Hi @Greg-Ware, we are still working on the
npm
because with many modules it requires the compilation of C/C++ code into binary. The Omega doesn't have enough computational resource to complete the compile itself, so we are working on a way to pre-compile some of the commonly usednpm
packages so that we can simply fetch it from a server duringnpm install
.Also your cheatsheet is super useful! Do you mind if we post it on the Wiki?
Thanks!
-
Hey thanks for tips
[post edited]
to install node.js- opkg update
- opkg install nodejs
Next step a piratebox ^^
Seeya
-
Hi @Vincent-Bonnefille, yeah, you can install
node
withoutnpm
. You simply need to run the following commands:opkg update opkg install node