megabit

Connect real things with Node.js

Usage no npm install needed!

<script type="module">
  import megabit from 'https://cdn.skypack.dev/megabit';
</script>

README

Megabit

Connect real things with Node.js

Usage

GPIO Example

const { gpio } = require("megabit");
const sleep = require("util").promisify(setTimeout);

async function blink() {
  for (;;) {
    await gpio(26).write(1);
    await sleep(1000);
    await gpio(26).write(0);
    await sleep(1000);
  }
}

blink();

I2C Example

const { sht30 } = require("megabit");

async function measure() {
  const { humidity, temperature } = await sht30().read();
  console.log(`Humidity: ${humidity.toFixed(2)} %`);
  console.log(`Temperature: ${temperature.toFixed(2)} ℃`);
}

measure();

Documents

Megabit API Documentation

Devices

Device Description API
ADS1015 12-bit Precision Analog to Digital Converter ads1015
ADT7410 High Accuracy Digital Temperature Sensor adt7410
ADXL345 3-axis Accelerometer adxl345
GP2Y0E03 4-50 cm Distance Sensor gp2y0e03
MPR121 Proximity Capacitive Touch Sensor Controller mpr121
PAJ7620 Gesture Recognition Sensor paj7620
PCA9685 16-Channel 12-Bit PWM/Servo Driver pca9685
S11059 Color Sensor s11059
SHT30 Humidity and Temperature Sensor sht30
SSD1306 128x64 Dot Matrix OLED ssd1306
SSD1308 128x64 Dot Matrix OLED ssd1308
TSL2561 Ambient Light Sensor tsl2561
VEML6070 UV(A) Light Sensor veml6070
VL53L0X Time of Flight Distance Sensor vl53l0x