Wednesday, December 22, 2010

ProximitySPOT / Sniffing Crawly

Yesterday I wanted to implement a proximity checker for my SunSPOT devices. I wanted to use the radio to determine the distance between two SPOTs. Well, as it happens from time to time, halfway through your implementation you stumble across some source code or library and you realize that someone already implemented it. In this case it was already on my harddrive because the SunSPOT SDK provides demos. One of those demos was to show the signal strength of a SPOT. Since there already was some nice code and an easy method to get the signal strength, I decided to modify my LEGO-Bot. His name is Crawly, as the title already implies. After giving it a name, it was even harder to take his head off. To make things right with Crawly I gave him something close to a sense of smell. Now he can move towards a signal source and stops if he is close enough.

This can be done in the following way. One SPOT can broadcast packets of data continously, while another one receives them and checks the signal strength while doing that. When reducing the distance between both SPOTs, the signal strength gets higher.

The SPOT mounted on Crawly broadcasts continously. The basestation you can see lying on the ground receives the signal and evaluates the strength of the signal. It is then compared with the last signal which was received. If the new signal strength value is higher than the last one, Crawly is on the right track and a command to move the servos forward is sent via bluetooth to crawly. If the signal strength gets lower, a command is sent to move left.

As you can see this is not a great pathfinding algorithm, but well I'm not a mathematician and this was just a little proof of concept experiment. So Crawly finds his way to the basestation by circling towards it.