Sensor

The sensor is made from an Arduino Nano, a Bluetooth transceiver and a Sensor and uses a Terminal board to avoid soldering

12752089_570104773149188_937992805_o

The connections as as:

Bluetooth:

  • VCC -> 5v
  • GND -> GND
  • TX -> RX
  • RX -> TX

Sensor:

  • VCC -> 5V
  • GND -> GND
  • Output -> A2

The Sketch for this device is simple:

Arduino

The Bluetooth module is simply handled by the MIT Amarino toolkit. Inside the loop function, the sensor  data is being sent very second.

 

Making the Server itself!

As stated previous, the server is programmed in NodeJS. So I have my a directory in my home directory called HealthServer:

  • mkdir ~/HealthServer

Inside here, I’ve installed the required libraries:

  1. sudo apt-get install npm
  2. npm install bson
  3. npm install express
  4. npm install mongodb

This will create a directory called node_modules with the following directories inside:

  • bson
  • express
  • mongodb

Courtesy of Christophe Coenraets, we can make the following paths for the NodeJS server:

  • We can see, the initial server allows us to do the following:
    • Find all patients (I’ve added one in manually to MongoDB)
    • Find a specific patient
    • Find all pulse readings for a specific patient
    • Add a pulse reading for a specific patient

nodePaths

As well as making the following connection to the database:

health.js

And defining the GET and POST functions:

Health.js.2

Server Side

The server will be based upon the RESTFul architecture and use a MEAN (MongoDB, Express, Angular, NodeJS) stack for it’s programming. This is because it’s quick and easy to setup!

Operating System:

For the OS, I used Raspbian Jessie Lite, simply because it’s the most supported OS for the Raspberry Pi. In addition, the Lite means that it doesn’t come with “bloatware” and will allow me to be up and running as soon as the SD card image is deployed. A link to Raspbian Jessie Lite is: https://downloads.raspberrypi.org/raspbian_lite_latest

Node JS:

The installation for this is simple, run the following line:

sudo apt-get install nodejs

MongoDB:

MongoDB is a bit harder to install on Raspbian than NodeJS. So use the following instructions (taken from: http://www.widriksson.com/install-mongodb-raspberrypi/) :

  1. wget http://www.widriksson.com/wp-content/uploads/2014/02/mongodb-rpi_20140207.zip
  2. sudo passwd (change the SU password)
  3. su
  4. adduser –firstuid 100 –ingroup nogroup –shell /etc/false –disabled-password –gecos “” –no-create-home mongodb
  5. cp -R mongodb-rpi/mongo /opt
  6. chmod +x /opt/mongo/bin/*
  7. mkdir /var/log/mongodb
  8. chown mongodb:nogroup /var/log/mongodb
  9. mkdir /var/lib/mongodb
  10. chown mongodb:nogroup /var/lib/mongodb
  11. cp mongodb-rpi/debian/init.d /etc/init.d/mongod
  12. cp mongodb-rpi/debian/mongodb.conf /etc/
  13. ln -s /opt/mongo/bin/mongod /usr/bin/mongod
  14. chmod u+x /etc/init.d/mongod
  15. update-rc.d mongod defaults
  16. /etc/init.d/mongod start

To make my life easier, I’ve added the following two lines to my .bashrc

  • sudo /etc/init.d/mongod start
  • export PATH=”/opt/mongo/bin:$PATH”

mongorpi

 

 

Architecture

BasicDiagram

This is the basic architecture of the system:

We have a sensor which is gaining “vitals” data, such as a pulse reading and sends this to a smartphone using Bluetooth.

From here the Smartphone will send the data to the Server vis a POST request.

The Raspberry Pi will use a RESTFul server(see https://en.wikipedia.org/wiki/Representational_state_transfer) and will store the data sent by the phone.

From here, physicians can easily access the data on the server through the RESTFul APIs