Garage Door Opener – a tinier computer project

Despite the issues with bricking the device and it recovering itself in a random state, I decided to go with what I had rather than risk bricking it again. This caused a few issues, but I can live with them. Below are the steps and some notes about how things went.In the picture below is the complete Raspberry Pi installation, below it the compete Omega installation.

Omega v Pi

Omega v Pi

Set up steps

  1. Unbox and plug in. Lovely packaging, shame to take it out really! I used a stanndard Micro USB cable plugged in to an office PC with a wifi connection. You have to use another computer with a wifi connection,
  2. Connect the computer you are using to the new wifi network that has appeared in your list, in my case it was called Omega-48CD. The 48CD part is the last 4 characters of the MAC address. The default password is 12345678. The Omega is acting as an access point (AP).
  3. Use a browser to log on to http://omega-48cd.local. The Omega set up wizard will start, and you can go through the set up process – login, wifi, update software, install console and latest firwmare updates.
  4. When Omega is rebooted, use a browser to go to http://omega-48cd.local again and log in to  console using “root” and “onioneer”. In general settings, change the password for “root”, change access point password, check for firmware upgrade again.
  5. In order to install all the software I required to create the Garage Door opener, I was probably going to need more than 32MB of storage. I bought the Omega 2+ because it had a built in Micro SD card slot, which can be used to extend the onboard storage.
    I have a 4GB Micro SD card which seemed ideal, so I put it into the Omega 2+, and changed system to boot from it. Full details can be found here on the Onion Omega 2 Documentation pages Make sure you follow the instructions exactly, especially when changing the config file, a mistake in the overlay line just stops it working.
  6. I am a PHP programmer, not a python programmer, so I want to use PHP to process my web pages. In fact, I intended to use exactly the same code as I used on the PI wherever I could. I needed to install PHP as detailed in the documentation pages. I don’t need to install a web server, as the Omega comes with its own light weght one installed.
  7. I like to use Nano (OK I dislike using Vi or Vim – I haven’t had a pony tail for many years now) so I installed the Nano text editor using
    opkg update
    opkg install nano
  8. Much as I want to use PHP, somethings have to be done in Python or C. I dislike C more than Python, so I used this page to install python light. No need for the full version, the sole use is for the relay expansion.
  9. In order to control the relays on the relay board, I needed to install the relay expansion python module. This is a Python script which may use a C program, and it delivers functions to initiate the relays, and to set them on and off. These can be called in small python scripts I have to write, which in turn will be called from my PHP code.
  10. change ip address to static by editing /etc/config/network with (my settings  – use your own based on your router). The last line seems quite important, I didn’t need it on the PI changes, but the Omega won’t work without it.
    config interface 'wwan'
    option proto 'static'
    option hostname 'Omega-48CD'
    option ipaddr ''
    option netmask ''
    option gateway ''
    option dns ''

    And maybe restart the network using /etc/init.d/network restart and the DNS thingy using /etc/init.d/dnsmasq restart
  11. The Omega is set up to use webcams virtually out of the box using the MJPG Streamer package. This a little basic, but seems to work very well. Just plug in the camera and set up config file. I used a Logitech C525 or similar (looks a lot like one) that a customer recycled through my business. The Omega can handle really high quality video, so I set it to its proper resolution (1280 by 720) with a frame rate of 30 and quality of 80%. This is done in /etc/config/mjpg-streamer. The camera can be tested in the console, and from that test you can get the code needed to stream the camera in the web page. In my case it was
    <img src= ""/>

    where is the fixed IP address set up above, and 8080 is the port allocated in the /etc/config/mjpg-streamer.
    I had an issue with starting the streamer, this code automatically starts the streamer at start up. /etc/init.d/mjpg-streamer enable
    Full details of streaming over wifi are here
    The camera and the Omega work really well together, and seem to cope with low light a lot better.
  12. Set up python scripts to flick relays on and off. These are based on the routines I set up for use on the PI, but the functions called are a little different. The lines in red check to see if the relays are initialised, and if they aren’t, initialises them The code in blue sets the channel zero relay on, then 0.2 seconds later, sets it off.
    The addr value of 7 is the hardware address of the relay board. If I added more relay boards, each would need a different address. A similar script does the same for the channel one relay.

    '''**************************************************************************** $
    Pulse relay number 1 for 0.2 seconds
    By dave Glover
    ******************************************************************************* $
    from OmegaExpansion import relayExp
    import sys
    import time
    addr = 7
    ret = relayExp.checkInit(addr)
    if (ret != 1):

    ret = relayExp.driverInit(addr)

    print "checking if initialized: ", ret
    ret = relayExp.setChannel(addr, 0, 1)

    ret = relayExp.setChannel(addr, 0, 0)
  13. As mentioned above, I used the PHP script to generate the web page that I created for the Raspberry Pi version, This needed very little modification. Below is the PHP portion of the code, with the changed lines highlighted. Executing the Python scripts in PHP is much easier, no need to use Sudo, and no need to give the PHP program god rights to use Sudo without a password! The video live stream is discussed above.
     exec('python /www/omegarelay/');
     echo '<div class="notification">North door activated</div>';
     else if(isset($_GET['s'])){
     exec('python /www/omegarelay/');
     echo '<div class="notification">South door activated</div>';
     echo '<div class="notification">Waiting for input</div>';
     else {
     echo '<div class="notification">Live video stream</div>';
     echo '<img src= ""/>';
  14. With it all set and tested on the bench, the Omega was attached to a 4 pin socket for the relay connection, a wifi antenna was attached just to make sure, and the camera on the ceiling was changed to the new Logitech camera, and connected to the Omega. Power was applied, and the new Omega garage door opener was up and running.A step by step, feature by feature comparison with the Raspberry PI will follow. First impressions are that they are fairly evenly matched, with specific difficulties and features in each device.

Screen shot with new camera on Omega 2+

Posted in Computer Stuff, Onion Omega - Internet of Things, Programming, Raspberry Pi
One comment on “Garage Door Opener – a tinier computer project
  1. Dave says:

    The omega was running hot, a common problem. The live stream of the video was the only real workload, so I reduced the frame rate to 10fps, and left the resolution and quality as they were. The temp dropped to about 32°C which is within normal range. Problem solved!

Leave a Reply

Your email address will not be published. Required fields are marked *