Wednesday, February 25, 2015

Real-time locating system (RTLS) with BeSpoon,MatLab,RaspberryPi,433Mhz sensor and switch

This is a big project I am working with at my work which makes me write a nice tutorial about it. I will go through step by step process. I will also try to introduce all the technology which I am using in this project.

-BeSpoon phone and tags (http://bespoon.com/)
-MatLab 2013a
-RaspberryPi model B (http://www.raspberrypi.org/products/model-b/)
-433Mhz sender, receiver and switch
-Distance leaser sensor DISTO D210
- Light(I am using 3 light for this project)
-USB hub
-RJ45 cable
-Router
-2.1A power supply
-HDMI cable(optional)
-Monitor(optional)

Distance leaser sensor:
To get the real distance or to make the right coordinate system, I used Disto leaser sensor. This will give me accurate distance in Meter.

BeSpoon:
BeSpoon phone using Android 4.0.0 and I wrote the program which will read tags distance and save it to MySQL. I used 3 anchors to map the area for the localization. After determine where will be my sensors location, I put them with glue. Finding out my 0,0 (x,y) by using leaser sensor, I put BeSpoon mobile and get all anchors position and save it to the database or temporary write that down in a paper.

So now I have two different distance value. One is the "real" value which I got from leaser sensor and second is "approximate" from BeSpoon anchors. For BeSpoon each sensor, I collect 150 data and use min function in MatLab and find out the average value.

MatLab:

MatLab will read all three tags distance from MySQL and by using AX=B it will calculate triangulation and find the phone's position. All my lights position (x,y) is known so depending on phone's position, MatLab will makes the decision which light will turn ON or OFF. After  making the decision, MatLab writing switch number in a local file(output.txt).

RaspberryPi:

I am using C++ in RaspberryPi which will SSH and read the file(MatLab output.txt) and deploy those switch turn ON or OFF by using 433Mhz hardware.

Here is some picture:
RaspberryPi connect with network and 433Mhz Receiver+Transfer

BeSpoon mobile and anchors
Distance leaser sensor



-433Mhz Receiver and Transfer is very cheap on ebay. Just search for it, you will find very cheap.

More details will add later...

RaspberryPi wicd-curses without WiFi

RPi without wicd-curses:
nano /etc/network/interfaces
---------------------------------------------------------
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.con$

----------------------------------------------------------
save and exit by pressing ctrl+x

nano /etc/wpa_supplicant/wpa_supplicant.conf
----------------------------------------------------------------
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="yourNetworkName"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="yourNetworkPassword"
}
--------------------------------------------------------
save and exit by pressing ctrl+x
restarts all the networks services :
  • /etc/init.d/networking restart
  • or
  • ifconfig wlan0 down
    ifconfig wlan0 up