GithubHelp home page GithubHelp logo

balenablocks-iio's Introduction

balenablocks-iio

Provides an easy way to work with Industrial IO sensor data. This block uses libiio to interface with the compatible sensors.

Features

  • Convenience script to load built-in module
  • Allows loading externally built kernel modules
  • Exposes the sensor data as json on port 8110

Usage

This block contains the run.sh script which has the following options

usage: run.sh [options]

options:
  --i2c-modules-addr  Space separated list of modules to enable and the respective i2c address.
  --bus="1"   The I2C bus.
  --modprobe-modules  Built-in modules to load.
  --modules-path="/usr/src/app/output"  Root path containing modules to load.
  --additional-modules  Space separated list of externally built modules to load from modules_path(Set to /usr/src/app/output).

Dockerfile.template : Using built-in module - the BME680 IIO driver is already built-in balenaOS

FROM balenaplayground/balenablocks-iio:%%BALENA_ARCH%%

CMD ["bash","run.sh" ,"--i2c-modules-addr","BME680:0x76","--modprobe-modules","BME680"]

Dockerfile.template : Using externally built module

We can use the In-Tree Kernel Module Builder to build other IIO driver modules that aren't already in balenaOS.

e.g Build and load the mma7660 accelerometer driver

FROM balenaplayground/balenablocks-in-tree-module-builder:%%BALENA_ARCH%% AS base

ENV VERSION '2.53.12+rev1.dev'
ENV BALENA_MACHINE_NAME=%%BALENA_MACHINE_NAME%%

WORKDIR /usr/src/app

# the built modules are in the output folder by default
RUN itkm_builder build --os-version "$VERSION" --modules-list 'MMA7660' --src "drivers/iio/accel"


FROM balenaplayground/balenablocks-iio:%%BALENA_ARCH%%

# copy over the built modules
COPY --from=base /usr/src/app/output output


CMD ["bash","run.sh" ,"--i2c-modules-addr","MMA7660:0x4c","--additional-modules","MMA7660"]

If using in a multicontainer app or with docker-compose file:

docker-compose.yml

version: "2"

services:
  iio:
    build: ./
    privileged: true
    labels:
      io.balena.features.kernel-modules: "1"
      io.balena.features.sysfs: "1"
    ports:
      - 8110

Sample output

The block has a server running on port 8110.

E.g output with only one device connected - the mma7660 accelerometer

[
  {
    "name": "mma7660",
    "channels": [
      {
        "id": "accel_x",
        "attrs": [
          {
            "raw": "-10"
          },
          {
            "scale": "0.467142857"
          },
          {
            "scale_available": "0.467142857"
          }
        ]
      },
      {
        "id": "accel_y",
        "attrs": [
          {
            "raw": "-12"
          },
          {
            "scale": "0.467142857"
          },
          {
            "scale_available": "0.467142857"
          }
        ]
      },
      {
        "id": "accel_z",
        "attrs": [
          {
            "raw": "10"
          },
          {
            "scale": "0.467142857"
          },
          {
            "scale_available": "0.467142857"
          }
        ]
      }
    ]
  }
]

balenablocks-iio's People

Contributors

rahul-thakoor avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.