BleuIO

BleuIO

  • Back to Site
  • Buy Now
  • Manual
  • AT Commands
  • Help

›Nodejs library

Manual

  • How it works
  • How to use
  • Verbose Mode
  • Known Issues
  • Firmware Updates
  • Release History
  • Troubleshooting

AT-Commands

  • List of AT Commands

Scripts & Tutorials

  • Python: iBeacon
  • Python: Eddystone Beacon
  • Python: Scan
  • Python: Scan and Store
  • Python: SPS Script
  • Python: File transfer Script
  • Python: Repeater Script
  • Javascript: Google chrome.serial Beacon
  • C# Console App Example
  • C# WFA Example

Script using libraries

    Python library > v1.2.0

    • Custom Services example using Python library
    • Eddystone example using Python library
    • IBeacon example using Python library
    • Scan example using Python library
    • Scan and store example using Python library

    Python library < v1.2.0

    • Eddystone example using Python library
    • IBeacon example using Python library
    • Scan example using Python library
    • Scan and store example using Python library
    • SPS example using Python library
    • Security Example using Python library

    JS library

    • Eddystone example using Javascript library
    • IBeacon example using Javascript library
    • Scan example using Javascript library
    • Security Example using Javascript library
    • Get Device Distance

    Nodejs library

    • Scan example using Nodejs library

STM32 Example

  • STM32 Example
  • Smart Bulb Example

Arduino Example

  • Arduino Example

Beaglebone Example

  • Beaglebone Example

Build Your Own Firmware

  • Build Your Own Firmware
  • Advertising Example

More

  • Links

Scan example using Nodejs library

Introduction

In this example, we are going to

  • install node js libray
  • connect to BleuIO dongle
  • set the dongle to central role
  • scan for nearby bluetooth devies
  • show the result into the screen
  • run the script

First install the library using

npm i bleuio-nodejs-library

Creater a script.js file and paste the following code

import { bleuIO } from "bleuio-nodejs-library/bleuIO-nodejs-library/index.js";
const portUtils = bleuIO("/dev/cu.usbmodem4048FDE6EBCB1");
portUtils.writeData("AT+CENTRAL").then(() => {
  portUtils.writeData("AT+GAPSCAN=2").then(() => {
    portUtils.readData().then((data) => {
      setTimeout(() => {
        console.log("Data read from serial port:", data);
      }, 3000);
    });
  });
});

Here '/dev/cu.usbmodem4048FDE6EBCB1' is the path of the dongle. To get the conencted dongle path , write the following code for MAc

ls /dev/cu.*

For windows, devie path can be found on device information screen Device Manger After scanning for three seconds ,we wait for the response and show it on the screen.

To run the script, we simply type follwing code on terminal

node script.js
← Get Device DistanceSTM32 Example →
  • Introduction
Docs
ManualAT CommandsHelp
Community
YouTubeLinkedInFacebook
More
BleuIOSmart Sensor DevicesGitHub
Copyright © 2023 BleuIO. A product of Smart Sensor Devices