Simple telemetry app based on arduino and Raspberry Pi.
git clone https://github.com/exelban/telemetry
I use Python 3.5 so you must to compile this version (or you can change code for oldest version of python).
Copy file raspberry.py
to your raspberry Pi.
You must to find on what port connected arduino and GPS module.
In Raspberry Pi 2 dafault RX/TX port is /dev/ttyAMA0
. But also you must to make some changes in system files (See here).
When you find port just change there in raspberry.py:
GPS_port = '/dev/ttyAMA0'
arduino_port = '/dev/ttyUSB1'
If you dont use GPS, just leave GPS_port
empty.
For compile arduino code you must to download and install SimpleTimer Library, because we use it for speed calculation.
If you connected sensors to different port on arduino just change it in arduino.ino
.
Next upload file arduino.ino
to you arduino board.
I recommend to install Arduino IDE to raspberry Pi. You can do it by print apt install arduino
in terminal.
Dont worry if you have different sensors or use your own arduino code. Script on Raspberry Pi justt add all received data from adruino to final array.
After you connected all sensors to arduino board and arduino board to raspberry Pi you can run python3 raspberry.py
on your raspberry Pi.
It means that script can not connect to arduino on this port. Probably you forget to change arduino port. If you your arduino connect to write port, but message still appear, plese create issue.
It means that script can not connect to GPS module on this port. Probably you forget to change GPS module port. If you your GPS module connect to write port, but message still appear, plese create issue.
This error can appear if your GPS module use other baud rate (not 9600). Please check your GPS module boud rate and just change GPS boud rate on line 24:
self.gps_module = serial.Serial(GPS_port, 9600)
Default data format is [adruino, [gps], time]
.
If you dont have GPS module data format will be [adruino, time]
.
Script split (","
) received string from arduino.
Script collect next data from GPS:
- Latitude (lat);
- Longitude (lon);
- Speed based on changing latitude and longitude (V1);
- Speed from GPS module (V2);
- Number of satellites (s);
- Altitude (alt).
Data format: [lat, lon, V1, V2, s, alt]
You can remove some parameters if you dont need on line 111:
return [self.lat, self.lon, self.speed, self.speed_gps, self.satelites, self.altitude]
Time format: H:M:S:MS
.
You can change time format if you need on line 132:
date = datetime.datetime.now().strftime("%H:%M:%S:%f")
['35', '31', '0', '-2.33', '49.63', '0.00', [52.2297700, 21.0117800, 0.00, 0.00, 7, 137], '17:22:53:208957']
[ arduino , [. lat. , lon. , V1 , V2 , s, alt], TIME ]