Today I will talk about you how the Internet of Things can be used in the travel sector, and I will show you how to track a bag using a device that is smart and connected using cellular networks.
Despite the fact that only 1% of the bags are lost in airline travel, it’s a constant source of stress for passengers, and waiting at the baggage claim wondering if the bag got on the plane can be very frustrating. Therefore I will show you how a device can be put in a bag and report its position, which can then be used for analytics and mapping, and I will use the ThingSpeak cloud to show the bag on a map.
I will use a board called FONA from Adafruit (e.g. www.adafruit.com/product/1946), and it’s a complete GSM module that can be controlled by a microcontroller like an Arduino (either 3.3V or 5V). You also need a SIM card, a battery (e.g. www.adafruit.com/products/1578), and an antenna (e.g. www.adafruit.com/products/1859 and www.adafruit.com/products/851). To connect everything, you need a breadboard, and 4 jumper wires.
To setup the hardware, you start by disconnecting everything from its power source, and then connect the Arduino VCC to the GSM module’s Vio (that set the I/O pin voltage level). Connect the Arduino GND to the GSM GND, and then connect Arduino pin 2 to the GSM transmit (TX) pin, and the Arduino pin 3 to the GSM receive (RX) pin.
You find the Arduino code on http://cforsberg.com/?p=254 to get the current location using GSM positioning and send it over GPRS to the server. After the initial include of the software serial library (on line 1), a variable is created for it (on line 2). In the setup, the software serial communication is initiated (on line 6), then the APN for my operator is configured (on line 7, e.g. for T-Mobile in the US, use epc.tmobile.com), and the GPRS connection is opened (on line 9). The eternal loop starts by querying the current position (on line 15), wait for a reply (on line 16), and get the position values (on lines 17-18, using the function on lines 29-43). Then a HTTP connection is initiated (on line 19), the URL is set (on line 21), and the request is made (on line 23). Finally, the HTTP connection is terminated (on line 25), and then I wait so that the position is reported once a minute.
You sign up for a ThingSpeak account (on https://thingspeak.com), and create a new channel, to get the API key for writing that you need to insert into the code. You can get the raw position data on the channel page, but if you want to see the position on a map, you can create a new plugin with the code on http://cforsberg.com/?p=254. I won’t go through it in detail, but it basically queries the channel for the last reported position, and then shows it on a map provided by Google. Here you can see how it looks on my channel, and note that ThingSpeak is open source (https://github.com/iobridge/thingspeak), so you could also set it up on your own server.
In a real world scenario, it would probably be a good idea to add an accelerometer to the device, so that it would sense when the plane accelerates and breaks and use that to stop and start the reporting of its position. This will also allow for a much more energy efficient solution as the GSM device can be turned off and the Arduino put to sleep. More on that in upcoming videos.
That’s how the Internet of Things can be used in the transportation sector.