2.1.0 • Published 3 years ago

arduino-bt v2.1.0

Weekly downloads
179
License
MIT
Repository
github
Last release
3 years ago

Installation

npm install arduino-bt

Example usage

nodeJS (.js)

Make sure your bluetooth module is connected to your computer so it connect

const arduino_bt = require('arduino-bt');
const arduino = new arduino_bt('hc-05'); //replace hc-05 with your bluetooth device name

//connect to the arduino
arduino.setup();

//send data to the arduino
arduino.send('1');

//receive data from the arduino
arduino.onDataReceive((data) => {
    console.log(data);
})

Arduino (.ino)

Connections / Wiring

Code

#include <SoftwareSerial.h>

SoftwareSerial BTserial(10, 11);

void setup() {
    BTserial.begin(9600);
    Serial.begin(9600)
}

void loop() {
    //send data to the nodeJS server
    BTserial.print('1');

    //read the sent data from the nodeJS server
    Serial.println(BTserial.readStringUntil('\n'));
}
2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago