The Raspberry Pi and [email protected] can communicate over both Serial and I2C, but Serial is used for the main inter-processor communication.
When the Raspberry Pi is active, it is the master on the I2C bus, and is responsible for setup of the Ardhat I2C peripherals (e.g. IMU, Altimeter, RTC). When the Raspberry Pi is inactive, the Arduino can master the bus and interrogate the peripherals. For example by watching the RTC, the Raspberry Pi can be started when the next crontab entry is about to come due.
However, access to regular Arduino-compatible ports such as Analog and PWM is performed over Serial using a standardised protocol layer, or Data Link layer in OSI parlance.
As an example, the factory image that ships with [email protected] contains a modified version of standard Arduino Firmata that adds several additional features, such as monitoring of the Navigation switch and Status LED control, using the Arduino SMlib. This state machine library provides an extremely lightweight mechanism that allows primitive multitasking.
In principle, an [email protected] host application can be written in any language that has a Firmata library, including Processing, Python, C++ and many more. However, in a Robotics or IoT environment, services are often distributed over a network whose availability cannot be guaranteed. A responsive system cannot block while waiting for these services to respond.
Johnny-Five is a great node library that sits on top of Firmata but provides some higher level functions to make use with node even easier. For example, [email protected] is unit tested using Mocha on Johnny-Five on Firmata.
Application-specific projects can also be created on top of Node using accessible app generators such as Node-Red.
Some of the key libraries are shown below:
|Mongodb||noSQL database , for example to keep track of authenticated users and nodes|
|Express||minimal node.js web application framework that provides a robust set of features for web and mobile applications|
|AngularJS||front-end application framework toolset for Single Page Applications|
|Firmata||node.js library to interact with local Arduino running the firmata protocol (currently limited to serial port only (use of node-i2c TBD))|
|pi-gpio||node.js based library to access the GPIO of the Raspberry Pi|
|socket.io||real-time bidirectional event-based network communication|
|mqtt||machine-to-machine (M2M)/“Internet of Things” connectivity protocol|
|mosquitto||message broker for mqtt, supports MQTT,MQTT-SN|
|ponte||node.js server bridges MQTT, CoAP|
|NeDB||lightweight MongoDB-like noSQL database for node.js|
|freeboard||local dashboard function|
|Node-Red||A visual tool for wiring the Internet of Things|
IoT System Model
The overall system model is as shown below.
The Arduino RealTime code is responsible for monitoring and handling system power, realtime events, and graceful sleep/shutdown/restart cycles of the Raspberry Pi. It is also responsible for transmitting application information to the Wireless Sensor Nodes, for example using a simplified MQTT (MQTT-SN) over a link layer protocol such as TinyHAN on top of the relevant PHY (eg RFM96).