5. MetaHub

_images/metahub1.jpg

The MetaHub is a linux based WiFi to BLE bridge that allows anyone to connect and retrieve data from multiple MetaSensors at once. The Metahub is programmable and comes with a plug-n-play configuration file. This is a great way to connect sensors without the need for a smartphone, tablet, or computer.

The MetaHub can be mounted on the wall and when part of a building infrastructure such as a hospital, it can locate nurses, patients, and doctors.

The MetaHub can graph sensor data live on screen, store sensor data locally, or push sensor data to the Cloud.

5.1. Hardware

The MetaHub is built on the Raspberry Pi 3 Model B and Raspberry Pi 3 Model B+ platform:

  • Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
  • 1GB LPDDR2 SDRAM
  • 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE
  • Gigabit Ethernet over USB 2.0 (maximum throughput 300 Mbps)
  • Extended 40-pin GPIO header
  • Full-size HDMI
  • 4 USB 2.0 ports
  • 4-pole stereo output and composite video port
  • Micro SD port for loading your operating system and storing data
  • 5V/2.5A DC power input

The MetaHub comes with a 5V 2.5Amps power supply, a 8/16/32GB MicroSD card (Sandisk or similar), and a plastic case with screws.

You can add a Bluetooth to USB Dongle to each port to connect to more MetaSensors. Each Dongle connects up to 7 additional sensors yielding at least 20 simultaneous MetaSensor connections on the MetaHub. This will require experience in programming.

Bluetooth dongles also add Bluetooth range; they perform better than the internal antenna. Two Bluetooth dongles are provided with the MetaHub bundle.

5.2. Software

The MetaHub runs Raspbian OS and comes pre-loaded with our APIs and configuration files.

Raspbian comes pre-installed with plenty of software for programming and general use. It has Python, Java, editors and more. Junk such as games and Scratch have been removed.

The configuration file means programming is optional but we recommend that only experienced coders use the MetaHub.

Warning

The MetaHub runs Raspbian out of the box and is loaded with NodeJS and Python code to get you started. You will need to write code to use the MetaHub and therefore you should feel comfortable writing Python and Javascript code.

Note

While we have done our best to make it accessible for everyone, you should be comfortable with basic Linux commands and working with terminals. You can learn more in the Raspberry Pi website.

5.3. Getting Started

5.3.1. Power your Hub

_images/metahub2.jpg

To get started, setup your RaspberryPi like a computer:

  1. Connect a LED/LCD screen via the HDMI port.

  2. Connect a keyboard and mouse to the USB ports.

  3. Optionally connect a Bluetooth dongle to the USB port if you have one.

  4. Connect the MetaHub to power using the power supply (AC to micro USB). The MetaHub will boot automatically.

  5. Login to the MetaHub using the following credentials:

    >>> Login: pi
    >>> Password: raspberry
    
  6. Connect the MetaHub to the internet.

_images/metahub_pi0.png

The quickest way to get your MetaHub connected is to use an Ethernet cable and just plug it into the back of your router/switch. As soon as you plug your cable in, you should see the network LEDs start to flicker.

To connect to WiFi networks, look for the wifi icon at the top right hand corner of the UI. You should see any broadcasting signals nearby. Enter your password and you should be connected.

Warning

If nothing works, you can connect the RaspberryPi to the WiFi using the commandline. Follow the instructions here.

  1. The MetaHub comes preloaded with the following to get you started:

    • NodeJS/Javascript
    • Python
    • Configuration files

5.3.2. Setup your Hub

Once logged in, you will see a Desktop. There is a MetaBase app icon preloaded on the Raspian desktop.

_images/metahub_pi1.png

The easiest way to connect to a MetaSensor device from the hub is to configure the settings file.

_images/metahub_pi2.png

Open the “metabase-config.json” file on your desktop by right clicking it and using the “Text Editor”. You will see some configuration options that must be set before you can use MetaBase. Find the line that allows you set your MAC address. It should look something like this:

>>> MAC=E2:C3:6D:33:73:6F

Change the MAC address to the MAC address of the MetaWear you want to connect to.

Save the file. Now you are ready to run MetaBase.

5.3.3. Running MetaBase

To run MetaBase, simply double-click the MetaBase App icon on the desktop.

_images/MetaBase_pi4.jpg

If you entered your MAC address correctly, the MetaBase app should successfully connect to your MetaWear and start streaming data at the default rates.

_images/MetaBase_pi2.jpg

Follow the instructions on the screen to terminate the session.

_images/metahub_pi3.png

5.3.4. Data and Logs

Once you terminate your MetaBase session, all the logs can be found in the directory on the Desktop as shown below. The number of logs you will have and how frequent they log data will depend on your configuration file.

_images/metahub_pi4.png

5.3.5. Additional Configuration

Additional configuration instructions can be found in the README on the Desktop. Follow the instructions and change the configuration file as needed.

_images/metahub_pi5.png

Don’t forget, if you use stream mode, the MetaSensor will continue to send sensor data to the MetaHub until you fully reset the device and terminate the session.

If you use log mode, first you must set the sensor to log. Then, when you are done, update the configuration file to download the data as per below:

_images/metahub_pi6.png

5.4. Developers

5.4.1. Command Line Instructions

If you want to run MetaBase from the command line, you can follow the instructions below.

Open up a terminal from the top left hand menu and navigate to:

>>> ~/Apps/MetaBase

If you browse the directory, you will see that there is an app.js, which is the main MetaBase app, along with supporting files. Open the metabase-config.json file on your desktop and modify the MAC address in the config file if you haven’t already by following the steps in the previous section. Now, copy the “metabase-config.json” from your desktop to the ~/Apps/MetaBase/ directory.

Launch the MetaBase App using the following command:

>>> sudo npm start -- --config metabase-config.json

This will start MetaBase and connect to your MetaWear with the default settings specified in your config file. It will continue to stream, graph and log data until you press [Enter], which terminates the app.

_images/MetaBase_pi1.png

5.4.2. Data and Logs

Once you terminate your MetaBase session, all the logs can be found in the ~/Apps/MetaBase/output directory as shown below. The number of logs you will have and how frequent they log data will depend on your configuration file.

_images/MetaBase_pi3.png

5.4.3. Advanced Configuration

Once you are comfortable with the process of running MetaBase, you can go back and configure the “metabase-config.json” file further. You can increase the sensor reporting frequencies, the type of sensors you want to record data from, and much more. Please refer to the readme file in the MetaBase folder for detailed configuration settings.

5.4.4. Examples

The comes preloaded with several Python, NodeJS/Javacript examples in addition to the MetaBase app. You will find them pre-loaded on the hub.

5.5. Build your own Hub

It is possible to build your own version of MetaHub by compiling the source files on the right device. We provide this tutorial as an example, but no official suppport will be given for homebrew products.

  1. Install the Raspbian OS on an SD card:

    Follow the instructions in the previous section link to boot and setup your MetaHub.

  2. Change settings (such as the keyboard layout):

    Use the GUI:

    >>> sudo raspi-config
    
  3. Add Wifi:

    Follow these RaspberryPi Instructions.

    Update packages:

    >>> sudo apt-get update
    

    Install GIT:

    >>> sudo apt-get install git
    

    Install pip:

    >>> sudo apt-get install python-pip
    

    Install Bluetooth dependencies:

    >>> sudo apt-get install pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev build-essential python-dev
    

    Install Bluetooth libraries:

    >>> pip install pygatt
    >>> pip install pybluez[ble]
    
  4. Choose the language you want in the Linux Developer section

    Start coding!