Jareth
Jareth

Reputation: 441

Raspberry Pi GPS to HTML + NodeJS

I currently have a Raspberry Pi with a GPS dongle which is successfully getting coordinates. I can see all the information i need if i run cgps -s and my ultimate goal is to display this in a HTML page. I am currently using NodeJS as a server.

How can I access the GPS information from either a webpage or the NodeJS server?

Upvotes: 0

Views: 553

Answers (1)

Mo Nazemi
Mo Nazemi

Reputation: 2717

You should be able to run a Linux command in a NodeJS application using child_process.exec

const exec = require('child_process').exec;
const child = exec('cgps -s',
(error, stdout, stderr) => {
    console.log(`stdout: ${stdout}`);
    console.log(`stderr: ${stderr}`);
    if (error !== null) {
        console.log(`error: ${error}`);
    }
});

Upvotes: 1

Related Questions