GPS Module not sending data on Puck.js

Posted on
  • Hello,
    I bought the GPS Module Ublox Neo 6m (GY-NEO6MV2).
    Then I connected it the following way to the Puck.js:
    GPS Module -> Puck.js
    RX -> D28
    TX -> D29
    VCC -> 3V
    GND -> GND

    The red LED on the GPS module is lighting.

    After that I wrote a small program:

    Serial1.setup(9600,{tx:D29,rx:D28});
    var gps = require("GPS").connect(Serial1, function(data) {
      console.log("DATA", data);
    });
    

    Unfortunately there is no output in the console. Doe you have any idea what could be wrong? Are there methods to check what might cause this problem?

  • Is RX connected to TX and vice-versa? Always worth checking :)

    However I've noticed that some GPS modules don't output anything at all until they get a lock - so it might be worth leaving the GPS in a window for 10 minutes just to make sure?

    Otherwise maybe detach the RX and TX wires and put a scope (or even just a LED) on them to see if any data is being sent?

  • After some time I get this in the console <- Serial1. I also tried changing the wires. It also does not work. The waiting does not help as well.

  • Are you trying the GPS out while connected to Bluetooth?

    <- Serial1 means that Bluetooth disconnected and the JS console moved over to Serial1, which is the default - then it moved back to Bluetooth when you reconnected. Using Bluetooth.setConsole(1) would fix that - but it shouldn't be your issue.

    If you disconnect the GPS, then short RX and TX together, I bet you'll find that Serial1.println("Hello") will cause data to be printed to the console.

    I'd try the LED thing - but if that's flashing about the only other thing could be that the GPS is using a different baud rate (even if 9600 is the default for most GPS systems)

  • Use this piece of code to check on GPS's output. Upload and start with entering onInit() in the console.

    // monitorPin.js
    var led = LED1;
    var pin = B7;
    var debounce = 5;
    var watchId = null;
    pinMode(pin,"input_pullup");
    function out(evt) { digitalWrite(led,evt.state); }
    function startWatching() {
      setWatch(out,pin,{ repeat:true, edge:"both", debounce: debounce });
      led.set();
    }
    function stopWatching() {
      if (watchId) watchId = clearWatch(watchId);
    }
    function onInit() {
      startWatching();
    }
    

    The red LED - LED1 - comes on. Then you can probe with a wire connected to the pin the GPS output (TX). If GPS sends something, TX is going low for the start bit and the LED goes out. You can play with the debounce value. Espruino is not fast enough to catch all 9600 baud changes and the event buffer may overflow... but you will get for sure some reaction when the GPS actually sends something.

    You may also use some other methods of recording what's going on at a pin, such as the way to record the IR remote control signal (see []()):

    // recordOnPin.js
    pinMode(D28,"input_pullup");
    var d = [];
    var w = null;
    c = 2000; // number signal changes to catch / record
    function record() {
      w = setWatch(function(e) {
        d.push(e.time-e.lastTime);
        if (!(--c)) stop();
      }, D28, {edge:"both",repeat:true});
    }
    function stop() {
      clearWatch(w);
      console.log(d.map(a=>(a*1000).toFixed(1)­).toString()); // display recorded times
    }
    onInit() {
      record();
    }
    

    Looking at the times you may even determine the baud rate.

    (I'm sure you came across my posts about GPS:

    Third one - I guess - is not what you are heading for, because this lead me to this question:

    How do you power the GPS? ...are you using puck's power? ...this could be a reason that the GPS module does not get enough power and puck may even brown out... (when button cell is not fresh anymore). After all, GPS is a bit power hungry when starting... as you can read in the post about powering the GPS by pins in order to be able to shut it down completely...

  • The power might be a problem. If the red LED on the GPS module is lighting constantly, the Puck.js delivers Battery level 0. If the GPS module is not connected it delivers a Battery level of 80. So does the puck not have enough power to use a gps module? What is the recommended battery for it? Maybe Varta?

  • Puck's CR2032 has an average capacity of 225mAh. Capacity is measured with (usually) 10% load, which means, if you draw 22.5mA, it will last 10 hours. In low power / energy context as with Puck, load is even much less and jsut pulsed in order to have a battery last very very long.

    After capacity is exhausted, voltage collapses practically completely (see datasheet).

    Since the GPS needs about 60..70mA peak - you may check this with the data sheet of your GPS module - this is way too much to keep power up. You may get 2 (fresh) alkaline AA / AAA batteries and power with them the GPS. This way puck is the only one sitting on the button cell...

    NOTE: With the GPS powered separately, you need then only three (3) wires between Puck and GPS: GND, RX, TX.

    To use the code snippets in my previous post - #5 - you need only to connect the GNDs; and the wire on the watching / recording pin you connect to TX of the GPS module.


    1 Attachment

    • CR2032.png
  • You may get 2 (fresh) alkaline AA / AAA batteries and power with them the GPS. This way puck is the only one sitting on the button cell

    Thank you. I am quite new at working with electronic components. Do you have a tutorial how to power the GPS module by a battery? I guess that I have to solder something to the VCC pin? Is there something that I should notice?

  • If the modules do not have female or male pin headers and there is enough space, I solder those on. then I use a bread board and some wires with combination of female and male connecters on both sides to connect the components and modules. If there is not enough space I cut a wire with pins in half solder the cut end onto the module. The other end of the wire I plug into the bread board...

    It is also very practical to have a power supply for the board that delivers - in your case 3.3V. Using a DC-DC (buck step down) converter with a USB plug that takes 5V from a USB and produces 3.3V output.

    On many posts you can see how it's done, for example: Breadboard friendly PICO.

    If you have not soldered yet, take some scrap things and practice on them. Go to youtube and search for some instructional videos.


    2 Attachments

    • breadboardWithPowerSupply.png
    • duPontFemaleToMaleBreadboardJumperWire.png
  • The module (if it's this one? https://www.openimpulse.com/blog/product­s-page/product-category/gy-neo6mv2-gps-m­odule/) says it supports input voltages of between 3 and 5v - so you could attach:

    • 3x AA batteries
    • A single cell LiPo battery

    Just be careful not to connect VCC to Puck.js as well - Puck.js only supports input voltages between 2 and 3.6v.

    If you want to connect both to the same power supply you'd do best to use a regulated 3.3v supply that you can then power from anything within the power supply's input range.

  • Just to add to this, if you use something like the MDBT42 Breakout or Pixl.js then those have 3.3v regulators inside already - so you could wire them up and they could power the GPS from whatever power source you decided to use for them.

  • That works well... I have one of these too... and the ON/OFF switch is a great bonus. I do not know the purpose of your project and the overall setup... but "Gehaeuse mit AA Batteriefach" could work as well... or a plain box and simple batterie holder for 3 batteries so you can all fit in a single box (w/ or w/o cutout for accessing/exposing puck.

  • After connecting the GPS module to a battery box the connection to the puck works.
    Unfortunately I only get this data (from inside a room):

    {
      "time": "::",
      "lat": NaN, "lon": NaN, "fix": 0, "satellites": 0, "altitude": NaN 
    }
    

    Any idea how to fix that?

  • Just put it near the window and wait a few minutes. GPS can take a while to get a lock.

    The GPS on your phone gets helped along a bit my the cellular network (providing time & rough location), but a standalone one can't assume anything, so it takes a bit longer.

  • If you cannot find an enclosure with separate battery compartment, you may us a battery box for more cells than you need and use the superfluous for your electronics... similar to what you find in this publication.

    Regarding the time to find first and subsequent fixes / satellites, you may even need to move the GPS antenna/receiver close to a window/onto the window sill with free sight of some sky. When had my GPS 6M receiver not on the window sill/somewhere in the middle of the, it sometimes did not even find a single satellite.


    1 Attachment

    • smartUseOfBatteryBox.jpg
  • Can I ask if you guys ever resolved this? I'm having the same trouble MobiTech did in the original post.

    • My GPS module light is blinking steadily (I assume that's a good thing).
    • I have connected up the battery pack to the module.
    • I also appear to be receiving data on the D29 pin on my puck (I ran the code allobjects posted in his first post, and the puck LED kept flashing and also I got a FIFO_FULL error fairly quickly).
      However, I'm running the code Mobitech has in the first post, and am still getting nothing on my console. Any help would be greatly appreciated (I'm a complete newbie, BTW : )
  • Since @MobiTech went silent, we can assume it got resolved for him... because post #14 is what you get until the gps could find fixes... (good enough reception over time to make sound calculations...).

    In your case - assuming GND and RX(Puck)-TX(GPS) are reliably connected and baud rate is matching, you should get at least what you see in post #4.

    To check if gps module gets some data from gps, you can enter gps.line in console. line is the property where the module collects all received data until it has a complete line with cr/lf, which it then does the parsing on (in handleGPSLine() function - see http://www.espruino.com/modules/GPS.js - GPS.min.js is though loaded, but still has the property 'line'). If this is completely giberish, the baud rate is still off...

    Btw, the GPS most likely send more than just the "GGA Sentence". Each line it sends has some identifier about the content and the module out of the box gives you only the GGA Sentence. If your GPS is for what ever reason differently configured / does not send this sentence, nothing will ever come out of the module... :

  • Just to elaborate on @allObjects post as I'm not sure it's that clear:

    • Do you have all the GNDs connected together?
    • The GPS TX pin needs to be connected to Puck.js RX (it's not TX->TX) - which with the inital code here is D28:

      Serial1.setup(9600,{tx:D29,rx:D28});
      var gps = require("GPS").connect(Serial1, function(data) {
      console.log("DATA", data);
      });
      

    You mentioned in your post that you're getting some data on D29 to it might just be that you have the pins swapped over :)

    You could also try:

    Serial1.setup(9600,{tx:D29,rx:D28});
    Serial1.on('data', function(d) {
      console.log(JSON.stringify(d));
    });
    

    Which will print out all data that was received - whether it's a valid GPS line or not. Might be handy for debugging?

  • Hi Gordon - Thanks, I did have my wires crossed, literally. I think I'm close to success, now in the console I'm getting a steady stream of

    Data[object Object]

    When I run your debugging solution (last code example in your last post), I do appear to be getting correct data, it's a steady stream of a lot of (JSON?) data, and some of them look like GPS readings. Could you please tell me how to fix the Data[object Object] to make it look more like actual data?

  • @Gordon , if data is mangled, then the sentence coming from GPS device is not what GPS module expects and parser goes high wire. @user97706 , take a look at GPS Module, Extensions for handling other sentences, and u-blox NEO-6M GPS receiver, especially post #3, that shows all what (my) GPS (at that time) sends (/sent).

  • Please disregard my last post, everything's working now. For some reason the string "DATA" in the original code was causing Data[object Object] output; I deleted the string and am now getting good results (thanks for all your help).

    A quick question (again, I'm a complete newbie): Why is it important to connect the ground of the GPS module to the ground of the puck? (I did do that, just wondering why it's important : )

  • Ahh - thanks! I just modified the posts above to use console.log("DATA", data); and not console.log("DATA"+ data);. It's just the way JS handles converting Objects to Strings.

    Why is it important to connect the ground of the GPS module to the ground of the puck?

    It's just a general electrical thing. Voltage is relative - imagine you're trying to measure the voltage on a battery - you need to connect both ends of it to the volt meter - just one isn't enough.

    So in pretty much all digital electronics, to make things easier you just connect all the grounds together, so that always sorts out one side of the connection and then you just worry about the signal wires.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

GPS Module not sending data on Puck.js

Posted by Avatar for MobiTech @MobiTech

Actions