Hi I'm trying to read code from an slave arduino using nodejs connected with and arduino through firmata, however i can't get the correct values in the read.
I'm using this package https://www.npmjs.com/package/firmata
Also I tried sending data from the Master to slave and it works correctly.
The slave arduino code:
#include <Wire.h>
void setup() {
Wire.begin(8);
Wire.onRequest(requestEvent);
}
void loop() {
delay(500);
}
void requestEvent() {
uint8_t buffer[4];
buffer[0] = 12;
buffer[1] = 23;
buffer[2] = 39;
buffer[3] = 78;
Wire.write(buffer, 4);
}
The Firmata code:
let firmata = require("firmata");
board = new firmata('COM3', {samplingInterval: 1000});
board.on("ready", function() {
this.i2cConfig();
this.i2cRead(8,4, function(data) {
console.log("received data");
console.log(data);
});
});
The response i get is:
received data
[189,255,255,255]