-
Can the espruino (WiFi) in this case, act as the MQTT broker?
I've got Device A hooked up to a GPS sensor and i'd like to send regular updates to listening devices B...D.
I can and have been using Websockets, with Device A running a server, but wanted to try use MQTT instead as it sounds like it's better suited for this sort of simple comms, with Device A being the broker?
All the examples i can find seem to have the Espruino connecting to a broker elsewhere, and then pub/subbing, unless i'm misreading it?
-
Apologies, real work took over! but a few weeks away and it was solved in a few seconds grrrrr...
I tried a few other of the commands that shouldn't require any update to baud rate, and stumbled across what i think was the problem.
This didn't seem to ever work, no matter what the testNMEACommand;
serial.setup(9600, { tx: options.tx, rx: options.rx }); serial.println(testNMEACommand); // attempt to send something to the GPS unit
But this does;
serial.setup(9600, { tx: options.tx, rx: options.rx }); setTimeout(function () { serial.println(testNMEACommand); // attempt to send something to the GPS unit }, 10);
I guess the connection just hadn't been made, by giving it just a few ms, the commands are being acknowledged (i'm getting PMTKACT sentences back, that at least tells me i'm sending something).
Is it better in this case to perhaps wait for the GPS unit's first communication to me i.e.
var connected = false; serial.on('data', function () { if (!connected){ serial.println(testNMEACommand); connected = true; } ...... });
As i suppose the timeout of 10ms may sometimes fail? I couldn't see a serial.on('connected') or similar command (as i suppose it's up to the device itself to send a heartbeat back, which can't be relied upon?).
-
So i've been experimenting reading the NMEA sentences, which has been going well but now looking at changing some of the GPS options sending commands to it.
So with Espruino Wifi B6 connected to Adafruit RX.
var refreshRate10Hz = "$PMTK220,1000*1F"; // ideal refresh rate (10hz) var refreshRate1Hz = "$PMTK220,100*2F"; // default (1hz) function AdafruitGPS(serial, options) { this.serial = serial; serial.setup(9600, { tx: options.tx, rx: options.rx }); serial.println(refreshRate10Hz); // attempt to update refresh rate var line = ''; serial.on('data', function (data) { line += data; if (line.indexOf("\n") > -1) { this.parseCommand(line); line = ''; } }.bind(this)); } AdafruitGPS.prototype.parseCommand = function (data) { var command = data.substring(0,6); console.log(command, data); }; var gps = new AdafruitGPS(Serial1, { tx: B6, rx: B7 });
So this connects and reads commands fine, but the write command doesn't seem to do anything (by the specs i believe regardless of the result i should be receiving a PMTK_ACK as a receipt of a command). I'm aware it's probably something very simple again! But having no luck, anything blindingly obvious in there?
https://cdn-shop.adafruit.com/datasheetsÂ/PMTK_A11.pdf (gps command sheet)
-
-
I've got an Espruino Wifi, and a Adafruit Ultimate GPS (https://www.adafruit.com/product/746).
I've got the following code from the tutorials;
Serial1.setup(9600, {tx: B6, rx: B7}); function onInit() { var gps = require("GPS").connect(Serial1, function (data) { console.log(data); }); } onInit();
The GPS module appears to power up ok, it's red LED flashing once every 1 seconds for a satellite fix, however i'm getting absolutely nothing back from the console.log. Not an error, not a success, nothing.
Not really sure where to go for troubleshooting from here. I believe I've got the pins wired up correctly.
Is it simply that the GPS module provided won't work "out of the box" with this module, do i need to do some lower level interfacing? Or perhaps something else is afoot?
Is there generally any way to debug/troubleshoot in circumstances like this?
EDIT: just to note: experienced JS dev, completely inexperienced Espruino/Ardunio etc dev!
Ah ok, might be a sockets for the immediate future and a look into the MQTT a little later.
Thanks very usefull to know : )