Archive for the ‘Programming’ Category

DIY Baby Monitor

10/11/2016 4 comments

I recently discovered WebRTC in another project and wanted to try it out in some home project. Since our another home project is nearing it’s delivery, a baby monitor seemed to be in the (very long) list of things to buy.

Our baby will probably be sleeping mostly outside in the baby carriage and I wanted some kind of device with live picture thats viewable anywhere in the house to keep an eye on him while doing something else. WebRTC seemed to fit the bill since it works wherever a recent enough browsed is available like in the Android tablet we have in the space between our kitchen and the living room. I tried to use ready software and 3D-printable parts wherever possible to make something usable fast. Read more…

DIY Remote shutter release for Samsung NX-series cameras

30/04/2013 210 comments

I’m using Samsung NX1000 for aerial photography. The camera has a nifty feature of using smartphone as a remote viewfinder and shutter release but unfortunately the good idea is watered by buggy and limited program and the feature freezes the whole camera all too often. Fortunately there is a simple way of triggering the shutter via cameras usb-port. The trick is to have 68K resistor between ID and GND pins. After this USB data lines can be used to trigger camera focus and shutter.



Tip: If you have spare micro-usb cables, it’s easy to source a connector from the cable that came with the camera. Just squeeze black plastic around the connector with a pliers and the plastic casing will crack open exposing the connector. The connector on the cable has a small pcb, which makes it easy to solder the required resistor in place. If you use smd resistor, the casing can even be reassembled.

The cable described above works fine for manual use, but to use the camera for aerial photography some interface for rc receiver is needed. Fortunately this is easily achieved with a small arduino program, which reads pwm value from receiver servo port and then pulls either shutter or focus line low based on channel value. The compiled code size is under two kilobytes, so it’s possible to use small and inexpensive microcontroller like AtTiny2313.


RC interface for camera

The schematics and sources can be found at:

Compatible with (at least) following models: NX20, NX210, NX1000, NX1100 and NX2000

Update: If you don’t want to make your own, I’m selling these ready made. Just drop me a message.

Shutter PCB's

Shutter PCB’s

Updating electricity meter to communicate via WLAN

RN-XV image (c) Sparkfun

A while ago Farnell sent email to me and offered one (inexpensive) product  as a sample in exchange for mentioning it at this blog. I browsed for a while for an interesting part and settled with Microchip MRF24WB0MA/RM WiFi module (Order code 1823142). This module is quite inexpensive and is used in products like WiShield and thus has good Arduino support.

I wanted to upgrade my electricity meter to communicate with WLAN to get rid of XBee receiver at the back of my server. After some prototyping I ended up using RN-XV module from Roving Networks. Since my application did not have to do any fancy network stuff, RN-XV was a perfect match. It has the same footprint as XBee module, which I was already using, so the hardware required no changes. The module supports WPA2 security and can remember it’s settings. Communication via HTTP request is incredibly easy, I set up the module to generate http request to my home servers address each time when AtMega output measurement data.

Unfortunately some thing are just too good to be true. The module soon proved to be quite unreliable. Each time after about 14 hours of operation the module lost connection to accesspoint for ever. I tried to solve issue with technical support. By default if module looses AP, it does not try ever to reconnect unless linkmon parameter is specified, which to me is quite braindead default setting. Even with the linkmon RN-XV did not work for long with my Cisco AP. I tried everything including rebooting the module every hour, adding commands to force reconnect and even doing hardware reboot to the module, but without much success. Eventually I changed the RN-XV to connect to different AP. It still looses the connection every now and then but it’s able to reconnect after random time. Still in every 24 hours the module is unavailable for about total of 3 hours due to lost connections. RN-XV firmware version I have is 2.36.

In the end, only changes I made was to modify server backend to accept HTTP requests and change the code running on the AtMega to output measurement data periodically instead listening request from XBee.

The RN-XV was configured with following commands:


set ip dhcp 1  # get ip from dhcp

set wlan auth 4 # use wpa2-psk encryption

set wlan phrase password # set network password

set wlan ssid network # set the name of accesspoint to connect

set wlan linkmon 5 # After 5 tries declare connection to AP lost and try to reconnect again.

set ip proto 18 // turn on HTTP mode=0x10 + TCP mode = 0x2

set ip flags 0x6 # close tcp connection if accesspoint is lost
set ip host ip # server ip address
set ip remote 8080 # server port
set com remote GET$/? # GET string to be sent to server. Any data from uart will be concatenated to this string
set uart mode 2

All in all, for simple projects, I can really recommend the RN-XV module over the MRF24 due it’s simplicity, but definitely not for reliability. Both modules cost about the same, but apart from Sparkfun I don’t know who else has them in stock. Farnell could start selling them, since ordering from Sparkfun can get expensive if you don’t live in the states.
Sources can be found from the repository:

Showing APM telemetry data on Hitec Aurora’s screen (revisited)

10/05/2012 53 comments

In my previous post I described building adapter which converts APM telemetry data to be shown on Hitec Auroras screen. Since then APM2 hardware has been released and some code changes made previous version unusable. I updated the hardware and software to support also APM2. I couldn’t get SPI transfer to work in APM2, but fortunately it has a spare serial port to use. The good thing is that now only three wires need to be connected to APM2 and nothing needs to be soldered.

APM1 is still supported, wiring instructions are in the previous post. When using with APM1, USE_SPI must be defined in main.cpp.

This version also includes support for showing GPS coordinates. Previously I thought it’s not really useful feature, but I changed my mind after searching for crashed plane in wintery forest in the light of the setting sun for a long time. Coordinates would have been useful after all. Time and Date are still unsupported since APM internal date format is yet to be decided.


Updated schematic

Connecting to APM2. Only three wires are needed.

Sources are uploaded to github:

Update 5.1.2013 – Error in schematic corrected. Added fet to power video transmitter after GPS lock has been acquired.

Update 7.1.2013 – Kind of a long shot, but if somebody wants to borrow me a Spectrum or Graupner system, I could modify the device to support different telemetry protocols.

Info display for home

05/03/2012 12 comments

After completing the home electricity meter hack I looked for options to have small display hanging on the wall, which would show useful information. I had previously bought Samsung SPF-87H photo frame which can be used as an external monitor. The frame connects to computer with usb and the picture is updated by simply sending it in jpeg format. Few caveats are that display needs to be first initialized to “mini monitor”-mode and the picture size must match exactly to the display resolution (800×480 in case of SPF-87H). I chose Beagleboard as the embedded computer to keep the power usage low. BB has one usb and one usb-otg port. I’m planning to change the Beagleboard to Raspberry Pi, when they became available since this doesn’t use all the resources provided by the Beagleboard.

Even that the Beagleboard has only one true usb-port, I did not need to add the usb-hub to setup, since the usb-otg port can also be used as host. The display connects to otg-port, since it has it’s own power supply (otg-port can’t supply power) and the regular usb port is used for wlan adapter.



Testing the setup

The photo frame has desk stand but no hole to hang it on the wall. This was fixed by using hot glue to attach a piece of wire to the backside to act as hanger. I learned later that I should have made a loop to the both ends of the wire to increase gluing surface. The frame dropped to floor after couple of days, resulting small crack to bezel and a dent to floor. Fortunately the display continued working.

The finished display looks quite nice. The Beagleboard and the power supply are hidden on top of cupboard and the display cables are hidden inside cable duct.

Finished display







The software “WallDisplay” running on the Beagleboard is written in C++ and uses Qt. The software simply reads Sqlite database, which contains a list of urls and time, how long the url is displayed on the screen. The web pages are loaded to QWebPage and its contents are exported as jpeg file, which in turn is pushed to the display. Qt’s webkit implementation has too many ties to the user interface for it to be used as command line QtCore-application. Since the program does not have to actually show anything on a real monitor nor accept user input, I’m using xvfb to simulate X-server. In future I’m planning to add web interface to make it easier to manage the displayed pages.

Currently the display is rotating following pages:

  • Electricity usage
  • Weather forecast
  • Calendar, exported from iCal
  • Irc log from the channel we used with my friends
  • Last picture from the security camera

The sources are available at:

You also need to install software for controlling the display from here:

See rc.local file for an example how to run the application. Path to database and path to frame-ctrl program must be given as arguments. The database creation command is in the readme.txt file.


Routing APM communications to Internet

28/12/2011 4 comments

I’ve been wondering, what would be the easiest way to route telemetry and commands from APM to Internet. Using 3G modem, would provide almost unlimited range (I know there has been some discussions about this in DiyDrones forum. Here in Finland the GSM network is very covering, but due the way the cellular towers are optimized, maximum altitude where the connection works is probably less than 200 m.)

In theory, list of required hardware is not long. One just needs to receive messages from APM and encapsulate them to UDP packets and send via 3G modem and vice versa. Unfortunately handling PPP communications is too large task for simple microcontrollers. I ended up using BeagleBoard for the sake of easy development and since I had one at hand. I realize that BeagleBoard (which essentially is full computer by itself) is an overkill, but it’s not very heavy and fits easily inside Maja’s fuselage. Basically any embedded system, capable of running linux and acting as an usb host would do. Maybe in the future I figure out some additional tasks for BeagleBoard to do.




The software that handles the communications is a simple Python script. Since APM has no onboard configuration interface, the program fetches configuration at start-up (and every 5 minutes) from URL, given as parameter. Currently configuration consist on ground station IP-address and port. Since typically ground station is connected to internet with 3G modem, it’s IP-address is not fixed. Current address can be then updated to the configuration file and file uploaded to some known server.

When the script is running, it simply listens to serial port and when it receives valid MavLink packet, it sends to to ground station and vice versa. I made couple of fixes to UDP handling for APM Planner. By the time this text is published, modifications should already be included on the latest version (without the fixes, connection usually fails when Planner queries parameters from APM and expects to get those in a numbered order, but with UDP, packets may arrive in random order)




Testing setup

Hardware wise setup is very simple. Beagleboard needs to be powered from 5v source. Due to 3G modem, power demand is very “spiky”, so regulator must have enough power output (big enough capacitor helps too). I connected APM telemetry port to BeagleBoard main serial port. Since Beagle has standard RS-232 levels and APM uses +3.3v logic, I used common MAX3232 driver between those. The downside is that console on BeagleBoard’s only easily accessible serial port must then be disabled. Be sure to do this only after you make sure, you can connect to Beagle via internet.

It’s also possible to use second serial port on Beagle. It’s however not enable by default and enabling requires compiling new kernel. Second serial port uses +1.8v logic, so level shifter is needed.




  1. Script to connect using 3G modem
  2. Script to bring up interface at boot and reconnect if needed.
  3. Disable console on serial port
  4. Place configuration file on known server
  5. Script to launch MavProxy at boot



  1. Connect ground station to net and check it’s ip
  2. Update ip to configuration file and upload it to specified server
  3. Power-up the plane and wait until it BeagleBoard boots up (Usually 3G modems have some kind of indicator light notifying when it’s connected. You can use this to check when the plane is ready)
  4. From APM Planner, select “UDP” as port and press connect (Plane must be sending data at this point)
  5. Enjoy!


Copying EyeTV recordings

I often record tv-programs with Elgato EyeTV and transfer them to my media server to be played back later with Playstation 3. Previously I did this by exporting recordings to H.264 and moving them to media server. Exporting however takes a long time and while the file size is reduced considerably, to me it’s totally unnecessary since I generally don’t watch them twice.

EyeTV recording format was a total mystery to me, until by accident I realized that the .eyetv files are actually directories, containing recording as an mpeg file. The actual mpeg file names are just series of numbers. I wrote a small python script which processes all .eyetv directories and copies included mpeg files with corrected names to selected directory.

The script can be downloaded here:

Usage: [-d] /path/to/eyetv/directory/*.eyetv /destination/directory/

If -d switch is used, recordings are deleted after successful copying. EyeTV however does not note that recordings have been deleted, until it’s restarted.

EyeTV has a capability to trigger scripts in certain events. Instructions can be found in this page. AppleScript command to execute shell scripts is:

do shell script "command arguments"

Please drop a comment if the script was helpful for you =)

Categories: Programming Tags: