Script to change keyboard layout on Raspberry Pi

To make it easier to change keyboard layout on a raspberry pi I wrote a small shell script. Be warned, this is one of my first scripts. So it is not optimal, and no guarantees. Use at your own risk.

echo "--------------------------------"
echo "Script to change keyboard layout"
echo "--------------------------------"
echo "Which layout should be used? tr=turkish, se=swedish, gb=english etc"
read layout

sudo sed -i 's|XKBLAYOUT=....|XKBLAYOUT="'$layout'"|g' /etc/default/keyboard

echo "Changed to"
grep "XKBLAYOUT" /etc/default/keyboard | sed 's/XKBLAYOUT=\(....\)/\1/g'
sleep 1
sudo reboot
exit 0

Save the code to a file (or downoad from here). Then add execute permission on that file with the command chmod 755 Then you can run the file with ./

Look in this list to find the 2 character code for the country layout you want to use.

New robot project!

Last saturday I went to an auction of random old electronics. After some hours of boring junk and slightly interesting items being sold for way too high prices, there appeared what seemed to be a big robot on the stage. So my friends and I started a quick discussion on how much we were willing to pitch in together as a maximum bid, because we just could not let this beauty slip past us. You might be able to imagine that we were a bit disapointed when it turned out to be not a robot, but some weird video conferencing system. When the bidding opened I shouted the minimum opening bid of 1 Swedish crown from the back of the audience. Expecting the rest of the room to take over the bidding from there, I could feel my heartrate go up while a silence was all that came.

Wait, what just happened? I just bought this enormous yet awesome-looking thing for 1 kr? And how will I get it home? (I came there by foot, bringing a backpack for anything I would buy) And, what just happened? In the end I went to get my car and brought it home. (It filled the whole back side of the car)

So now I am the happy owner of a Tandberg Maestro. It seems to be in a near perfect condition, except for some dust and one broken power cable (easily replacable). The only problem for any intended use though is that it is incomplete. The biggest miss is the remote control, which according to the manual I found online, is rather crucial. As for the cables I’m not sure yet if I am missing anything more than a power cable, because the manual is not very clear on how everything should be connected.

A quick overview of the system:
– On top a good quality Sony camera with optical zoom and steppermotors for pan and yaw.
– Below that a 5(?) inch color display
– Next a set of speakers, which seem to be optimised for speech instead of music
– On the back side hidden behind an easily removable cover is the ‘codec’; the big black computer with a whole bunch of ports
– This is all mounted on a strong metal pole/frame that is attached to the base part of the frame which has a lot of empty space and some plastic wheels.

As far as I could test, all systems seem to work. I can get the video out of the camera from the s-video port. It also has a composite video port, but this seems to only give a black and white video. The steppermotors work, because they calibrate when they get power. The optical zoom can be tested by two buttons on the circuitboard of the camera. The speakers work directly when they get power. I have not figured out yet what the ‘out loop’ port is for, but I assume some kind of output of the same sound again? The screen was a little bit trickier to test. In the end it turned out that if I connect its data cable to the data1 port on the (powered) codec, the screen accepts input on the s-video port. I dug up my old laptop, which to my surprise has a s-video port, so I managed to connect the 5 inch screen as external screen. This also shows that the codec is not broken. But without the remote I will have a hard time testing anything more with it.

I have not completely decided yet what my plan is. At first I thought of building in a raspberry pi as the brains for the robot, but now that I found my old laptop with s-video port it could be an easier path to use that instead. I would like to get rid of the codec box, but then I need to find a way to fool the screen so that it works without it. Also I need to figure out how to control the zoom and movement of the camera via the ethernet cable that plugs into it. And I have not found yet how I will take the video feed as input into any computer system. Maybe a s-video to usb cable would fix that.

Some ideas:
– Motorized wheels! If this is to be a robot, it should be able to move itself around. The ‘desk chair kind of wheels’ on the back are a bit small and crappy, so those should get an update anyway. But motorized wheels might be best on the front?
– Some kind of computer as brain to control the different parts of the robot. Currently it is most likely to be old laptop.
– Wireless powersource, aka battery. The camera and speakers both like to get 12 volt, so maybe the battery should give that?
– Web based control
– Voice synthesis, or maybe an R2-D2 style of beeps. (Or both)
– A robot arm. The bar on the back is just to perfect to mount stuff on

What about a name? Maestro sounds quite nice, and is already printed in big letters on the front. (I can peel off the ‘Tandberg’ letters) Or would some number/letter combination be more nerdy? And what kind of function should this robot fullfill?

Stay tuned for more 🙂

Raspbian keyboard shortcut for window management

Raspberry Pi tip of the day: If you want to maximize your window, but do not have a mouse to click the icon, you can press alt+spacebar to open the menu in the windowbar. Similarly, press alt+[the letter that is underlined] to open one of the the menu’s in the menubar.

Analog video (RCA cable) on NOOBS Raspberry Pi

HDMI to VGA adapter
HDMI to VGA adapter

On a Raspberry Pi where the operating system (e.g. Raspbian) is installed using the NOOBS setup, using the analog port for video can give some trouble. In this post I’ll tell you why, and how to fix it.

The Raspberry Pi has quite a few ways to connect it to a screen. The most common one is the HDMI port because screens these days are often equipped with a HDMI connection. As an alternative, a HDMI to VGA adapter can be used to connect a VGA (analog) cable to the HDMI port. The third option is useful for old tv’s that only have a RCA/composite video port (or scart port, using this composite to scart adapter set to input). For the more advanced users you can also connect to the Raspberry using a remote desktop approach, and use for example an Android phone as screen (and mouse!).

RCA/composite video port on a tv
RCA/composite video port on a tv

Unfortunately, when NOOBS was used to install the os, the RCA connector seems to not work. The reason for this is that NOOBS has added a setting to the config.txt file, forcing the Raspberry to output its video on the HDMI port. So the solution for making the RCA port work is to remove that setting. Of course, if you have a HDMI cable or adapter, you can use that to boot the Raspberry, open the file and change the setting (see below for instructions). Otherwise if all you have is an RCA cable, it is easier said than done. As far as I have found, the only option then is to put the SD card into a Linux machine, and change the file that way. As a last resort, you could also give the Raspberry internet, figure out its IP address, and log in to it remotely to change the file.

RCA/Composite cable
RCA/Composite cable

If you have a HDMI cable
This is the easiest way.

  1. Connect the Raspberry via the HDMI port, and start it up.
  2. Open a terminal window (“LXTerminal”).
  3. Type: cd ../../boot to get to the /boot/ directory.
  4. Type: sudo nano config.txt to open the config.txt file with ‘administrator’ rights. If you are asked for a password, write raspberry and press enter. (You will not see anything happening while typing in the password.)
  5. Move down to the line where it says: # NOOBS Auto-generated Settings:
  6. Put a # in front of hdmi_force_hotplug=1 to disable it.
  7. Press Ctrl+x to close the file, and press Enter to save it with the same name.
  8. Now you are done! You can open the file once more to see if the saving worked. (If it did not, you might have forgotten the sudo command.)
  9. Now you can restart the Raspberry with the RCA cable connected instead of the HDMI cable.

If you have a Linux computer

  1. Turn off the Raspberry. Make sure it is off by unplugging the power (usb) cable.
  2. Take the SD card out, and put it in the SD card reader of your computer.
  3. After a short moment you should see a file explorer window open, showing the contents of the contents of the card. If nothing happens, open a file explorer yourself, and locate the SD card with the name BOOT.
  4. In this BOOT directory you should find a file called config.txt. Open it in a text editor.
  5. Scroll down to find the line where it says: # NOOBS Auto-generated Settings:
  6. Put a # in front of hdmi_force_hotplug=1 to disable it.
  7. Save and close the file.
  8. Put the SD card back in the Raspberry and start it up, with the RCA cable connected.

If you have an Android phone, internet cable, and access to your router (and feel a bit adventurous).
There are more ways to do this, feel free to find alternatives to what I write here.

  1. Start up the Raspberry without it being connected to a screen.
  2. Connect the Raspberry with an internet cable to your router.
  3. On your Android phone, find and install the app Ping Tools
  4. Make sure your phone is connected on the wifi of the router. And make sure the Raspberry had some time to start up (1-2 minutes)
  5. Open the app, tap on the top blue bar that says Ping and select Subnet scanner in the dropdown menu.
  6. Click on the settings button (right next to the scan button).
  7. In the list of ports, add the number 22. This is the port that the Raspberry will have open.
  8. Then tap the scan button. Now your phone will try to look for other devices on the same network. This will take a while. If you see a device that has port 22 open, then that is most likely the iIP address of your Raspberry.
  9. Now you can remotely connect to the Raspberry using SSH (Secure Shell). For this you can either download Putty on a computer or use an Android SSH app.
    • On a Computer connected to the same network
      1. Download putty.exe and run it.
      2. Fill in the IP address of the Raspberry in the Hostname field. The port should be 22.
      3. Then click connect.
      4. The first time you will get an alert, click yes.
      5. As username type in pi and the password raspberry.
    • On an Android phone
      1. Download a SSH app, for example ConnectBot.
      2. You probably also need a keyboard that gives you more control, like the Hacker’s keyboard.
      3. Fill in pi@ where you replace the IP address with the address of your Raspberry.
      4. Type in raspberry as password.
  10. Now that we have a SSH connection to the Raspberry, we can do anything that you can do in a terminal window on the Raspberry.
  11. Type: cd ../../boot to get to the /boot/ directory.
  12. Type: sudo nano config.txt to open the config.txt file with ‘administrator’ rights. If you are asked for a password, write raspberry and press enter. (You will not see anything happening while typing in the password.)
  13. Move down to the line where it says: # NOOBS Auto-generated Settings:
  14. Put a # in front of hdmi_force_hotplug=1 to disable it.
  15. Press Ctrl+x to close the file, and press Enter to save it with the same name.
  16. Now you are done! You can open the file once more to see if the saving worked. (If it did not, you might have forgotten the sudo command.)
  17. Now you can restart the Raspberry with the RCA cable connected instead of the HDMI cable.

If it still does not work
Please note that if the HDMI cable is plugged in, the Raspberry will automatically switch to that as output. So make sure the RCA cable is connected before the Raspberry starts, and no HDMI cable is connected. If it still not works, feel free to ask your questions in the comments!

Print your own tools

Now that I am in the process of designing and copying things as 3D models I notice I really need to have a good ruler to figure out the sizes. Specially a caliper (Dutch: schuifmaat, Swedish: skjutmått) would be good. I know where to borrow one, but I should just get one for myself. This morning I asked myself, “Why would I buy one, if I could also print one?”. So instead of looking up the opening hours of the store I opened Tinkercad. A quick search only gave me parts of the tool, but they were good as inspiration.

Iteration 1
As usual it went surprisingly quick to create the model. Of course it helps that the design is simple and consists of basic geometric shapes. This close-up picture was also helpful for the details. When I was done I had modeled the entire tool (Link). But I wasn’t sure if it would fit together, look good, have the right scale etc. So then I took the model, cut out only the first part, and printed that out. In this way I could test the model without spending a lot of time and material.

Caliper test print 1
Caliper test print 1

Iteration 2
It turned out it was a good idea to do a test print. The scale of the ruler was correct, and the model looked quite good. A big issue though was that because of the big overhang there was a lot of support printed, which was hard to take away. In my second version I changed this to a small overhang, with an angle of 45 degrees (so it is supported by the lower layers and thus does not need support). I also added some room so the two pieces would be able to fit into each other. In my original model the inner part was exactly the same size as the empty space, which in real life would not work.

Caliper test print 2
Caliper test print 2

Iteration 3
The second printed turned out really well. The parts fitted together, and the tool seemed to work. Still I made some changes again. The extra space was reduced to 0.25mm on both sides, as the 0.5mm was more than what was needed. Also the height of the stripes of the scale was brought down to 1mm to make sure they would not break off. And I added numbers to the ruler, otherwise it would be kind of annoying to use. This time the model became a full size caliper again because I had faith that it would work.

Print 3 warped
Print 3 warped

Unfortunately now that I was printing the entire tool it took the printer too long to print one layer, which made the plastic cool down and curl up. I hoped that later layers would push it down and correct it, but no. This of course caused the parts to not fit together, so I was forced to cut it shorter.

Print 3 cut shorter
Print 3 cut shorter

In the end, the part that did come out straight fits very well, so I am rather pleased. It works as a tool to measure objects in millimeters. I think my next move will be to print this same model again using the Replicator 2x because it is enclosed and has a heated building plate, so it should not warp as much. I will also print the two parts separately to reduce the time it takes to print one layer. If I print it from ABS it will probably also warp less than the PLA I used today. (One idea which I am not going to test would be to try a faster printing speed.)

Link to the final model.

Lessons for today:

  • It is a good idea to try a small test print of the difficult parts of a big model.
  • The measurements in the software transfer correctly to the printer. (With this I mean the scale of the ruler was correct.)
  • 0.25mm on both sides of an object should be a good size to make it fit quite precise inside something else.
  • Reducing overhang can be very rewarding.
  • Try to prevent warping.

Is it broken? 3D print a new!

Our beloved but always overloaded laundry bag is held together by a string with a ‘clip’ (no idea what else to call it) on it. At least that is how it used to be, until it broke. Since I was going a bit nuts already with drawing things in Tinkercad, it was a perfect practice object.

The original broken rope clip
The original broken rope clip
The parts
The parts
The 3D model
The 3D model
Printed parts after removing the support material
Printed parts after removing the support material
They fit together
They fit together
It works!
It works!

Raspberry pi on-screen keyboard

Because I don’t have any usb keyboard at home, other than my big and bulky laptop stand, it is a bit of a challenge to type on a Raspberry Pi. I’ve even went as far as copying letters one by one with a mouse to type something.

But now that is solved thanks to this forum post where JeremyF and Paenny explain how to get an on-screen keyboard.

The summary:

  • type: sudo apt-get install matchbox-keyboard
  • type ‘y’ say yes to installing
  • create a new file on the Desktop called ‘’:
  • Then open a terminal and write:
    cd Desktop
    chmod +x
  • Now you can double click that file and execute it to start a big on-screen keyboard 🙂

PS: If you start the keyboard from a terminal, and then use that keyboard to type ctrl-c in that terminal your Raspberry will go nuts.

3D printed Leatherman wave extension v0.1

Last month I became the proud owner of a Leatherman Wave. Because the lanyard ring it has is too well hidden, I ended up on Youtube to figure out how to open it (The answer). There I also came across some cool mods for Leatherman tools, which inspired me to think beyond the tool as how it comes by default.

Quick-Release Lanyard Ring & Removable Pocket Clip
Quick-Release Lanyard Ring & Removable Pocket Clip

Two accessories that are available for the Wave (and other models) are the quick-release lanyard ring and removable pocket clip. Now I tried to re-create this as 3D model and print one myself with a 3D printer. The model is publicly available on Tinkercad.

In the first version the measurements were a bit guessed, so after printing some filing was needed to make it fit. Here are some pictures of the result:

Result straight after printing
Result straight after printing
After filing
After filing
It fits
It fits

It fits

The next step will be to update the model with better measurements, and improve its strength. Because so far it seems a bit too thin to hold much force. The idea is to later invent other tools with this form on it so they can be attached to the Leatherman.

To be continued…

Bikes in language

While the Dutch language uses bikes to show understanding:

“Oh, on that bike!” => “oh, in that way!”

Swedish thinks you are crazy:

“He is outside, biking.” => “He doesn’t know what he is talking about.”