When we travel in a bus with other passengers for longer duration of time or say a long distance ride, it is obvious that you will be bored and interested in consuming media content but due to shortage of battery life on your mobile phone you may have to restrict your cellular data usage.
As we all know most of the smart phones these days run for longer duration on Wi-Fi than on cellular data for media consumption. The Raspberry Pi Zero W acting as a Wi-Fi Hotspot will run a server and hold the latest news, books, songs, videos etc on the local storage of the raspberry pi for offline access. The content on the raspberry pi zero w will be uploaded and managed by the administrator through cellular network access provided by Hologram Nova.
The passengers travelling on the vehicle can access the media content available on the Raspberry Pi Zero W by connecting to the Wi-Fi Hotspot. In this manner multiple users can connect to the Wi-Fi Hotspot and listen, watch or read different content of their choice which is available on the Raspberry Pi. Based on user ratings and suggestions, new set of media content can be updated by the administrator which will be accessible for the travelers in future. If there is data connection loss in between the travel at certain locations, there won't be any effect on the user experience as the media content is available locally on the Raspberry Pi. The passengers will have uninterrupted media consumption experience.
The GPS location data of the vehicle is also transmitted through the cellular network of Hologram Nova which is received at the data engine at the cloud server. This data helps other users who are waiting at the bus stops to track and get the ETA of the buses moving towards their bus stops.
Architecture:Prepare micro sd card for raspberry pi and login into raspberry pi via SSH.
There are lots of tutorials available online on how to do this, one such link has been mentioned below for your reference.
Ref. https://www.losant.com/blog/getting-started-with-the-raspberry-pi-zero-w-without-a-monitor
Step 2 - Using Mobaxterm software:Once you have setup the raspberry pi connected to your router and able to login via SSH. I suggest you to use the Mobaxterm software available at https://mobaxterm.mobatek.net to login via SSH as shown in the following screen shots. This will be helpful to upload files to the raspberry pi from our laptop through local SSH connection or through hologram.io space bridge which is shown in the demo video
Once you have logged in using using default username "pi" and default password "raspberry" or anything you have modified it to in Step 1. You can go ahead and make some configuration of the raspberry pi using the raspi-config command
Once you enter the configuration menu, you will see the screen as shown in the picture below
In this menu, we shall enter into advanced options to expand filesystem
using option to expand the sd card volume to be fully used to maximum capacity as shown in the screen shot below:
Next we shall use the interfacing options to enable serial interface
we shall not enable login shell of raspberry pi over serial because we will be using the serial port for getting GPS data
enable serial port hardware to receive serial data
Once you are done with the configuration you can finish the configuration
and reboot
Now we shall setup apache2 on raspberry pi using apt
sudo apt-get install apache2 -y
Once the installation of apache2 is completed you can check the local server by pointing at the ip address on the browser, you will see the default web page as shown in the screen shot below
Now in the mobaxterm sftp window, you can change directory to
cd /var/www/html
you can delete the index.html page which is already exists inside the /var/www/html directory and create a new directory inside it
in the name of songs
similarly create multiple directories that you want to serve on the server, like I have done for images, songs and video
you can double click on the folder to change directory again and then
upload files using the upload button, but before that execute the following command which will make the html folder writable
sudo chmod 777 /var/www/html
you can now select files and upload the files that you want to upload
you can see the uploaded files as shown in the screen shot below
repeat the same for videos and images that you want to put inside the media server
Once you are done with uploading the files to the server / raspberry pi, you can check the server again at the same url i.e. the ip address of the raspberry pi. Now you will be able to see the images, songs and videos available on the raspberry pi acting as server.
Install hologram CLI and python SDK using
curl -L hologram.io/python-install | bash
you can visit https://hologram.io/docs/guide and https://hologram.io/docs/ to get all necessary documentation get started up and running with hologram nova GSM modem with raspberry pi
once you have activated the sim card you can go ahead and edit the rc.local file
sudo nano /etc/rc.local
to connect hologram nova to network once you boot the device add the following line at the end of the /etc/rc.local file
sudo hologram network connect
To interface GPS receiver, you can connect the GPS receiver to Raspberry Pi as shown in the picture below:
Create a python file to read GPS data from GPS receiver over serial and upload it to hologram.io cloud. For your reference, the GPS.py file is available in the code section which you can use to do this. You just have to change the device key to your device key that you can get from hologram.io dashboard
Now you can go ahead and add the line
sudo python /home/pi/GPS.py
to the /etc/rc.local file to run this python file when raspberry pi boots up
Now, once you turn on your raspberry pi with the GPS receiver and hologram nova modem connected to it, it will start uploading the GPS data to the hologram.io cloud server as messages on the particular topic that you have used in the code, in my code I have used GPSDATA as topic name
Step 7 - Setting up Raspberry Pi as Wi-Fi access point:Now that we have the required setup, we can go ahead and setup the raspberry pi to act as a Wi-Fi access point / hotspot
This step is based on the documentation available at
https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md
I suggest you to take a look at the URL to understand the process in detail with comparison to the screen shots given below
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install dnsmasq hostapd
To configure the static IP address, edit the dhcpcd configuration file with:
sudo nano /etc/dhcpcd.conf
Go to the end of the file and edit it so that it looks like the following:
interface wlan0
static ip_address=10.0.0.1/24
Configuring the DHCP server (dnsmasq)
The DHCP service is provided by dnsmasq. By default, the configuration file contains a lot of information that is not needed, and it is easier to start from scratch. Rename this configuration file, and edit a new one:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf
Type or copy the following information into the dnsmasq configuration file and save it:
interface=wlan0 # Use the require wireless interface - usually wlan0
dhcp-range=10.0.0.1,10.0.0.255,255.255.255.0,24h
Configuring the access point host software (hostapd)
You need to edit the hostapd configuration file, located at /etc/hostapd/hostapd.conf, to add the various parameters for your wireless network. After initial install, this will be a new/empty file.
sudo nano /etc/hostapd/hostapd.conf
Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of MediaSpot, and a password 12345678. Note that the name and password should not have quotes around them.
interface=wlan0
driver=nl80211
ssid=MediaSpot
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
We now need to tell the system where to find this configuration file.
sudo nano /etc/default/hostapd
Find the line with #DAEMON_CONF, and replace it with this:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Now that you have configured the raspberry pi act as access point, you can go ahead and use it as media access point server as shown in the demo video.
Step 8 - NodeJs Maps Server:To create the map server on which you can see the live tracking of GPS data, you can use the app.js and index.html file available on the code section of this project.
Make sure you install all required node modules that are mentioned in the app.js file to get the server running.
Once you have the server running and hosted on any platform like AWS or heroku you can use the URL that you get in the hologram.io advanced webhook to redirect the messages you receive to hologram cloud from the device to the maps server
Step 9 - Hologram Advanced Webhook:You can create a webhook to redirect the messages to custom URL / maps server at the routes section of the hologram.io dashboard
The screen shot above shows the created route, you can click on new route and create a new one as shown in the picture below where you need to enter the topic whose message you would like to decode and use in triggering the maps server
You can watch in the console whether the data that you receive triggers the maps server successfully or not as shown in the screen shot below
Now that you have everything working as expected, to update data from remote location you can make use of space bridge service provided by the hologram.io
You can refer the links https://hologram.io/hologram-spacebridge-tunnel-sims and https://hologram.io/docs/guide/cloud/spacebridge-tunnel to use the service. I have given the demo usage of this in the demo video that is shown in this project.
With this last step we come to the end of this tutorial, with all these 10 steps, I guess the project can be replicated to achieve what was shown in the demo video. If you have any queries, you may comment below in the comments section.
Comments