New to this Pi world and what not but I know some JS and am using the Johnny-Five library.
I used raspi-config
to disable Serial/USB Console and Enabled Serial interface. I've also added enable_uart=1
config.txt.
Running cat /dev/serial0
from the command like outputs a stream of data from the GPS unit and seems to be doing it's job. Nonetheless, I'm having an issue with Pin 10 receiving data from the GPS Unit. When I run my code below it throws the error:
Error: Pin "10" does not support mode "other"
var five = require("johnny-five");
var Raspi = require("raspi-io");
var board = new five.Board({
io : new Raspi({ enableSerial : true /* apparently required as per raspi-io docs */ })
});
board.on("ready", function() {
const gps = new five.GPS({
pins : {
rx : 'P1-10',
tx : 'P1-8',
}
});
gps.on("data", () => {
console.log("position");
console.log(" latitude : ", this.latitude);
console.log(" longitude : ", this.longitude);
console.log(" altitude : ", this.altitude);
console.log("———————————————————————————————————");
});
});
cat /dev/ttyS0
? – stevieb May 24 '17 at 22:05cat: /dev/ttyS0: Input/output error
– heyron May 24 '17 at 22:41raspi-config
will enable serial. You have NOT told us what you actually did. NOTE you should use/dev/serial0
rather than any other designation. – Milliways May 24 '17 at 23:18this might seem a bit ignorant but how do i use /dev/serial0 from within a node app?
– heyron May 24 '17 at 23:45the issue still stands that the pin does not support mode 'other' which i can't seem to find a definitive answer for
– heyron May 25 '17 at 00:01/dev/serial0
is a character device. You open and read and write to the device. I have no idea how to do this in JS, but there are hundreds of examples for Python, C etc. Linux programs generally do not access hardware directly, but through the/dev
interface. – Milliways May 25 '17 at 07:10