Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

No project description provided

Project description

MetaCloud is a cloud service by MbientLab providing data storage, visualization, and analytics for your sensor data.

In order to run the example code in this tutorial, you will need to have an active subscription. If you need to create an account, follow the instructions on this page to begin a free 3 day trial.

Installation

Use pip to install the metacloud package.

pip install metacloud --process-dependency-links

If you are syncing data from one of MbientLab’s sensor boards, install the package with the metawear extra.

pip install metacloud[metawear] --process-dependency-links

Usage

After installing all of the necessary package, open a new Python file in your favorite text editor, import the metawear and metacloud modules, and create the MetaWearClient and Session objects. The Session constructor requires several attributes that describe the device and your app:

  1. Firmware version
  2. MAC address
  3. Model name
  4. Friendly name identifying the device
  5. App name
  6. App revision

If you don’t have an app name or revision, simply use the __file__ variable for the app name and "1.0.0" for the app revision.

from ctypes import cast, c_char_p
from mbientlab.metacloud import Session
from mbientlab.metawear import MetaWear, libmetawear, parse_value
from mbientlab.metawear.cbindings import *

mac = "D4:5E:82:E1:15:01"
metawear = MetaWear(mac)
metawear.connect()

libmetawear.mbl_mw_settings_set_connection_parameters(metawear.board, 7.5, 7.5, 0, 6000)

raw = libmetawear.mbl_mw_metawearboard_get_model_name(metawear.board)
model_name = cast(raw, c_char_p).value.decode("ascii")
session = Session(metawear.info["firmware"], mac, model_name, "Device #1", "metacloud_py_tutorial", "1.0.0")

Start a data stream from the device and add the received values to the Session object. Here we will stream accelerometer data thus will forward it to the add_acc_data method.

# Stream data at 100Hz
libmetawear.mbl_mw_acc_set_range(metawear.board, 16.0)
libmetawear.mbl_mw_acc_set_odr(metawear.board, 100.0)
libmetawear.mbl_mw_acc_write_acceleration_config(metawear.board)

def data_handler(ptr):
    value = parse_value(ptr)
    session.add_acc_data(ptr.contents.epoch, value.x, value.y, value.z)
data_handler_fn = FnVoid_DataP(data_handler)

signal = libmetawear.mbl_mw_acc_get_acceleration_data_signal(metawear.board)
libmetawear.mbl_mw_datasignal_subscribe(signal, data_handler_fn)
libmetawear.mbl_mw_acc_enable_acceleration_sampling(metawear.board)
libmetawear.mbl_mw_acc_start(metawear.board)

When you are ready to sync the data, stop the accelerometer then push the data to MetaCloud with sync method.

# Stop the stream
libmetawear.mbl_mw_acc_stop(metawear.board)
libmetawear.mbl_mw_acc_disable_acceleration_sampling(metawear.board)
libmetawear.mbl_mw_datasignal_unsubscribe(signal)
# Sync to MetaCloud, replace with actual login credentials
session.sync("username", "password")

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
metacloud-0.2.0.tar.gz (3.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page