Talking to a headless Turtle

So how do you talk to a headless turtle?

That’s the problem I wanted to solve.  A “headless” RPi had no screen, keyboard or mouse, meaning the only way of talking to it is over the wireless network I have here (as do most people with an internet connection).  The way I want to ultimately achieve is to connect the Turtle to SupeRpi with a dedicated TCP connection using Python on the SupeRPi to take commands from its keyboard, and pass them to the Turtle for it to carry out.  By commands, I mean “forward 10”, “rotate clockwise 90”, or “reverse 20”.

TCP connections are set up between a unique pair of IP addresses.  Each network card has it’s own unique one.  In my RPis, each has only one for the wireless link – SupeRPi is 192.168.1.66, and the Turtle is 192.168.1.67.  These addresses aren’t (in my case, yet) configured on the RPi – the RPi learns them over the wireless network from the dhcp server.  This runs (d)ynamic (h)ost (c)onfiguration (p)rotocol which assigns IP addresses to each network device it hears from on the network.  It is possible to ensure the dhcp server assigns the same device each time it starts up, but in my case, that’s not necessary as mine tries to assign the same IP address to each network device across each time it reboots.

So how do you find out the IP address for your device?  I ran “ifconfig” which lists all network interfaces, and shows their IP addresses amongst other stuff).  Having found the 2 addresses, I check they can talk to each other by using “ping”.  Typing ping from the SupeRPi (192.168.1.66)  to Turtle (192.168.1.67) like this “ping 192.168.1.67” tries to find 192.168.1.67 every few seconds, printing the results on screen.

So now I have IP addresses, and proof they talk to each other, the next step is to be able to send Turtle commands from SupeRpi.  As I said previously, I am going to do this with more Python code, but first I remembered a quicker way: “rlogin”.

From SupeRPi, I can type “rlogin 192.168.1.67” and after typing the password for the Turtle, the screen actually acts as though it’s on the Turtle, so typing “sudo python turtle.py” from the SupeRPi rlogin screen sets the Turtle running (well crawling actually, but…).

So the next step has changed.  I need to guillotine the Turtle (no harm was made to any animals), and then I can get back to the electronics of powering the Turtle without the mains – well within the bounds of a Lithium Ion battery, but outside of this months pay-packet.  Lucky payday is imminent so I hope my next post will be less wordy, and more interesting.  Until then…