Senior Capstone Project for an IoT device
Here is the overall schematic for our system (v0.1)
The specific Raspberry Pi Zero being used can be found for sale here: https://rb.gy/mcofca
Raspbian Jesse was used on our Pi, and can be downloaded here: http://downloads.raspberrypi.org/raspbian/images/raspbian-2020-02-14/2020-02-13-raspbian-buster.zip
Now, do sudo apt-get update
to update the OS's dependencies. Then do sudo reboot
For easy access to the Pi, ssh is also setup. In order to setup ssh, complete the following:
sudo raspi-config
Select Interfacing Options
Now the Raspberry Pi should be able to accept ssh connections. In order to enable SSH, follow these steps:
sudo systemctl enable ssh
sudo systemctl start ssh
Dependency Installation:
sudo apt-get install clang
sudo pip install gps
sudo pip3 install gps
First, connect the audio breakout board, speaker, and microphone as indicated in the schematic
Secondly, we need to edit some config files in the pi before it is able to output audio through the speaker
using your favorite editor open the file /boot/config.txt
sudo vim /boot/config/txt
edit/add the following lines
#dtparam=audio=on dtoverlay=hifiberry-dac dtoverlay=i2s-mmap
Next, we want to add a new file /etc/asound.conf
sudo vim /etc/asound.conf
and we want to add the following lines:
`pcm.hifiberry { type hw card 0 }
pcm.!default { type plug slave.pcm "dmixer" }
pcm.dmixer { type dmix ipc_key 1024 slave{ pcm "hifiberry" channels 2 } }`
Prerequisites
rpi-update
This process may take up to 30 minutessudo reboot
to reboot the Raspberri PiNext, we will install some dependencies to be able to interact with the GPS module:
sudo apt-get install gpsd
sudo apt-get install gpsd-clients
Then, we need to enable the serial ports on the Raspberry Pi. With the GPS module plugged in, execute the following command:
sudo raspi-config
Select Interfacing Options, then Serial
Select Finish, then type in sudo reboot
to reboot the Raspberry Pi.
Interfacing with GPS Module
Now we can begin interfacing with the GPS Module, and viewing the data it is recieving. Since we are using a Raspberry Pi Zero W, we will be interfacing with the /dev/ttyS0
. Other articles mention using /dev/ttyAMA0
, however this is only on Raspberry Pi's 1 & 2.
cat /dev/serial0
sudo systemctl disable gpsd.socket
Please NOTE: The following command MUST be executed everytime the Raspberry Pi is restarted
sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock
Now the GPS Module should be outputting its data to the Pi. In order to view the data, execute this command:
sudo gpsmon /dev/ttyS0
Prerequisites
pip3 install RPi.GPIO
pip3 install mpu6050-raspberrypi
With this, the dependencies have been installed.
Check all connections are in place. After running the pedometer/step_counter.py
, we get the current temperature and steps taken as output.
Prerequisites
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install bluetooth blueman bluez
sudo reboot
We'll need the Python Library for Bluetooth communication to allow us to send and recieve data
sudo apt-get install python-bluetooth
and we also need the GPIO Library:
sudo apt-get install python-rpi.gpio
Rather than relying on a bluetooth connection to interact with the Raspberry Pi using the Android App, the Raspberry Pi will instead send information to a database that the app can then access.
sudo dphys-swapfile swapoff
sudo nano /etc/dphys-swapfile
#modify the variable CONF_SWAPSIZE to 1024:
CONF_SWAPSIZE=1024
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
sudo reboot
For RethinkDB, a secondary Raspberry Pi is setup to be used as the 'server' that stores the information, while the Rasberry Pi Zero with the modules connected to it will act like the 'client' that is sending the data out.
The following steps were used on BOTH Raspberry Pi's.
sudo apt-get install g++ protobuf-compiler libprotobuf-dev libboost-dev curl m4 wget clang
#At this point make sure you check to see that 2.0.4 is still the most recent version of RethinkDB! http://rethinkdb.com
wget https://download.rethinkdb.com/repository/raw/dist/rethinkdb-2.4.1.tgz
tar xf rethinkdb-latest.tgz
rm rethinkdb-latest.tgz
cd rethinkdb-*
./configure --with-system-malloc --allow-fetch
make
#Export the proper C++ flags for Raspberry Pi 1/2
export CXXFLAGS="-mfpu=neon-vfpv4 -mcpu=native -march=native -mfloat-abi=hard" | make -j3 ALLOW_WARNINGS=1
sudo make install
Now that RethinkDB is installed, we need to ensure that RethinkDB starts correctly when using it.
In order to do this, sudo nano /etc/rc.local
and modify it to look like the following:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
_IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi
rethinkdb --bind all --server-name rbpi_rethinkdb -d /home/pi --daemon
exit 0
* Now, to start the 'server' Raspberry Pi, please enter the following command:
`rethinkdb --bind all`
# Installing MongoDB Python Module to Raspberry Pi
To download the python module to use MongoDB on the Client Raspberry Pi, please use the following command:
`sudo pip3 install pymongo`
`sudo pip3 install dnspython`