Recent Updates RSS Hide threads | Keyboard Shortcuts

  • Configure Yun and install Node

    Ellen 17:21 on November 4, 2014 | 0 Permalink | Reply
    Tags: , , , yun

    Turn your Arduino on by connecting the micro-usb cable. It will get it’s own access point that you connect to. When connected type in http://arduino.local into your browser and you will get into the page of the Arduino Yun. Password comes preconfiguired as “arduino”.

    If http://arduino.local doesn’t work. Check the IP adress of your network ie and type it in but replace the last digit with 1 so it becomes

    Type in the details of your wifi network so that the Arduino can connect to internet. Configure and restart. No connect to your wifi network that has internet connection.

    Now open the Terminal and type:

    ssh root@arduino.local

    You will be required to type in the password you set earlier.

    Upgrade OpenWrt
    Download the upgrade for OpenWrt to the SD card via the Terminal.

    cd /mnt/sda1/

    Install unzip and unzip the package

    opkg update
    opkg install unzip

    Install upgrade

    run-sysupgrade /mnt/sda1/openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin

    The output will look like this:

    run-sysupgrade /mnt/sda1/openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin
    Sending TERM to remaining processes … uhttpd dbus-daemon dnsmasq avahi-daemon thd ntpd uSDaemon sleep syslogd klogd hotplug2 procd ubusd netifd
    Sending KILL to remaining processes …
    Switching to ramdisk…
    Performing system upgrade…
    Unlocking firmware …
    Writing from  to firmware …
    Upgrade completed
    Rebooting system…

    When the process is done you see “Rebooting system…”.

    The Arduino Yun has now gone back to its original settnings. Connect to it with its access point and hook it up to your wifi again. Make it a habit to change name and password for future security.

    Format SD card
    To format the SD card and assign more disk space to OpenWrt follow these steps. All is copied from

    Upload YunDiskSpaceExpander sketch to your Arduino Yun via USB (not over wifi). Make sure that your Arduino Yun is connected to the wifi for this procedure though.

    If you experienced problems uploading the sketch make sure that the Arduino Yun is listed as a known host on your computer with

    Click on the Serial Monitor-button to get started. Write yes to proceed. Make sure that you have “Newline” selected.

    When bridge started write yes to proceed:

    Proceed to partitioning micro SD card and write yes. Then enter the number of MB for data partition.

    The instructions invites you to press the Yun RST button when it is done. The Yun RST button reboots the Arduino Yun and is placed close to the LEDs.

    When the Arduino Yun restarts you can ssh into it and confirm the partition with:

    df -h / /mnt/sda1

    It should look something like:

    Install node
    To install node on your Arduino Yun, enter:

    opkg update
    opkg install node

    To talk to the Arduino part from OpenWrt install the node package serial-port.

    opkg update
    opkg install node-serialport

    Open the serial port for Node so communication between Arduino and OpenWrt can be done:

    vi /etc/inittab

    Add # in front of the last line to comment it out. In the vi editor press i to insert text.

    #ttyATH0::askfirst:/bin/ash –login

    Press Esc and write “:w!” to save and “:q!” to quit editor.

    Now reboot your Arduino Yun and we will get some code going!

    Example code of calling an Arduino sketch from node:

    var SerialPort = require("serialport").SerialPort
    var serialPort = new SerialPort("/dev/ttyATH0", {
        baudrate: 9600,
        dataBits: 8,
        parity: ‘none’,
        stopBits: 1,
        flowControl: false
    }, false);

    serialPort.on("open", function () {
    var data_with_newline = "mydata/n";
         serialPort.write(data_with_newline, function(err, results) {      
          log("send data");
          if(err != undefined) {            
            log(‘err ‘ + err);      

        serialPort.on(‘data’, function(data) {
            log(‘data received: ‘ + data);

      serialPort.on(‘error’, function(err) {
          log(‘error: ‘+err);

    The Arduino sketch receving the data:

    char incomingChar;
    bool incomingCodeReceived = true;

    void setup() {
     while (Serial1.available() > 0 && !incomingCodeReceived) {
       incomingChar =;
       if (incomingChar == \n) {
          incomingCodeReceived = true;
        } else {
        if ((incomingStrLength + 1) < INCOMING_STR_SIZE) {
            incomingStr[incomingStrLength] = incomingChar;
            incomingStrLength += 1;
          } else {
            incomingStrLength = 0;

    void loop() {

    Install forever on Yun

    The Yun doesn’t have enough memory to install this module on its own so the version I use can be downloaded here:

    Make sure your forever module is executable:

    chmod u+x /root/node_modules/forever/bin/forever

    Try it out by typing:


    Crontab on the Yun
    You might want to run a Cron job on your Yun. This can be done by typing:

    /etc/init.d/cron start
    /etc/init.d/cron enable

    Edit your Crontab as you normally do with:

    crontab -e

    Setting static IP of an Arduino Yun
    Soon to be published

  • Servo festival with node.js on Raspberry Pi

    Ellen 17:51 on October 25, 2014 | 0 Permalink | Reply
    Tags: , , servo

    pi-blaster.js was used in the ballon project with 2 servos controlling the flow of helium and cutting the cord to the ballon.

    Running several servo motors on Raspberry Pi with pi-blaster.js works like a charm. Install node.js on your Raspberry to run the pi-blaster.js package.

    Install pi-blaster

    git clone
    cd pi-blaster
    make pi-blaster

    Start pi-blaster deamon

    sudo ./pi-blaster

    Defines outputs to use. In this case I use 2 but you can use up to 8 pins.

    sudo ./pi-blaster 22 24

    Try it out from the command line setting channel 0(GPIO 22) to 0.2.

    echo "0=0.2" > /dev/pi-blaster

    Install pi-plaster.js

    npm install pi-blaster.js

    In your node.js script you can now control your servos like this:

    var piblaster = require(‘pi-blaster.js’); // Import package

    piblaster.setPwm(0, 0.2); // Sets servo on pin 22 to 20 %
    piblaster.setPwm(1, 0.4); // Sets servo on pin 24 to 40%

    To set the pi-blaster setting on reboot, create this shell script and call on reboot crontab:

    sudo /path_to/pi-blaster/pi-blaster 22 24

    To connect a servo motor to Raspberry Pi:

  • Raspberry Pi with Node.js and Alamode

    Ellen 15:52 on July 1, 2014 | 0 Permalink | Reply
    Tags: alamode, , , , serial port


    For this tutorial I use the latest Raspbian version from

    Setup Alamode
    Install the arduino IDE on the Raspberry

    sudo apt-get update
    sudo apt-get install arduino

    Get the Alamode setup files and install them by following these steps:

    git clone git://
    cd /alamode/alamode-setup
    sudo ./setup

    In order for these setting to take effect, please reboot your Raspberry PI:

    sudo reboot

    Load an Alamode sketch
    If you don’t have your Raspberry Pi connected to screen, keyboard and mouse you can access the GUI from your computer. I have a Mac and use XQuartz.

    As you start XQuartx open the Terminal in this application with Command + N and log into your Raspberry Pi like this:

    ssh -X user@ipaddress

    When you are logged in, just type:


    and the Arduino IDE will start up on your computer.

    The Alamode setup added the Alamode board to your Arduino IDE. Select it by
    Tools > Board > Alamode
    Tools > Serial Port > /dev/ttyAMA0

    Copy the following code and paste it (Ctrl+V) into a new sketch. Put an LED into ground and pin 13 on your Alamode.

    void setup()
      pinMode(13, OUTPUT);

    void loop()
      char inSerial[5];  
      int i=0;
      if (Serial.available() > 0)
           while (Serial.available() > 0) {
             inSerial[i]; //read data  
           if(!strcmp(inSerial,"high")) {
            digitalWrite(13, HIGH);
          if(!strcmp(inSerial,"low")) {
            digitalWrite(13, LOW);

    To send data from Alamode to Arduino, just write to the serial port with:


    Install node.js

    tar xvfz node-v0.10.12-linux-arm-pi.tar.gz
    sudo mv node-v0.10.12-linux-arm-pi /opt/node/

    Set the path to node.js:

    echo‘export PATH="$PATH:/opt/node/bin"’ >> ~/.bashrc
    source ~/.bashrc

    Install serialport
    To communicate between the Alamode and node.js we need the serialport package for node.js:

    npm install serialport

    More information on:
    Node.js coding

    var SerialPort = require("serialport").SerialPort
    var serialPort = new SerialPort("/dev/ttyAMA0", {
    baudrate: 9600
    }, false); // this is the openImmediately flag [default is true] () {

    Trigger this command and “high” will be sent to the Alamode

    // Sends "high" to the Alamode
    serialPort.write("high", function(err, results) {
          if(err != undefined) {
                console.log(‘err ‘ + err);

    To receive serial data from the Alamode, listen for data with this code: () {
          serialPort.on(‘data’, function(data) {
                console.log(‘data received: ‘ + data);
                if(data == "alamode_data") {
                     // Do something

    External power
    If you are dealing with many power consuming sensors on your Alamode, it’s a good idea to power your Alamode externally with its own 5V power adapter.

  • Control stepper motors with Raspberry Pi and node.js

    Ellen 11:55 on February 25, 2014 | 11 Permalink | Reply
    Tags: , , , , steppers

    Continuing the journey on how to control things with node.js on the Raspberry Pi I set up 2 stepper motors and controlled them in real time with Hydna. You can can read futher on how to install Hydna on Raspberry Pi here.


    Wire up your motors with a stepper motor driver shield. I used Easy Driver and connected it with Pololu stepper motors:
    The to pins that controls the motors in this diagram are pin number 16(GPIO 23) and pin number 18(GPIO 24). Pin number 18 controls the direction of the motor and pin number 16 the speed. With 1K ohm resistors connected to the ground for each of these pins we connect them to the Easy driver.

    Depending on the stepper motor you have, you will need to check the bipolar stepper motor wiring diagram for your motor. The motors I used had the following diagram where A(black) and C(green) connects to the A pins and B(red) and D(blue) connects to B pins.


    Install pi-gpio and go ahead with this script to control the stepper motors:

    var gpio=require("pi-gpio");

    stopMotors = false;

    function sleep(milliseconds) {
      var start = new Date().getTime();
      for (var i = 0; i < 1e7; i++) {
        if ((new Date().getTime() - start) > milliseconds){
      console.log("Pin 16 open"); // Opens pin 16 as output  
      console.log("Pin 18 open"); // Opens pin 18 as output  

    // Runs motor in the set direction
    function move() {
       gpio.write(16, 1, function() {
             gpio.write(16, 0, function() {

    function stopMotor() {
      stopMotors = true;

    // Changing direction of motor
    function left() {
      stopMotors = false;
      gpio.write(18, 1, function() {

    // Changing direction of motor
    function right() {
      stopMotors = false;
      gpio.write(18, 0, function() {

    • Rob 06:23 on March 15, 2014 Permalink

      Thanks so much for this post. I was having no end of trouble controlling my stepper motor and couldn’t figure out the proper way to hook up the grounds. Your diagram is crystal and I finally have a working stepper motor.

    • Ellen 01:25 on March 17, 2014 Permalink

      Great! I am glad it helped!

    • Mitko 22:39 on March 30, 2014 Permalink

      Is this async code ?Thanks

    • Mitko 21:22 on March 31, 2014 Permalink

      I dont think so , because of the “sleep()” function – it is not asynchronous

    • Ellen 21:51 on April 1, 2014 Permalink

      @Mitko The code is not async. :-)

    • Paolo 12:32 on November 2, 2014 Permalink

      Hi! Thanks for your tutorial!

      I managed to make it display the pins are open.

      Now how do I make the stepper move? :P
      Can I use a python script? If so, how?

    • Paolo 12:33 on November 2, 2014 Permalink

      Hi thanks for your tutorial!

      I managed to get it to display those pins are open. How do i make the stepper move now? Can i use python script?

    • James 21:07 on April 3, 2015 Permalink

      Your set up has one problem. As displayed and written, the Pi will be damaged eventually. The default control signals for the board is 5V (compatible with TTL circuits/Ardruino controllers). The board has to be set to accept the Pi’s lower 3v (3.3v) signal. The solder joint is above the highest ground point in the picture (top left corner of the easydriver board as displayed)- soldering this will let it take a 3v control signal from the Pi safely. Otherwise you would have to add a voltage shifter to protect the Pi.

    • Ellen 22:11 on June 17, 2015 Permalink

      @James Can you please supply a sketch on where to solder? I will update the post!

    • James 15:28 on June 19, 2015 Permalink

      Unfortunately I don’t know how to drop a sketch here (tried to drag and drop) but I am looking at a marked up image of the board while writing this ( On one corner of the board there are 2 solder pads bracketed off and marked 3/5V, these are the logic level signal controls (shorted = 3V, unshorted = 5V). Looks to be that all Version 4’s of the board have these.

  • Realtime control of GPIO:s with Hydna

    Ellen 12:33 on February 13, 2014 | 0 Permalink | Reply
    Tags: , gpio, , , , realtime


    Want to control the pins on you Raspberry Pi in real time? With the scaleable realtime platform from Hydna you can set how many that can access the GPIOs and when. Install the node modules gpio and hydna to controll your GPIO:s over the net.

    Install node.js

    sudo apt-get upgrade;
    sudo apt-get update
    sudo apt-get install nodejs npm node-semver
    npm config set registry

    Open the profile file with:

    sudo nano /etc/profile

    And enter the following:


    NOTE! Log out and then in again in order to make the changes go through.

    To run nodejs with with the command node, link them to with:

    sudo ln -s /usr/bin/nodejs /usr/bin/node

    Make sure to check where your node was installed and add it to NODE_JS_HOME

    Install GPIO

    npm install pi-gpio

    Install GPIO-ADMIN

    cd /home/pi
    sudo git clone git://
    cd quick2wire-gpio-admin
    sudo make
    sudo make install
    sudo adduser pi gpio

    Try out gpio-admin with the following line:

    gpio-admin export 22

    If you get this error

    Error /bin/sh: 1: gpio-admin: Permission denied

    follow these steps:

    sudo groupadd gpio
    sudo usermod -aG gpio
    sudo chgrp gpio /sys/class/gpio/export
    sudo chgrp gpio /sys/class/gpio/unexport
    sudo chmod 775 /sys/class/gpio/export
    sudo chmod 775 /sys/class/gpio/unexport

    Install Hydna

    npm install hydna

    With Hydna you can send real time messages to your pi and allow a certain number of clients to connect to your Raspberry Pi. With Hydna’s Behaviours you set the behaviours of your different channels.

    The following example code shows how to control your gpios with messages from Hydna:

    var gpio=require("pi-gpio"); // Include the pi-gpio library to control the gpios,"output",function(err){
    console.log("Pin open"); // Opens pin 12 as output
    var hydna = require(‘hydna’);
    // Open channel in "read/write" mode. All data sent to channel will
    // loop back from the remote connection.
    var channel = hydna.createChannel(‘’, ‘readwrite’);
    // Connect handler, is triggered once that the channel is connected
    channel.on(‘connect’, function () {
    this.write(‘Status: ok’);
    // Data handler, is triggered each time DATA is received on the channel
    channel.on(‘data’, function (data) {
    // Log data received on channel.
    if(data == "on") {
    gpio.write(12, 1, function() {
    } else if(data == "off") {
    gpio.write(12, 0, function() {
    } else if(data == "end") {
    gpio.close(12); // Close pin
    this.end(); //Close the channel, which terminates the underlying receive-loop.

  • Looping videos seamlessly OMXPlayer

    Ellen 16:30 on October 15, 2013 | 37 Permalink | Reply
    Tags: omxplayer, python,

    As I looked for different solutions for looping videos on the Raspberry Pi seamlessly I eventually came out with a solution that worked quited good for videos looping with sounds. Looking at the possiblities of using the existing example of hello_video/video.c to loop a video wasn’t an option as sound was not supported and syncing sound was not something I wanted to spend time on.

    Instead I looked to jbaiter’s OMXPlayer library pyomxplayer build in python. It calls the OMXPlayer through the command line and with some testing I could run several instances of OMXPlayer at the same time. This meant that I could start one movie and pause a copy of the same movie in the background. When the first movie came to an end I could start the second movie which was an exact copy of the first one in order to get the seamless loop. No terminal windows showing and no gap between the movies. And so the loop goes on.

    By having 2 different names of the same movie I was in complete control of the omxplayer processes running in the background to play another movie on top of this.

    I start off loading both movies by calling making to OMXPlayer instances in pyomxplayer and pausing the second movie:

    self.loop1= OMXPlayer(‘/home/pi/loop1.mp4′, ‘-o local’, start_playback=True, do_dict=False)
    self.loop2 = OMXPlayer(‘/home/pi/loop2.mp4′, ‘-o local’, start_playback=True,do_dict=False)

    In a loop I check when the first video reaches its end position and pause it just before to start the next movie. Since it already loaded, there is no buffering for it to play. Note that the end position needs to be set a little bit before the video exactly ends in order to not get out of the video screen mode.

    position = self.loop1.position/1000000
    if position > 12.8:

    A few seconds later I kill the process of the first movie to start it and pause it for next time.

    os.system(‘pkill -9 -f "/usr/bin/omxplayer.bin -s /home/pi/loop1.mp4 -o local"’)
    os.system(‘pkill -9 -f "/bin/bash /usr/bin/omxplayer -s /home/pi/loop1.mp4 -o local"’)
    self.loop1= OMXPlayer(‘/home/pi/loop1.mp4′, ‘-o local’, start_playback=True, do_dict=False)

    I added a 2 seconds delay in order for the new movie to have time to show and to allow for some time to kill the process.

    • Phil 07:30 on October 23, 2013 Permalink

      I installed pyomxplayer and found it needed pexpect. After installing both, I am getting an error on the first line. “unexpected keyword argument ‘do_dict’. Any ideas on what else I might be missing? Thanks!

    • Reg 22:42 on November 2, 2013 Permalink

      Interesting, which omxplayer build are you using? pyomxplayer doesn’t appear to work with the latest (9-25-2013) build.

    • Ellen 17:14 on November 12, 2013 Permalink

      @Phil Which Python version are you running? Python versions earlier than 2.5 requires the pty module. I have Python 2.7.3. I have Pexpect version 2.3.

    • Ellen 17:30 on November 12, 2013 Permalink

      @Reg I use the OMXPlayer from

    • KenT 12:21 on November 14, 2013 Permalink

      Not sure if this is the cause but pyomxplayer is out of date in that the format of the output of omxplayer with the -s option has changed. I use modified versions of pyomxplayer in TBOPlayer and Pi Presents.

      Ellen, great that you got this technique working, I tried something similar in Pi Presents some months ago without success, must have another try.

    • emil 21:26 on November 21, 2013 Permalink

      I receive this error message:

      SyntaxError: Non-ASCII character ‘\xe2′ in file ./omxloop2 on line 18, but no encoding declared; see for details

      This is the code:


      import sys
      import subprocess
      import os
      import glob
      path =’/home/pi/test’

      self.loop1= OMXPlayer(”/home/pi/test/01_h264_1024-576_square.mp4″, “-o”, “hdmi”, start_playback=True, do_dict=False)
      self.loop2= OMXPlayer(”/home/pi/test/01_h264_1024-576_square.mp4″, “-o”, “hdmi”, start_playback=True, do_dict=False)

      position = self.loop1.position/1000000
      if position > 4:

      os.system(‘pkill -9 -f “/usr/bin/omxplayer.bin -s /home/pi/test/01_h264_1024-576_square.mp4″ “-o” “hdmi”’)
      os.system(‘pkill -9 -f “/bin/bash /usr/bin/omxplayer -s /home/pi/test/01_h264_1024-576_square.mp4″ “-o” “hdmi”’)

      self.loop1= OMXPlayer(”/home/pi/test/01_h264_1024-576_square.mp4″, “-o”, “hdmi”, start_playback=True, do_dict=False)

    • Ellen 12:08 on November 25, 2013 Permalink

      @emil Please check that you havn’t added any weird symbols at the end of your file. And please set up the code in functions to be triggered when you want them to.

    • Ellen 12:10 on November 25, 2013 Permalink

      @KenT I also used a modifed version of pyomxplayer. I will post the entire project here.

    • Ellen 12:12 on November 25, 2013 Permalink

      @KenT Looking at the code, I used a modified version that you modified! :-)

    • carnivoire 02:11 on November 26, 2013 Permalink

      really nice work, but it only works with small movie files here, it could be caused by a different pyomxplayer version (i used this one: InfernoZeus to work with the latest version of omxplayer from this archive: huceke).

      I got this error when I want to start two 1080p ~ 850 MB files and to pause one of them:

      pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().

      Perhabs you could help me (: ?! Or is it working at your setup with large files?

    • JViyer 21:35 on December 4, 2013 Permalink

      Thanks it is what I was looking for. I dont know python but experienced in C/C++ and was hoping I could use this to get started in python. Is the code snippets you have shown part of some python script you are using to drive the pyomxplayer ? would you be kind enough to share the code ?
      much appreciated,

    • bendr 10:13 on January 22, 2014 Permalink

      Hi Ellen, thank you for your idea and your post it’s exactly what I was looking for. The script ist working except I’m not able to kill one instance of the omxplayer with your command

      pkill -9 -f “/usr/bin/omxplayer.bin -s /home/pi/loop1.mp4 -o local”

      doesn’t do anything for me, if I jsut use

      pkill -9 -f “/usr/bin/omxplayer.bin”

      the second omxplayer also shuts down.
      Perhaps you can help. Thank you!

    • Matt 23:04 on January 22, 2014 Permalink

      Hi, I have never done this type of coding or anything like this before. Can someone please tell me step by step on how to do this. This is very important for me. Thank you to anyone who helps!

    • Ellen 16:48 on January 27, 2014 Permalink

      @bendr Make sure that the path is right in you pkill. Make sure local/hdmi is set them same as well. The last pkill command kills all the processes you run with omxplayer which is not great if you want to kill one after starting another video.

    • Ellen 16:55 on January 27, 2014 Permalink

      @JViyer You can achieve the seamless looping by downloading this version of omxplayer where the -loop command is available: Note that it requires GCC version 4.7.

    • Ellen 17:00 on January 27, 2014 Permalink

      @carnivoire I used 1280p files but with a length of 2 minutes.

    • KenT 09:32 on January 28, 2014 Permalink

      @bender you could use the pexpect kill with SIGINT. this is much better as it kills only one instance and, because it sends SIGINT to omxplayer tidies up omxplayer, omxplayer.bin and the dbus-daemons
      import signal

    • KenT 09:44 on January 28, 2014 Permalink

      Does your timeout happen every time you run the video of just occasionally. If occasionally then you may be hitting the omxlayer unreliavle playing issue #124. If permanent try running omxplayer -s file does the output hang before have a nice day?

    • Santiago 13:51 on March 21, 2014 Permalink

      Hi Ellen, I installed the omxplayer and it worked 100%. But when i rotated the screen in 90º, the video disappeared (but the audio continues running). Do you have any solution to my problem?

    • Ellen 21:53 on April 1, 2014 Permalink

      @KenT Great that you come with improvements to the code!

    • Ellen 21:55 on April 1, 2014 Permalink

      @Santiago I had the same problem and ended up rotating the clip it self in a movie editor to appear in portrait mode. One solution might be to rotate the screen output in the setting of the screen if that is possible.

    • Carolina 09:39 on April 9, 2014 Permalink

      Hi! i need help to do a loop video
      i had many problems with the sound and the quality of the video, actually reading the file is fine, the issue is to have a seamless loop. during loop, there are 2 seconds of delay between the end of the first video and the beginning of the new one.

    • Carolina 09:40 on April 9, 2014 Permalink

      Hi Ellen! i need help to do a loop video
      i had many problems with the sound and the quality of the video, actually reading the file is fine, the issue is to have a seamless loop. during loop, there are 2 seconds of delay between the end of the first video and the beginning of the new one.

    • roberto 17:21 on April 11, 2014 Permalink

      Hi where can I find your complete project??

    • roberto 17:30 on April 11, 2014 Permalink

      Hi where can I find your complete software to test if it works?

    • sergio 11:53 on June 1, 2014 Permalink


      Someone is able to manage a playlist of 1080p formatted videos without gap (black frame between videos)???

      In my case this only works for 720p (even if gpu mem is set to 320MB)

      Thanks for answer

    • Florian 16:38 on July 8, 2014 Permalink

      Hi Ellen,

      I recently find this post,

      But i have some issues : ‘do_dict’ argument unknow,
      Python : 2.7.3
      Pexpect : 2.3
      have you some tips to clean this error ?
      Thanks for answer

    • Draco 00:05 on September 17, 2014 Permalink

      Thanks a lot Ellen for sharing this info. I managed to get it working with some code modification.

    • kamera 01:18 on September 17, 2014 Permalink

      Hello Florian …

      As the same for me :-/

      ( i ‘am totaly noob in python)

    • Tristan 14:24 on October 29, 2014 Permalink

      I’m getting a NameError: name ‘OMXPlayer’ is not defined. Any idea how to fix that? Why isn’t it recognizing omxplayer?

    • Gustavo 20:51 on November 10, 2014 Permalink

      Thanks a lot for your post Ellen!!. Gustavo

    • Bill 12:35 on December 13, 2014 Permalink

      Ellan; is this still active? I am looking at using video as a front end to a voice recognition RPI based project. I tried pygame (no joy) then discovered omxplayer which plays brilliantly, what I now need to do is find a way of linking videos together to give the project a live visual front end, possibly playing different ones based on the voice output.
      Your looping seems to be the way ahead, any examples of embedding this in a python script would be helpful. I am a nube :-)

    • Giacomo 19:56 on February 8, 2015 Permalink

      Trying trying trying but can’t make it working.
      Could you please be so kind to share a working project with me?
      Very sorry I’m not a programmer and Isee my limitations on this field.

    • Giacomo 19:57 on February 8, 2015 Permalink

      Trying trying trying but can’t make it working.
      Could you please be so kind to share a working project with me?
      Very sorry I’m not a programmer and Isee my limitations on this field.
      many thanks

    • Ronei 16:11 on February 9, 2015 Permalink

      First excuse my poor English.
      Loved this solution and is exactly what I ‘m trying to implement , I’m noob in python and I would if someone can help me , someone has a step-by – step of how I implement this solution ? or the complete script?
      I thank you .

    • Rich Shumaker 05:35 on March 2, 2015 Permalink

      I have not tried this yet as I just found it today. I am excited to try it out.
      Since this has been built for a few years I wondered if anyone has used this awesome idea beyond a single loop?
      As an example has anyone built a looper based on key stroke input.
      Also for anyone that has tried to push this method what is the upward maximum of ‘paused’ videos. Can I have 4 or 8 or more or will the GPU CPU grind to a halt. So with the RasPi 2 coming out does that allow for more paused videos based on GPU memory allocation or CPU increased speed and multithreading?
      I guess the question beyond that would be can you pick start and stop points and how fast can they be gotten to. Meaning could you cue and then play with fast key presses.

      Honestly I think this would make the most amazing video looper for an artist to use especially across multiple screens or layered projectors.

      Rich Shumaker

    • sanjay sahay 12:41 on August 30, 2015 Permalink

      Hi Ellen, would you publish the final code or is this the final code ? I am looking for something like this so will be of good help.thanks.

  • Connect Parallax RFID to Raspberry Pi

    Ellen 15:01 on September 18, 2013 | 5 Permalink | Reply
    Tags: , ,


    To connect a Parallax RFID Reader to the Raspberry Pi you can either use the USB version of the Parallax RFID reader or the pin enabled used in this example. With the pin enabled Parallax version the data is sent to the Raspberry pi serial pins with the pins TXD and RXD pins. With the RFID reader with only need to use RXD as we will only receive data from the RFID reader.

    Wiring setup

    The RFID reader operates on 5V but the Raspberry Pi GPIOs operate on 3.3 V which mean that in order to read the serial data we need to convert it from high volt to low volt. There is circuit available from Sparkfun doing just that. It is called Logic Level Converter and will be part of the wiring between the Raspberry Pi and the RFID reader.

    Below is the schematics for the connections you need to make.

    1. Connect your common ground to both ends of the Logic Level Converter and RFID reader. Note that the Parallax RFID reader needs the Enable pin to be connected to ground in order to read RFID tags. When the LED on the RFID reader turns red it means that it is ready to read. (Black)

    2. Connect the high volt  from 5V pin to HV pin. (Red)

    3. Connect the low volt from 3.3 V pin to LV pin. (Orange)

    4. Connect the SOUT pin to  serial input RXI on the Logic Level Converter. (Blue)

    5. Connect the seriel output RXO to the pin RXD on the Raspberry Pi.

    Screen Shot 2013-09-18 at 3.07.29 PM

    Enable serial port

    To make the serial port available for your own use you need to edit the file /etc/inittab.

    sudo nano /etc/inittab

    Comment out the following line in inittab

    T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

    Like this:

    #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

    Install minicom for testing

    To read and test your tags on the Raspberry Pi you need a set of packages:
    A great package to test your serial port is to install minicom:

    sudo apt-get install minicom

    To test your serial port you can use mimicom command like this:

    minicom -b 115200 -o -D /dev/ttyAMA0

    Read RFID tags with Python

    To access the serial port from Python install the pySerial package with command line:

    sudo apt-get install python-serial

    Now you can import the serial library on order to access the serial data sent to the Raspberry Pi from the serial port. Note that you can set the timeout of the RFID reader to make the read timeout after a while. The example code below times out the serial read after half a second. This can be useful to set a longer or shorter timeout depending on if you execute other things in your loop or application.

    import serial
    ser = serial.Serial(‘/dev/ttyAMA0′, 2400, timeout=0.5)
    while True:
        string =  
        if len(string) != 0:
            print string

    Raspberry Pi Lab posted a great Python script on how to check which tag is read in the

    • Dog 03:53 on April 10, 2014 Permalink

      How would someone do this for the USB version.

    • Jason Green 19:29 on January 5, 2015 Permalink

      Seconding Dog’s question. I think you replace the wiring section with – plug an appropriate USB cable between the two boards. From other research it appears the PI will read serial via /dev/ttyAMA0 even if that serial is coming via USB. I hope to get confirmation from someone before I go out and buy the Parallax however.

  • Clone SD card for Raspberry Pi(Mac)

    Ellen 10:46 on September 16, 2013 | 9 Permalink | Reply
    Tags: , sd card

    Backup SD card

    To clone an SD card setup for your Raspberry Pi on a Mac, do the following:

    Input the SD card you want to clone. Open the Terminal window and type:

    diskutil list

    This will list your connected disks. See the name of your SD card, on mine in looks like this:
    diskutil list on Mac

    Make an image of the content with the following command:

    sudo dd if=/dev/disk1 of=~/Desktop/boot.dmg

    This might take a while and when it is finished you will see how many bytes were transferred.

    Edject your SD card and input the SD card you want to clone to.

    Format new SD card

    If the SD card is not formatted you can open the Disk Utility and select the card(not the volumes) . Click on the “Erase”-tab and select the format “MS-DOS(FAT)”. Name your card and click on the button “Erase”. This will only take a few seconds. The SD card is now formatted in FAT32.

    Screen Shot 2013-09-16 at 11.15.05 AM

    If you want to change the format to FAT16 just go to your Terminal window and type:

    sudo newfs_msdos -F 16 /dev/disk1

    Note that the name of the disk can be different. Run “diskutil list” again to find out.

    Clone SD card

    Now the SD card is prepared to get the cloned image. Unmount the volumes on the SD card before you go ahead with cloning. NOTE! That you should unmount and NOT eject.
    Screen Shot 2013-09-16 at 11.44.26 AM

    To transfer the image you just made before you write in the Terminal window:

    sudo dd if=~/Desktop/boot.dmg of=/dev/disk1

    This can take long depending on the class of your SD card.

    During the process you can to checks that the cloning is progressing. Open a new Terminal window and type:

    ps ax | grep dd

    This will list processes on your computer with “dd” as part of it. At the bottom of the list you will find something like this:

    11502 s002  S+     0:00.01 sudo dd if=~/Desktop/boot.dmg of=/dev/disk1 bs=5
    11503 s002  R+     0:58.27 dd if=~/Desktop/boot.dmg of=/dev/disk1 bs=5
    11524 s003  R+     0:00.00 grep dd

    Note the id of the process and type:

    sudo kill -s SIGINFO 11503

    In the other window where you did your clone command, it will now print out how much data that has been transfered to your SD card in the format seen on success in the below example.

    When the process is finished you will see how many bytes were tranfered and compare it with the bytes when you made the backup.

    60392+1 records in
    60392+0 records out
    30920704 bytes transferred in 132.542963 secs (233288 bytes/sec)

    • T 12:42 on October 8, 2013 Permalink

      I think you made a mistake when specifying the backup command (it looks exactly the same as the ‘recover’ command). I guess it should be:

      sudo dd of=~/Desktop/boot.dmg if=/dev/disk1

    • Ellen 17:05 on October 9, 2013 Permalink

      Ohh yes! I fixed that now! Thanks!

    • Mike 12:48 on December 2, 2013 Permalink

      Just to make it clear too. Be sure to unmount your disk in disk utility (not eject)

    • Tom Cox 03:55 on January 7, 2014 Permalink

      You say, “Ohh yes! I fixed that now!” I don’t see that it is fixed.

    • Ellen 15:12 on March 20, 2014 Permalink

      @Mike, I added the NOT eject to the post. Also added commands to follow the process when in doubt of the progress.

    • David 19:56 on March 23, 2014 Permalink

      Excellent guide! Tanks a lot!

    • Ellen 21:56 on April 1, 2014 Permalink

      Cheers @David! I might write a program for this as I had problems using RPi-sd card builder with some SD cards..

    • Hans Baumeister 22:11 on June 28, 2014 Permalink

      I’m just curious: why does an SD-Card need to be formatted if you’re dumping binary data onto it via dd? I.e. if the SD-Card has a Linux system on it (such as for my m0n0wall), do I have to format the destination card appropriately first? This would be impossible on a Mac, as it doesn’t do ext3…

  • Useful Raspberry Pi commands

    Ellen 09:54 on September 12, 2013 | 0 Permalink | Reply
    Tags: commands,

    Autostart desktop

    1. Enter the following on the command line

    sudo raspi-config

    2. Select “3 Enable Boot to Desktop” with your arrow keys and press enter key
    3. Select and press enter key and your are back on the main menu
    4. Select with the tab key
    5. A dialogue saying “Would you like to reboot now?” Select with the tab key


    Enter the following on the command line

    sudo nano /etc/inittab

    Change the line:

    1:2345:respawn:/sbin/getty noclear 38400 tty1

    to this with {USER} as the name of the user you want to auto login with

    1:2345:respawn:/sbin/getty autologin pi  38400 tty1

    Hide mouse

    Install unclutter and it will hide when there is not activity.

    sudo apt-get install unclutter

    Then set a delay for how long it will take before hiding the mouse through the command line:

    unclutter -idle 1

    You can also set it for a specific user

    unclutter -idle 1 -user

    If you always want to hide the mouse, add the code into a shell script and make an auto start file like below:

    Autostart python script

    1. Create a desktop file that will run your python script

    cd /usr/share/applications/
    sudo nano app.desktop

    Add the following content to your desktop file:

    [Desktop Entry]
    Comment=Start application
    Exec=sudo python

    2. Save the file and exit the editor.

    3. Add the desktop file to your autostart directory with this command

    ln -s /usr/share/applications/app.desktop ~/.config/autostart/

    Make sure that you add this to the user you log in to. So if you log in as pi, stand in the directory pi and run the above command. If you use another user it would be /home/username/.config/autostart/

    To double check that your desktop file runs you can run it from /usr/share/applications/ directory.

    4. Reboot and see result

    Kill all processes for one service

    pkill omx

    From Python script:

    os.system(‘pkill omx’)

    Kill a certain process

    To kill a certain process you can pass it the entire command of the process to target just that process.

    pkill -9 -f "/bin/bash /usr/bin/omxplayer -s /home/pi/myfilm.mp4 -o local"

    This can be done directly from Python as well:

    os.system(‘pkill -9 -f "/bin/bash /usr/bin/omxplayer -s /home/pi/myfilm.mp4 -o local"’)

  • How to enable reverb in FMOD iOS

    Ellen 19:40 on May 5, 2013 | 0 Permalink | Reply
    Tags: , iOS

    To enable reverb settings in Fmod Designer click on “Window” > “Reverb Defs”. Select your reverb and click on the play button. The reverb is now active and the project can be built. Notice that for the time being Fmod Designer requires you to always activate this whenever you open your project. This is not done automatically. The name of your reverb, in this case “Reverb00″ is used later on in the code.


    To activate the reverb in the code the follow code needs to be added:

    #import "SoundManager.h"
    #import "mySoundProject.h"
    @implementation SoundManager
    void ERRCHECK(FMOD_RESULT result)
        if (result != FMOD_OK)
            //fprintf(stderr, "FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
    - (id)initWithString:(NSString*)selectedProfile
    system  = NULL;
        eventSystem = NULL;
        FMOD_RESULT result      = FMOD_OK;
        char        buffer[200] = {0};
        FMOD_REVERB_PROPERTIES reverb00;
        result = FMOD::EventSystem_Create(&eventSystem);
        [[NSString stringWithFormat:@"%@/mySoundProject.fev", [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
        result = eventSystem->load(buffer, NULL, NULL);
        result = eventSystem->getReverbPreset("REVERB00", &reverb00); // Same name as in Fmod Designer.
        result = eventSystem->setReverbProperties(&reverb00);
        result = eventSystem->getGroup("MySoundProject/MySoundProject", FMOD_EVENT_DEFAULT, &group);

compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top