Use the Rasp Pi to log data from bicycles and motorcyles

Data Transmission

The captured data lands in text files, which the Rasp Pi then makes available for analysis to another computer by means of a Lighttpd web server. One group used a smartphone as a mobile access point. The Raspberry Pi and a laptop were configured so that they connected automatically via DHCP with the WiFi network.

Another group used the Rasp Pi itself as a wireless access point. However, note that not all WiFi USB adapters support this function. Support capability can be tested via the /usr/sbin/iw list command. When * AP, for access point, appears in the output under Supported interface modes then the configuration will work.

Three additional steps completed the configuration.The first was to provide a static IP address for the WiFi device. This was done via an entry in /etc/network/interfaces (Listing 2). Then, they needed a DHCP server that could assign an IP address to other devices. For that purpose, they installed a resource-frugal udhcpd server (Listing 3, line 1).

Listing 2

Provide Static IP

iface wlan0 inet static
  address 192.168.0.1
  netmask 255.255.255.0

Listing 3

Install udhcpd and hostapd

$ sudo apt-get install udhcpd
$ sudo sh -c 'echo "interface wlan0" > /etc/udhcpd.conf'
$ sudo apt-get install hostapd

The software will almost run without any further configuration. All that remained was to set the DHCPD_ENABLED="no" line in /etc/default/udhcpd to "yes" and create a minimal configuration file (Listing 3, line 2). Udhcpd would then distribute IP addresses in the range between 192.168.0.20 and 192.168.0.254. If necessary, the settings could be modified further. In the project presented here, this was not necessary.

The final step was to install the hostapd software, which converts the WiFi device into an access point (Listing 3, line 3). In the /etc/default/hostapd file, the #DAEMON_CONF="" line was changed to DAEMON_CONF="/etc/hostapd.conf" to make sure the daemon would find its configuration file. Listing 4 shows an example configuration file.

Listing 4

Example Config File

# Minimal configuration for
# a network without encryption
interface=wlan0
ssid=<MySSID>
# Extensions for WPA2-PSK encryption
wpa=2
wpa_passphrase=<MyWPApassphrase>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Both daemons are started with the commands from the first two lines of Listing 5. Using another device such as a laptop, tablet, or mobile phone, the teams could check to see whether the daemons found and connected with the WiFi access point. If this worked, they used the commands in the last two lines to make the software start automatically once the Raspberry Pi was rebooted. (See the "Init Systems" box.)

Listing 5

Start Daemons on Boot

$ sudo service hostapd start
$ sudo service udhcpd start
$ sudo update-rc.d hostapd enable
$ sudo update-rc.d udhcpd enable

Init Systems

Raspbian Wheezy with SysVinit was used in this project. Jessie is the newest version of the operating system and it uses the systemd init system. This makes a difference when activating and starting services.

Another possibility would be to perform an analysis retroactively. This type of analysis could be done simply by putting the Rasp Pi SD card in the card reader of a laptop and reading the data directly. If this were done on a Windows PC, a FAT partition would be needed to exchange the data. On the other hand, when only a small amount of data is involved, the effort of repartitioning would be unneccesary, and the data could be saved in the /boot directory. This option works because, by default, the boot directory of a Raspberry Pi is located on a FAT partition.

Finally, it would also be possible to transmit the data over cable by providing both devices with a static IP address in the same network. Alternatively, by operating a DHCP server via the LAN interface on the Rasp Pi, the laptop would obtain its network address from there. The network card in the Raspberry Pi is sufficiently intelligent to recognize when it has been connected directly to another card, avoiding the need for a hub and crossover cable.

Analysis on a PC

The measurement data is read, stored in arrays, and evaluated for further processing and analysis by means of a C# program. This software displays values for the turning radius sensors and for the speed measurement data as data points on a chart. The program plots GPS data on maps with the use of an API made available by Google Maps. You can read more about this Google service in the "GPS Visualization with Google Maps" box.

GPS Visualization with Google Maps

Google allows users to visualize GPS data with the use of specially constructed URLs that generate an image. The project teams used this service to display the GPS data. The corresponding URL looked something like:

https://maps.googleapis.com/maps/api/staticmap?zoom=14&size=300x300&\
  maptype=roadmap&path=color:red|47.0700,15.4095|47.0700,15.4000|47.0730,15.4000

The parameters are fairly self explanatory. GPS coordinates are entered via the path= option, with the coordinates separated by pipe symbols (|). The service understands several other parameters and offers further possibilities [5]. To make complete use of the service, the user needs an API key. An API, or Application Programming Interface, key is a character string a program uses to identify itself to a server so it can use the corresponding services. The teams did not have to purchase a Google API keys for this project, because their data traffic fell under the usage limits.

If you are interested in competing services, you should check out Bing Maps [6]. However, you must purchase an API key to use it. The MapQuest Open Static Map Service [7] uses OpenStreetMap data with a free API key.

One of the groups reconstructed a calculated route in addition to the route displayed in Google Maps (Figure 5, upper left). The underlying idea was to recreate the route in the form of a coordinate system using the speed measurements and turning radii.

Figure 5: The program that analyzes the data can also deliver a graphical representation of the route using maps from Google Maps.

The software derived the route from the time between the measurement values. Additionally, the program analyzed the values of the potentiometer and boosted them somewhat to interpret and display curves correctly. This made it possible to recreate the route and plot it in a bitmap.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content