obniz Parts Library

M5StickC_ADC

GitHub
M5StickC_ADC
Usable Devices :
obniz_board
m5stickc
Found at :
秋月電子通商

M5StickC_ADC

The AD Converter for M5StickC. It reads the potential difference between + and -.

https://m5stack.com/products/m5stickc-adc-hat-ads1100

wired(obniz, {[scl, sda, vcc, gnd, i2c]})

connect to the obniz Board.
When using M5StickC, You do not need to assign pins.

// JavaScript Examples
var adc = obniz.wired("M5StickC_ADC");
while(true) {
  var vol = await adc.getVoltageWait();
  console.log(vol + " V");
  await obniz.wait(1);
}

When using other devices, assign vcc and gnd as appropriate pins.

name type required default description
vcc number(obniz Board io) no   Power Supply
gnd number(obniz Board io) no   Power Supply
scl number(obniz Board io) no   scl of I2C
sda number(obniz Board io) no   sda of I2C
i2c object no   obniz i2c object
// JavaScript Examples
var adc = obniz.wired("M5StickC_ADC", {sda:0, scl:26});
while(true) {
  var vol = await adc.getVoltageWait();
  console.log(vol + " V");
  await obniz.wait(1);
}

setGain(number)

Setting a gain. Choose from 1(default),2,4,8 times.

// JavaScript Examples
var adc = obniz.wired("M5StickC_ADC", {sda:0, scl:26});
adc.setGain(1);
while(true) {
  var vol = await adc.getVoltageWait();
  console.log(vol + " V");
  await obniz.wait(1);
}

[await] getVoltageWait()

get the potential difference(V).

// JavaScript Examples
var adc = obniz.wired("M5StickC_ADC", {sda:0, scl:26});
while(true) {
  var vol = await adc.getVoltageWait();
  console.log(vol + " V");
  await obniz.wait(1);
}

Supported from: obniz.js 3.5.0