Raspberry PI: Transmitting Telemetry via UHF
Equipment used:
- UBlox Neo 6M GPS
- NTX2 UHF transmitter
- Raspberry Model B
GPS
The GPS uses 3.3V so connect the GPS to the appropriate GPIO pins for 3.3V working
Install the GPS software
#apt-get install gpsd gpsd-clients python-gps
Then edit /boot/cmdline.txt
ammend the "ttyAMA0" parameter to read
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
edit /etc/inittab
comment (add a hash #) the line below "#Spawn a getty on Raspberry Pi serial line" like this:
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
edit /boot/config.txt
insert to set the baud rate for the neo 6M to 9600bps
init_uart_baud=9600
edit /etc/default/gpsd:
and change the DEVICES to indicate "/dev/ttyAMA0"
Reboot and test the gps data. You can test the rx data with minicom :
#minicom -b 9600 -o -D /dev/ttyAMA0
you should see a stream of gps info
Run gpsd
# gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock
and you can check the incoming data with cgps -s
UHF transmission
Run gprx on the mac to receive the 434 Mhz uhf signal and dl-fdigi to decode the audio that is being sent with the carrier.
Set the serial port to the correct settings:
# stty 50 cs7 cstopb < /dev/ttyAMA0
I run a quick cycled message to see if I can pick up the message via audio.
# while x=1; do echo Hello Out There > /dev/ttyAMA0; sleep 2; done
I pulled up quick script (be careful I said it was quick)
#!/usr/bin/python
import os
import serial
import time
import crcmod
x_list = []
y_list = []
def send(data):
NTX2 = serial.Serial('/dev/ttyAMA0', 50, serial.SEVENBITS, serial.PARITY_NONE, serial.STOPBITS_TWO)
NTX2.flush()
NTX2.write(data)
print "sent "+ data
NTX2.close()
while True:
gps = serial.Serial('/dev/ttyAMA0',9600, timeout=2)
line = gps.readline()
if 'GPGGA' not in line:
continue
#gps.flush()
gps.close()
time.sleep(0.5)
print line
fields = line.split(',')
utc = fields[1]
lat = (fields[2])
N = fields[3]
lon = fields[4]
E = fields[5]
FS = int(fields[6])
NoSV = fields[7]
HDOP = fields[8]
msl = fields[9]
uMsl = fields[10]
Altref = fields[11]
uSep = fields[12]
DiffAge = fields[13]
DiffStation = fields[14]
if FS == 0:
print "not synched"
continue
utc = float(utc)
t = "%06i" % utc
h = t[0:2]
m = t[2:4]
s = t[4:6]
utc = str(str(h) + ":" + str(m) + ":" + str(s))
y = int(lat[:2]) + float(lat[2:]) / 60.
y = "%02.2f" % y
if N == 'S':
y = -y
x = int(lon[:3]) + float(lon[3:]) / 60.
x = "%02.2f" % x
if E == 'W':
x = -x
print FS, x, y, NoSV, msl, DiffStation
string = "DATA " + str(NoSV) + ',' + utc + ',' + str(x) + ',' + str(y) + ',' + str(msl) + "\n"
send(string)
References:
http://ukhas.org.uk/guides:raspberrypi
http://diydrones.com/profiles/blogs/how-to-connect-3dr-gps-ublox-to-raspberry-pi
http://www.danmandle.com/blog/getting-gpsd-to-work-with-python/
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=41&t=53012
http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html
http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29
https://pypi.python.org/pypi/crcmod
https://github.com/ibanezmatt13/NORB