Bluetooth connections and pty/tty – HELP!!!

Hopefully someone’s reading this who can help me. I’ve posted it to the forum as well as I’m stumped!

I’ve got a very specific kind of problem to do with a Bluetooth keyboard.
Now, I’ve had the keyboard working fine before, and I believe I have it working now… except…
Okay, here’s what I do:

1. Start the Pi. It connects to my WiFi network automatically.
2. Run a remote ssh terminal (MobaXterm) and connect to it via IP.
3. Login.
Everything’s fine up to here.
4. Make sure the BT dongle is working in the Pi. It is.
5. Put the keyboard in discovery mode (light flashes).
6. hcitool scan. Find the MAC of my keyboard. All ok so far.
7. Use l2ping to make sure that I can actually get to the keyboard. still ok.
8. Run bluez-simple-agent hci0 DC:2C:26:D9:1A:BB
    This connects my dongle with my keyboard
9. bluez-test-input connect DC:2C:26:D9:1A:BB
    This connects my dongle with the keyboard SERVICE of the keyboard.
10. At which point the light on my keyboard goes steady. I know this is correct operation.

If I start typing on the keyboard, the orange transmit light flashes (which it doesn’t do if it’s not connected). However, nothing appears on the screen.
Now, I know that I’m on /dev/pty0 – which is a pseudo-terminal from my remote connection.
I suspect that the keyboard has connected to the terminal session that a screen connected to my Pi _would_ be showing if I had a screen plugged in.

So… the question is… How do I

a) Connect the bluetooth keyboard to the pty I’m already logged in on.
OR b) Change from the pty session to the ‘console’ session.

Any ideas?

The Pragmatic Bookshelf | Raspberry Pi

>The Pragmatic Bookshelf | Raspberry Pi:

Raspberry Pi: A Quick-Start Guide gives you everything you need to get the Raspberry Pi up and running and doing cool stuff. You’ll get started by learning what additional hardware you need and how to connect it, install Debian Linux and configure it to your needs, and customize the Pi’s firmware to get the most out of your hardware.

‘via Blog this’

Dynamic DNS – open up your Pi’s webserver to the World

I’ve installed Raspcontrol by Jacob Clark along with Apache and PHP. I did a guide for that in a previous post.

What I want to do now is to get the webserver running it open to the World.
I’m on a dynamic IP with my ISP (I think!) so I want a way of getting the Pi to use some kind Dynamic DNS  so I can refer to it by hostname.

I looked around for Dynamic DNS providers and found
Looking at, I can see they have an API that can be configured with ddclient, whatever that is. It’s got an obscure name, so it’s probably linux!

So first of all:

  • Go to and register.
  • Then, once you’ve validated using their registration email, add a new domain.
  • For the purposes of this tutorial, let’s go with


  • Start the Pi, login as root and then:
  • apt-get install ddclient

That installs and I automatically get an interface pop up on my screen:

So I choose other…

  • Asking me for the name of the provider server, so let’s put in
  • DNS Dynamic uses the dyndns2 protocol, so choose that.
  • Enter your username and password.
  • It now asks for the network interface to use. Now, I use Wifi, so I put in wlan0, but if you are using a cabled LAN connection, you’ll use eth0.
  • Now enter your domain –
  • At this point, ddclient will configure itself. At this point, I rather hope that it tells me what it does next!
  • Okay, so it installs more stuff…
  • Interesting… the installation completes and… tells me nothing…
  • Right, looking at the ddclient documentation it tells me where the configuration file is. Not quite right in the documentation – the config file is at /etc/ddclient.conf
  • Apparently, the way to run it automatically is to add the following to your /etc/rc.local:
    /usr/sbin/ddclient -daemon 300 -syslog
  • The ‘300’ is the number of seconds it should wait before checking to see if the IP address has changed. I think this is fine, even for my wifi connection with it’s customary 2 minute connection delay.
  • So, let’s try it!
You check your IP address by going to, logging in, going to “manage” and editing your existing domains.
If you are behind a router (and let’s face it, who isn’t!?) then this will (incorrectly) show your INTERNAL IP address. (Mine says for instance). We don’t want that, so I found a help page:
To fix:
  • Edit /etc/ddclient.conf (for example > nano /etc/ddclient.conf)
  • Change the line
    use=if, if=wlan0
    and add a # in front of it.
  • Add the line
  • Save and quit.

You  need to kill the current ddclient and restart it:

  • ps -ef | grep ddclient
  • Make a note of the process id (which is the first number on the left)
  • kill -9 <process id>
  • Then re-run ddclient by typing:
  • ddclient

This will run it in the background and update the IP address to your external ip.

Go back to and check your existing domains again. You should have your external IP address showing now. (I did).
You should now be able to: ping and get that same IP address back.
The next thing to do is to do a port forward on your router. There are various guides to do this. You will need to point port 80 (HTTP) of your router at your INTERNAL IP address, port 80, or however your router identifies the destination. (Assuming that’s the port your webserver is running on).
I managed to do this on my BT Home Hub without much trouble
Now, to test it. First of all you cannot just put your dynamic DNS hostname into your browser and expect it to work. I think it’s got something to do with looping back to yourself.
So, go to and type your into there. You should get your Pi’s homepage! Wahey!

Headless Raspberry Pi – Tell me my IP address!

What is my IP address and can you email it to me?
Instructions for getting your IP address emailed to you can be found on the RPi wiki
It works. Yay.

What is my IP address, and can you tell it to me?
This is to get the Pi to find it’s own IP address and tell you vocally over the 3.5mm audio jack.
First of all, you need to install Festival, which is the text-to-speech converter.


  • Install the Festival package
    • apt-get install festival
  • Install the alsa utilities/drivers if you do not already have them
    • apt-get install alsa-utils
  • Edit /etc/modules
    • Make sure that
      • snd_bcm2835
    • is in the file.
    • Once it is (it might be already) you do not need to do the modprobe again after each reboot.
  • Push audio to the 3.5mm jack
    • amixer cset numid=3 1
  • (If you want to put it back to automatic, or HDMI, change it to 0 (auto) or 2 (HDMI))

Test out your audio

  • Do the following:
    • su root
    • cd /opt/vc/src/hello_pi
    • ./
    • cd hello_audio
    • ./hello_audio.bin
  • You should hear something like a siren run through a bad 50s sci-fi tv show.
  • Let’s try testing ‘aplay’ to see if that works. Use one of the ‘alsa’ sample files.
    • aplay /usr/share/sounds/alsa/Front_Center.wav
  • Yes! It works. Dull, but it works.
  • Install mplayer:
    • apt-get install mplayer
  • Edit /etc/mplayer/mplayer.conf. Add the following line:
    • nolirc=yes
  • mplayer /usr/share/sounds/alsa/Front_Center.wav
  • Yes! Works!

Try out Festival

  • To make Festival say hello, try this:
    • echo “Hello” | festival –tts &
  • YES! It spoke to me!!! Woo-hoo!!!

The Script and running it

  • Return to your root folder:
    • cd /root
    • mkdir bin
    • cd bin
  • Create and edit a file called: and use this:
# First of all, see if you have an IP address yet
echo `hostname -I` > /tmp/check_ip.out
_CHECK_IP=`cat /tmp/check_ip.out`

# Find the length of the IP address
_LEN=`expr length $_CHECK_IP`

# Check the length of the IP address and make sure it’s sensible
if [ $_LEN -gt 3 ]; then
        # Construct your string to push to Festival
        echo “” > /tmp/shoutout.tmp
        echo “I am, a, Raspberry Pi. My I,P address is. ” >> /tmp/shoutout.tmp

        # This is so the IP address is said ‘nicely’
        for EACH in `hostname -I | grep -o -e “[^.]*”`; do
                for BIT in `echo $EACH | grep -o -e .`; do
                        echo $BIT >> /tmp/shoutout.tmp;
                        echo “. ” >> /tmp/shoutout.tmp;
                echo “dot. ” >> /tmp/shoutout.tmp;

        # And a bit of optional retro War Games!
        echo “. Would you like to play a game?” >> /tmp/shoutout.tmp
        cat /tmp/shoutout.tmp | festival –tts
        rm /tmp/shoutout.tmp
        rm /tmp/check_ip.out
        # If the IP address is not valid, report vocally and delayed re-run
        echo “I do not yet have an I,P address” | festival –tts
        sleep 5
        /root/bin/ 2&>/dev/null

(All those fullstops and commas space out the words so it sounds like an IP address!)
  • Save and quit.
  • Make the file executable:
    • chmod a+x
  • Edit /etc/rc.local
  • Add the following lines:
sudo -u root /root/bin/ &>/dev/null
  • And reboot
  • Don’t forget to have your earphones plugged in!