Search

Putting a raspberry pi into an old radio from the 60s had been on my project list for quite a while. Having a dedicated internet radio player inside a beautiful old case and with all the original controls connected would have been so awesome. I was hence very excited when I finally got around to buy a used 60s radio, settling for a “Löwe Opta Magnet 4725W“. Unfortunately, it turned out that the old radio I bought from a nice lady nearby still works, despite having been advertised as “broken”. Buggers, as I can’t really bring myself to destroy something that is still functioning perfectly fine.

The Löwe Opta Magnet 4725W – High Tech from the 60s.

However, there are alternatives to breaking it, especially as it features a line-in connector on the backside, which was originally used to connect record players or tape recorders. After some reading on the web and buying the right cable I tested connecting the radio to the audio jack of a Raspberry Pi 1, which worked well enough for me to stop investigating any further.

Next question was: how to control the radio? Some earlier experiments with potentiometers for controlling volume and selecting channels had already convinced me that this was the direction to take, but also showed that rotary encoders would probably the better choice due to their comparably greater range, and also have the advantage of (kind of) working out of the box with a Raspberry Pi (i.e. without involving any further chips that convert the analogue readings of the potentiometers to a digital signal).

An earlier prototype with potentiometers. Note the DAC chip to read the analogue signals on the RPi.

As rotary encoders come in different flavours and are often not well documented (at least for laypersons), I tried to find a model that reportedly worked and ended up getting some KY-040s that already had most of the circuitry on board. Apart of GND and power, only two pins need to be connected to the Raspberry Pi’s GPIO as inputs: one Clock pin, and one Data pin.

The read the rotary encoder from software, you basically need to do two things: 1) listen to the input of the Clock-Pin, and when you detect that it is getting from HIGH to LOW, 2) read the Data-Pin to figure out if the knob was turned clockwise (HIGH) or counter-clockwise (LOW). Here is a simple example on how this works in Python. You can read up further on KY-040s and how to connect them to a computer here (the example is about an Arduino).

For playing web radio streams, I used the popular Music Player Demon (MPD) which is easy to install (as in “apt-get install mpd”) and quite versatile with regard to its use. I then wrote some Python code that uses a library to control the MPD based on a playlist containing all the radio channels I like to listen to. After figuring out how to control the MPD from Python and combining that with the code for reading the rotary encoder, I can now use a knob to switch between channels on my radio; for volume, I can just use the controls of the original radio.

You can find the code for the radio here, in case you are interested: https://bitbucket.org/snippets/boden/ppRAdG. The principle of reading the rotary encoder is similar to the example above, with some small tweaks. The rest is just code for controlling the MPD (including making sure the button works even when another MPD client is used in parallel), and for cleaning up the GPIOs when the Raspberry Pi is shut down. The music playlist itself needs to be configured in MPD, for which several clients are available on a variety of platforms (so as a nice side-effect, the radio can also be controlled easily from the smartphone or any other computer on the network).

The control knob for switching the channels – already covering dust like the radio it controls.

So far, the rotary encoder is sitting in a plain paper box next to the Raspberry Pi. Next steps would be to get a nicer case for it or potentially putting everything right into the radio itself. We will see.

I got a Raspberry Pi 2 for my birthday and, as a small evening project, ported my Arduino Weatherstation project to this new platform.

The setup is relatively simple: I used the Adafruit Python DHT Sensor Library to read the sensor values from the GPIO, logging the resulting values with a timestamp to a CSV file. Another python script then reads this files and creates a graph using the Matplotlib library (which can be installed easily on the RPi with sudo apt-get install python-matplotlib).

Both scripts are called every five minutes by crontab, and the resulting image is displayed on a webserver (I used nginx, which is also quite easy to install).

Next steps would be to log to a database instead of a file, and implement different visualizations over different time intervals.

So far the setup seems to work well, but the sensor readings regarding the temperature look a bit high (maybe influenced by the Arduino which gets warm over time … its probably better to place the sensor away from the board, and not right on top of it).

Just a snipped of code that I have found for creating a candlelight-like light with a yellow LED attached to a PWM port of an Arduino (called here ledPin). You could probably add another red LED to optimize the effect, but for a first try it does not look too bad.

I have created a holder that can be used to attach my Arduino-based camera remote to the hotshoe of the camera. The file was created in the CAD software Rhinoceros and printed on a MakerBot Replicator 1 owned by the University I work at. Its a rough first try, but the device works.

Just some brief notes on how to post status-updates to status.net from an Arduino with an ethernet shield. Status.net is an open source micro-blogging solution that is used for example by the Twitter alternative identi.ca (so it should work with identi.ca, too, but I have not tested it so far).

Posting to status.net is actually very straightforward. You just need to send a simple HTTP POST-request with your login credentials and the message you want to send (there are other optional parameters such as the source of the post or your geo-location, check the API description if you want to use those).

The message you want to send needs to be URL-encoded, which basically means that you have to exchange certain characters (!*'();:@&=+$,/?#[])with codes. For example, a whitespace becomes %20, so “This is a test” would become “This%20is%20a%20test”. Check this site to find out how to encode other characters.

Your login-credentials also need to be encoded, but this time as Base64. There are several websites that will enocode your credentials for you, check for example this site. Enter your credentials there in the form of username:password and you will get a result such as dXNlcm5hbWU6cGFzc3dvcmQ= which needs to be entered into the code. Obviously, username and password have to match an account at the server you are posting to.

If you got this, you are ready to go. Just start an Ethernet connection with your Arduino (using the Ethnernet library) to the IP address of your status.net server. You can find out how to use EthernetClient with Arduino here.

If the connection was initialized, perform the following HTTP request that is based on the examples described above:

The first line defines the url of the statusnet api (the path may need to be adjusted to the correct url of your server), and adds the URL-encoded status message as well as the source of the post. The second line provides the basic HTTP authentification as a Base64 string. The third line sends an empty line to signal the server that the HTTP request is completed.

This is a binary clock that was built into a 3d-printed case created in Minecraft. It shows the current time in a binary coded decimal format. The code and idea are based on a tutorial by Daniel Andrade.

The model was exported with the free tool Mineways and printed on a Zprinter 650 3d-printer, with a block size of 125mm^3 (so every block has an edge length of 5mm).

17:07 (i.e. 5:07 PM)

After printing, LEDs were glued into the case after filing the openings a bit wider. Then, the LEDs were soldered to form a 4×4 LED matrix, and the matrix was connected to an Arduino board. Two pushbuttons were added for setting the clock (hours and minutes).

The circuit of the binary clock (not very accurate, I know, but you get the idea…).