ina-viam-module

command module
v0.0.0-...-ef9af93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

README

INA power sensor Viam module

Module for INA3221 series power monitors

Tested and known to work on the INA3221. Support for other INA modules already in mainline Viam RDK.

This can act as a sensor, reporting all channels simultaneously, or as a power_sensor, for which each channel must be configured individually.

Usage

1. Build binary

If you clone this repository to the target environment where you run your Viam robot, then you can build a binary named inaModule with:

go build -o inaModule
2. Add to robot configuration

Copy the binary to the robot (system where viam-server is running) and add the following to your configuration to use as a sensor:

  "components": [
    {
      "name": "ina_for_example",
      "type": "sensor",
      "model": "bee-ring:sensor:ina",
      "attributes": {
        "model": "ina3221",
        "i2c_bus": "0"
      },
      "depends_on": []
    }
  ],
  "modules": [
    {
      "name": "inaModule_for_example",
      "executable_path": "/path/to/executable/inaModule"
    }
  ]

And/or, use the following to configure as a power sensor:

  "components": [
    {
      "name": "solarChannel",
      "type": "power_sensor",
      "model": "bee-ring:power_sensor:ina",
      "attributes": {
        "model": "ina3221",
        "channel": "channel1",
        "i2c_bus": "0"
      },
      "depends_on": []
    },
    {
      "name": "boardConsumption",
      "type": "power_sensor",
      "model": "bee-ring:power_sensor:ina",
      "attributes": {
        "model": "ina3221",
        "channel": "channel2",
        "i2c_bus": "0"
      },
      "depends_on": []
    }
  ],
  "modules": [
    {
      "name": "inaModule_for_example",
      "executable_path": "/path/to/executable/inaModule"
    }
  ]

Additionally, you may set a floating point number in the voltageMul attributes field, and the voltage returned by Voltage() will be multiplied by this number. This is useful in the case where you are monitoring a higher-voltage battery and are using a voltage divider to halve the voltage. Note that only the output of Voltage() is changed, the voltage value returned by Readings() will be the raw value.

Example, if you used a voltage divider to halve the voltage:

      "attributes": {
        "model": "ina3221",
        "channel": "channel2",
        "voltageMul": 2.0,
        "i2c_bus": "0"
      },

Documentation

Overview

package main is a module for INA series power monitors

Directories

Path Synopsis
code and configuration loosely based on the implementation in esphome https://github.com/esphome/esphome/blob/dev/esphome/components/ina3221/ina3221.cpp
code and configuration loosely based on the implementation in esphome https://github.com/esphome/esphome/blob/dev/esphome/components/ina3221/ina3221.cpp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL