Wednesday, November 06, 2013

Picture viewer with remote picture syncing

Goal of project:
Create a picture viewer display using a raspberry PI, a screen and a wifi usb-interface.
The viewer shall be able to display a number of images and it shall be possible to update the images displayed remotely, preferably from picasa.
It shall also be possible to access the viewer remotely to perform any maintenance of the device.

Final result of project:
Picture viewer deployed, possible to update the images from picasa, the unit opens upp a reverse ssh connection to my home server, giving me handy access, regardless if the viewer hides inside a firewall.

Parts needed:
Raspberry PI,
I used model A due to low performance requirements.

External screen,
http://www.ebay.com/itm/8-9-CHIMEI-N089L6-L02-LED-Screen-Panel-Module-DVI-Controller-Board-1024x600-/370811546169?pt=US_Laptop_Screens_LCD_Panels&hash=item5656172a39

Make sure it supports HDMI for easy convenience.
The board I bought had quite a large footprint with HDMI, DVI, VGA inputs and audio output, input.
Try to find one smaller if possible

SdCard,
I ended up using a 16 GB card, from a price / performance perspective.

USB wifi-dongle.
I purchased a realtek one from dx.com for about 8 bucks
http://dx.com/p/ultra-mini-nano-usb-2-0-150mbps-802-11b-g-n-wifi-wlan-wireless-network-adapter-white-67532

Power adapter,
I bought a 12V 2A adapter from ebay for about 6 bucks.

Spacers,
Used to get some height against the wooden back plane, I belive I paid 3.20 quid for them.
A very short HDMI cable for internal routing.

Assembly:
I cut a wooden frame that would fit all the parts and drilled and screwed down spacers for mounting of all the base parts. The parts were mounted and connected together.
In the image below the bottom pcb is the raspberry pi connected via a small HDMI cable to the chi-mei main board.
By luck there was a 5V output available on the chi-mei mainboard which I used to power the pi.
The chi-mei input voltage is 12V which is what I feed the system via the power adapter.


I used a 3.5 mm headphone jack wired to the serial rx / tx pins, this allows for easy serial access.

Software:
The ordinary raspian debian distribution is used.
I hacked the init script to automatically launch qiv which is a basic photo viewing application.
A cron script pulls down a picasa web album every day where I can put the pictures from my ordinary display.

This unit will reside at my parents in law, behind their firewall.
I wanted to have a fail-safe mechanism of being able to access the device.
This is solved by using a reverse autossh connection.
The machine will at start connect to another pi acting as my local server.
Thus I can at any moment access my local pi and connect to the picture viewer.

See this link for more information:
http://akntechblog.wordpress.com/2010/09/11/autossh-for-persistent-reverse-ssh-tunnels/

In order to get native 1024x600 resolution, a custom HDMI mode needed to be used.
This was acheived by adding the following to the /boot/config.txt:

framebuffer_width=1024
framebuffer_height=600
hdmi_force_hotplug=1
hdmi_cvt=1024 600 60 3 0 0 0
hdmi_group=2
hdmi_mode=87

gpu_mem=16

Frame assembled without paint

Final result:

End result

I was satisfied with the final result, things I would improve would be to find a graphic driver with less board space and to improve my woodworking skills.


Labels: , , , ,

Friday, August 30, 2013

Thermometer using an arduino, a 7 seg display and a DS18B20

Today I pieced together a small arduino project using a temperature sensor and a 7 seg display.

The video below pretty much sums up the functionality.
I'm quite satisfied with the results given how little time I put into the project.

The arduino is a great platform to base your project on as the number of support libraries truly speed up your development. For instance, getting the temperature sensor up and running took only a couple of minutes.

The hardest part of the project was to try to minimize the flickering while doing the display multiplexing. There is still some flickering due to that some cycles need be spent quering the sensor.
I don't know if this is solvable without involving some external circuitry


Labels: , , , ,

Monday, August 26, 2013

Monday evening fun!


Tuesday, August 13, 2013

Controlling a receiver using an raspberry pi and an ir transmitter

The aim of this project was to stream music from my computer to my receiver wirelessly and to control the power and input selection of my audio receiver.

The streaming part was resolved by adding a raspberry pi next to the receiver, connecting it via the aux input and using shairport to emulate AirTunes, https://github.com/abrasive/shairport/commits/master  

This allows me to stream from any audio source from my macbook air via the excellent airfoil utility, http://www.rogueamoeba.com/airfoil/.

There was still a problem that was nagging me: I needed to manually power up the receiver and set the correct audio source before I could enjoy the sweet music my ears were craving.

My receiver, a Yamaha RX-396RDS has an infrared-interface with a remote.
Thus I built the hardware and software to control the receiver from my pi using an infrared led.

Hardware
IR receiver
To clone the ir commands of the my remote I had to build an IR receiver and connect it to the PI.
Buy an ir receiver transistor, solder it to a female header pins and connect it to the PI.
As always, be careful when attaching stuff to the GPIO pins, as you might destroy the PI GPIO pins.

IR-receiver with its headers
IR transmitter
I've seen other projects connecting an ir-transmitter LED directly to one of the pins.
This is risky as you might damage the pins or the pi by drawing too much current.

I didn't want to take my chances and decided instead to build my own support board where power to the LED is taken directly from the 3.3V pin and the GPIO pin is merely used as a switch using a NPN transistor.

Parts needed:
1 NPN transistor, I used a C1815
1 resistor, 22 Ω
1 resistor, 600 Ω
1 IR-transmitter LED
Resistor values may change depending on what setup you have. 
You can probably swap out the 600 Ω for a higher one.

Schematic

Connect the parts as the schematic indicates. 
The resistor values are adapted for the 3.3V supply voltage of the raspberry pi but R2 can probably be swapped out to a resistor with higher value. It depends on what transistor you are using.



Board is assembled and plugged in. Black and blue wires goes to the IR-led

I did some debugging at this part to ensure the design was sound.
The light spectrum that the IR LED transmits is invisible to our eyes. 
Fortunately cell phone cameras do detect them due to how their filters are designed.
What I did was to film the LED with my cell camera in order to verify the functionality.




IR-board connected to the pi

I connected the VCC, GND and GPIO pins to a female header and connected it to the PI.

Take care to connect it correctly, I connected the pi input to pin 10.
I positioned the IR LED in such a way I was sure that it had a clear line of sight to the Yamaha receiver IR-receiver.

Software
The LIRC software was installed on the pi. 
If you use the raspian linux distro, it is available in the package manager.
Just issue an apt-get install lirc.

First I tried to use the existing yamaha RAX7 remote control firmware, but couldn't get it to work.
I then had to proceed to capture the input from my remote. 

After connecting the ir receiver to my pi, I had to load the lirc kernel module and instruct it to understand which pin I wanted to use as input.
The command modinfo lirc_rpi gives you the exact properties to use.
In my case I had connected the ir receiver input to pin 10 and used the following command:
sudo modprobe lirc_rpi gpio_in_pin=10

I checked the kernel log using dmesg to verify that the lirc module was properly loaded.

The command irrecord was used to to create a new firmware for the remote.
I had to use the force mode for proper functionality but your milage may vary.

After having created a proper firmware I needed to place it in /etc/lirc and rename it to lircd.conf.

I then removed the IR receiver from the pi and removed the lirc_rpi module by issuing:
sudo rmmod lirc_rpi

Then the lirc_rpi_module was inserted again but now with the gpio_out_pin=10 argument and the ir transmitter module was inserted, with the GPIO pin connected to pin 10.

The irsend was then used to send ir commands to the receiver via the ir transmitter circuit.
For debug the SEND_START command is useful as it repeats the signal indefinitely.

I got the receiver to react to the commands sent from the PI. 

Success!

Interaction with shairport
The final piece of the project was to start the Yamaha receiver and switch to the correct input when I connected to the shairport server and to do the reverse when disconnecting from the pi.

I first wrote some minor scripts and placed the in /usr/local/bin, taking care to make them executable.

start_tuner
#!/bin/sh
irsend SEND_ONCE yamaha_rax7 KEY_POWER
irsend SEND_ONCE yamaha_rax7 KEY_TV2

stop_tuner
#!/bin/sh
irsend SEND_ONCE yamaha_rax7 KEY_TV2
irsend SEND_ONCE yamaha_rax7 KEY_POWER

Lastly, I edited the /etc/init.d/shairport and added --play_prog=start_tuner --stop_prog=stop_tuner to the DAEMON_ARGS line.

That's it!

Here's a video showing it all in action.






Caveats, future improvements
The system has no feedback structure and relies on dead counting i.e the volume must be sane, the receiver must be positioned in its nominal setup.
However, fixing this issue this is much more complex task.
If one would add some kind of relay switch killing the power fully to the receiver it would return to its default state that would be a way forward.

The volume dial is mechanical so the startup would then need to turn the volume down for a long time ensuring that we always start off from a zero state.


Labels: , , , ,

Thursday, September 20, 2012

Garageplatsen.se

Vill tipsa om den eminenta sajten Garageplatsen.se där du både kan hyra och hyra ut parkeringsplatser, dessutom är det gratis för privatpersoner!

Thursday, March 01, 2012

Watch out for using the same drawable reference on an maps overlay and on a dialog

I've been having problems where I display multiple items on an overlay.
When displaying an alert dialog on top, some of the items got corrupted, and remained so even when closing the alert dialog.

When you create an overlay item, you define the drawable draw bounds by issuing boundCenter(drawable) or boundCenterBottom(drawable).

The problem was that I used the same drawable as an icon on the alert dialog displayed on top. The dialog somehow altered the draw bounds under rendering which caused the overlay item to be corrupt.

The fix is to use separate drawable instances for the overlay and alert dialog

Labels:

Sunday, February 26, 2012

Android, Creating a progress bar of custom size

By default, android gives you a small and a large sized spinner progress bar.
What if you want a spinner of a different size?
Easy, create a custom style in styles.xml in res/values




Trim the width / height values to your liking.

Define the progress bar in your view.xml and point to the style that you previously defined.

style="@style/Widget.ProgressBar.Medium"
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

Hope this helped!