IoT MEAN App (RESTful API server and Arduino101)

Overview:

The Arduino101 is a microcontroller board that is based off of the Intel Curie Module which includes the Intel Quark Microcontroller C1000. This board comes with a 6-axis accelerometer/gyrometer and also has built in Bluetooth low Energy (BLE). For this project, the Arduino101 is set up to collect acceleration and gyrometer data, and then advertise the data over BLE. A client device is setup to connect to the Arduino101 via bluetooth, read the advertised data, and then send that data over wifi to a server. The server stores the received data in a database and also forwards it to a webpage where the data is graphed and displayed for the user. From the webpage, a user can also control the Arduino101’s sampling frequency. With a click of a button, the user can send a new sampling time all the way back to the Arduino101. The change is instantaneous and can be visually seen on the webpage. The below diagram illustrates a general overview of this project.

a101_diagram
Flow Diagram of Overall Project

How it Works:

Arduino101:

Standard Arduino code along with the “CurieBLE” and “CurieIMU” libraries were used to write the code for the Arduino101 board. The board is set up as a peripheral with one service that contains seven characteristics. One characteristic is the sampling frequency (ts) which the user can write values to, and the other six are the acceleration/gyrometer values (ax, ay, az, gx, gy, gz). These service and characteristics are each assigned a UUID which is used by the client device to connect, subscribe, read, write, or receive notifications for a particular characteristic.

Client Device:

On my client device, Node.js along with Noble is used to search and connect to the Arduino101 over BLE. Once the client device finds the Arduino101, it looks under the assigned Service UUID for each Characteristic UUID. Notifications are then turned on for each characteristic, and Socket.io is used to forward the sampling frequency and accelerometer/gyrometer data to my server. One interesting point to note here is the use of Socket.io over WebSockets. The main reason why Socket.io is used over Websockets in this project is because of multiplexing. Socket.io’s API makes it quite easy to send multiple signals over one channel while doing this with Websockets is a little more complex.

Server / Webpage:

Node.js along with Express is used to set up my server and MongoDB is used as my database. Socket.io once again forwards the data from my server to my webpage, where the raw data values are displayed and graphed for the user. From the webpage, the user can also choose to change the sampling frequency of the Arduino101. These effects take place nearly instantaneously thanks to Socket.io and Noble. The user can also see this change visually on the webpage where the rate of the incoming data will either speed up or slow down based on the new sampling time chosen. The webpage was created using frameworks such as Bootstrap and Angularjs. Google Charts is used to graph the acceleration values in real time. The project is available on github and a demo is available on youtube.

Hardware:

Software/Modules/Frameworks:

References:

CurieBLE
Multiplexing using Websockets