Make sure your bluetooth module is connected to your computer so it connect
constarduino_bt=require('arduino-bt');constarduino=newarduino_bt('hc-05');//replace hc-05 with your bluetooth device name//connect to the arduinoarduino.setup();//send data to the arduinoarduino.send('1');//receive data from the arduinoarduino.onDataReceive((data)=>{console.log(data);})
Arduino (.ino)
Connections / Wiring
Code
#include<SoftwareSerial.h>
SoftwareSerial BTserial(10, 11);
voidsetup() {
BTserial.begin(9600);
Serial.begin(9600)
}
voidloop() {
//send data to the nodeJS server
BTserial.print('1');
//read the sent data from the nodeJS server
Serial.println(BTserial.readStringUntil('\n'));
}