Wow, I watched this when I was in high school (I was making a toy self-driving car for my school project) and I learned a lot of things from this video. Now I am a computer science major working part-time as a junior software engineer. Thank you so much for making this video, it really taught me a lot and gave me an idea of what programming is all about. You are awesome !! (I don't know why UA-cam recommended this to me now, but I am glad it did, bought back so many memories :) )
@@iforce2d Good material to study. Can I ask the author or subscribers a question about receiving data about VELNED? I rewrote the parser code to get values, but the values are parsed once every 40 seconds, while NAV_POSLLH normally parses once a second. If anyone answers with a hint, I'll show you the code.
What a gift! Nine months of learning boiled down to 39 minutes. Thanks! And your follow-up video is also a gift - especially the SendMessageOutputs information.
Wow! That was so helpful! I am very grateful you have done this research. Like you, I was only looking for a handful of values for my application, LAT / LON and perhaps speed and heading etc. But parsing the numerous text based NEMA sentences just to find the one of interest, and trying to keep up with the rate to prevent a buffer overflow seemed so silly when I only needed 16 bytes of so. Thank you so much for drilling deep into this and helping us understand (at least for ublox devices) how to reconfigure them for just the data we need , turn of the endless text messages in favor of the UBX binary or hex mode. Brilliant! I just reconfigured my two UBLOX 8M modules which happily accepted the upgraded rate of 10 HZ versus the default of once per second. Cant wait to try it out in my app. Thanks again for demonstrating a game changing mode to talk to our GPS! Nice work!
Don't worry about the length of your videos. People can fast forward over things not applicable, so please keep being detailed in your explanation and picture inlays. Great work.
This looks like great fun - I'm going to get one of these. I might even go to Greenwich so I can see genuine zeros coming in for longitude. Might be a bit tricky getting both to show zero though :)
Just have to say this video stands the test of time. I watched it at least 100 times, NOW I’M making a nixie clock out of a vintage HP nixie counter with no modifications to the counter itself. Pulling the time from gps through an uno displaying time on the counter. THANKS
C structs and pointers have fallen from heaven. Combining these two when sending, receiving or storing packets of data is absolutely the way to go. Thank you for a very clear and informative video. Please keep them coming.
(chuckle) "Is anyone still watching?" Of course! I love the amount of down to earth detail I get from your videos (pun not intended but I'll accept any credit anyway). Don't stop. Thanx, WDP
This is brilliant. Designing a GPS disciplined real time clock. Looks like I can keep the GPS code very small and use a Maxium TCXO chip to hold the time during power failures. Update the Maxium chip every 4 hours from the GPS time and have a pretty accurate clock. Using binary and turning off everything but what I need is really a great idea. Thanks for the great video!!
I'm still watching! :) Thanks iforce2d for putting this together. It was tremendously helpful! I just want to post this for anyone having trouble: I was getting no information displayed in the serial monitor despite making sure only the one (NAV_POSLLH) or two (NAV_STATUS) were being sent via the U-center software. I tried using hardware serial (RX-TX and TX-RX) and it worked with no problem. Convert all the lines of code with "serial. " to "Serial." to let the arduino use hardware serial. Also make sure to disconnect RX/TX lines while you upload the code to the arduino.
Yep, I'm "still watching", Freak'n AWESOME !!! Binary is SEXY. I've watched this one and many of your other videos over and over. I don't know how many times over the last x months. At first I was frustrated with what I thought was just rambling on. But, YT, ie, google search kept bringing me back. And, as I watched until the end, you REALLY do cover all the DETAILs. Thanks for all the research, work and time creating these! Character text is for wimps. Real programmers know the difference in a byte and a char, nothing, it’s all left up to interpretation. Cheers BG
BRILLIANT video, iforce2d! Thanks to you, I was able to use UCenter to configure my NEO-M7 to deliver 10Hz updates, even after I power-cycled it. Now I can read the UBLOX messages using Python (my original goal), and will move on to Arduino as you've done. So I believe that following your instructions carefully produces a robust solution.
Glad you did the video. I had worked this all out about 4 years ago but didn’t remember how. Hang onto that version 8.12. I can’t get the née 20 point something to work at all and it wants the internet all the time. Well done 👍
Thanks so much for your video I watched it all the way through. I don't mind long videos. ;-) It was just what I was looking for as I've got the NEO6MV2 module and need to convert the data out from the GPS to another Binary Format for input into another piece of gear, a Telescope Controller, which does not use NEMA Strings. You've been a great help on this. Cheers from South Australia. Jeff
Your code works fine on a Teensy 3.2. Your explanation of navigating UBlox's interface was also pretty good. it took me a long time to find my way around it. My autonomous object will fly and i had almost given up being able to do it with a single controller - two or three, but the teensy is just the thing. 256k program space and three serial ports in addition the the first one, plus swift processing 96mHz.. on teensy sketches which i'm migrating from arduino, I get them running on an uno or mega first, then go to the teensy. teensy compiler seems fussier about the sorts of things where C compilers used to object to C+, but not consistently.
Good information and video. I’m still using the old system and two Arduino boards for now so my brain can keep the functions separate but likely will do this in future modifications. Thanks.
I believe another benefit of using this scenario instead of libraries is to avoid float type & resulting inacuracy of dealing with float type. Anyways, this was quite deep insight, thank you!
A comment from the future ... There are very few things one can do to produce an abridged version of this without leaving out salient details. Its even refreshing to see someone struggle through the same issues we are experiencing.
Good video. Looking closely at a problem often reveals better solutions. U-center won't work to turn off sentences on other GPS's. I made my own NMEA state machine library that efficiently discards the sentences it doesn't want, and it takes far less resources that way, and it works with any GPS module that outputs NMEA.
i once connected my GPS module with an FTDI to my computer and opened a serial monitor in the Ardiono IDE, looked very much alike what you showed in the text console :)
Yes, the factory defaults seem to be quite similar for most modules. Unless you change the settings like I did, you will get exactly what we saw in the text console to start with.
***** hi there, thank you for reply, i did check the battery voltage , it seam to be holding charge, am so frustrate, some how with the laptop in u-centre , i got the gps fix very fast, and first time in the copter it pick up fast too, but lol leave it for a bout 10 mins or more , then maybe need to waited forever ;-)
well, you did it again - one more in a series of great vids that shoot right to a topic i've been interested in. i've read before about shutting down a lot of the info on a GPS so that the Quad can better utilize just the pertinent info it needs. - and while U-Blox is a great piece of software - it is not all that user friendly. you were able to clear up 90% of what i wanted to glean off the software. thanks for that. I have a question, though... when using Cleanflight - the CF software allows you to pick a bit rate. does CF push ANY data to the GPS module or do you just set that bitrate according to what you programmed it to? keep up the great work - as far as i'm concerned - your videos are just long enough. Thanks, Russ from Coral Springs, Fl, usa
To be honest I'm not sure how that works. hm..... just checked the source code - Cleanflight sends a 'change baud' instruction to the GPS module on all baud rates one after another. One of them has to succeed, after that they will both be using the desired baud rate.
ahh... there had to be a reason why there was a dropdown selection for the baudrates... so - you believe that the software only tries to GET the baud rate & doesn't SET any gps options? Is there a way of telling which "G" code line that CF looks for when it grabs the Lat/Long? are there any other lines. my guess is that it would be more beneficial to shut down the other data lines so that the CF would not have to read thru all the lines of data the GPS would (at default) be sending down the Tx line to the CF, and therefore having less lines to read, the processing time of obtaining the Lat/Long would then be shorter.
No, quite the opposite. The flight controller sets the baud rate and a bunch of other things too, the SBAS settings, the update rate, which messages to provide etc. If we are talking about the UBX protocol as covered in this video, it doesn't use any text string 'G' codes. Part of said settings is to disable those NMEA messages and use UBX binary messages instead (as at 22:24 in this video). As for the setting of baud rate, my explanation before was perhaps a bit brief. Suppose you choose a baud rate of 57600 as your desired baud rate. When the FC starts up it will tell the GPS module "Let's talk at 57600 baud". But the FC doesn't know what baud rate the GPS is currently listening to, so it sends that message at 9600, then at 19200, then at 38400.... and so on, to cover all the possibilities. By the end of that process, it doesn't matter what baud rate the GPS was originally using because one of those messages will get through, so it will switch to using 57600 thereafter. This would be at github.com/cleanflight/cleanflight/blob/master/src/main/io/gps.c#L269
I'm on a bus, I apologize for any text errors. I now understand. The FC actually DOES send control codes. Codes are dependent on the type of GPS you select in the clean flight software or I have software.
yeah - that last remark did not finish up correctly - bumpy bus ride. so the bottom line is, it does no good to fool around with the Ublox because it will all be taken care of in iNav Flight. thanks. so now i'm moving on to your "tagging" videos. sleep tight.
Height abolve ellipsoid is height above the Mean Sea Level (MSL) model that does not account for gravity inconsistency (Geoid), not height above ground level (AGL). POSLLH - POSition Lat Long Height
One Arduino-specific issue, at least with presenting the Lat and Lon data, in 'human readable' form (on any model, apart from Due)... Arduino Uno float variables are strictly single-precision. That means, when you divide the values by (/10000000.0f) you aren't getting 1e-7 precision. If you watch the data stream by, you'll notice that the number will be static for long periods and then, the last 2-4 digits will all change together. Since the height is only divided by 1000, it doesn't appear to lose any precision. For the inner workings of a multi-copter, best to work with the 'raw' long number and don't give up the 1e-7 precision lost in converting to single-precision floating point.
This was such a useful video, thanks. How good is the u-center software, after using that I think I'll be sticking to using u-blox as my go to GPS module, especially given the price :)
NOTuNOTme "how good" is a bit vague, but it lets you set any option available on any ublox module, there are many views available to see the data, and it doesn't crash... :) It's free and you could have it running on your computer in a few minutes to see for yourself. www.u-blox.com/en/evaluation-tools-a-software/u-center/u-center.html
***** Sorry, "how good" was supposed to be a rhetorical question like "how good was the rugby last night" haha. They did a quality job on this application, right down to the field descriptions in the NMEA sentences. The best feature is they display the byte code for the command you've selected, that's so useful. I'll get a NEO-7 next. Will be a cheap way for me to play around with GLONASS. Thanks again for your great video.
hai. i'm using gy-neo6mv2. i had problem when i attached it on arduino nano. there is no serial output result. but when i try it directly on u-center it's working. can you help me? i use ýour UBX_GPS_SS
Thank you, thank you, thank you!!! Excellent video. My most immediate concern has been getting an accurate time value from the GPS unit, accurate to the millisecond. The iTOW (Time Of Week) value would seem to do exactly what I need. I followed along, running the u-center program connected to my GPS unit and the iTOW values do indeed seem to be providing millisecond accuracy, with sequential values of 28.552 s , 29.552 s, 30.552 s, 31.552 s, etc. So, exactly 1,000 milliseconds between each subsequent message. HOWEVER, I notice that in your test setup in which your GPS unit has no antenna and is therefore showing no lat/long values, it nevertheless IS showing what look like valid iTOW values, AND every single one of the iTOW values ends with 00, incrementing by 100 each time, which corresponds to the once-every-tenth-second that you have set for its rate. But where is it actually getting those iTOW values if not from satellites? It looks very strange to me that your values are always coming in precisely on the tenth of a second, while my values (from a GPS that's definitely accessing satellites) happen to be coming in on the .552 second. Are the iTOW values actually received from the satellites, or is it somehow just calculated and local to the GPS device?
I think it just gives some local value based on when it started up. Usually there is a tiny button cell battery used to store the ephemeris information for quicker startup, so perhaps it also stores the last time it saw and begins with that. Either way, just ignore all data until the 'fix' value is valid.
Thank you for sharing this. So often the library code uses too much the available memory of the Arduino. I will be using the code for my project. My challenge is to minimize memory usage and power consumption. I have GSM (SIM800L) , GPS (NEO-6M) , MOTION (gy9255), radio (NRF24L01) and weather (BME280) devices to manage with a single PRO MINI.
Yes, I am still watching (even the 'Wrong Button' event). Most useful - now all I have to do is to figure out how to make the changes stick to my NEO 6 and NEO 8 after power-off.
Nice tutorials, normally, I use GPS with Arduino for datalogger, also I use Laptop with U-blox for Lat and Long coordinating. Just a questions. Each time when I use GPS module, their time is in Greenwich Time Zone or 00:00 U.T.C which is 6 hours ahead of Central Time Zone -6:00. How do I change it from Greenwich Time Zone to Central Time Zone? Thank you.
Sry for the late reply but it seems to me that save and load the configuration refers to saving on the PC not the ublox. Send is indeed the act of committing the config to the unit. It can also be that the PC software could make a auto-commit, that is sending the configuration, to the unit on exit or the like. it's a matter of checking how the U-Centrer sotware exit warnings are alerting the user to sedn or save the changes made to the configuration.
You got 10hz off a bro-6m? That’s pretty awesome. I only went to 200ms for update. I never tried 100 for a 10hz. The manual said 5hz max so I figured it won’t go to 10hz but never tried. I shal try and see if I can get close to 10hz which would be awesome.
Amazing work sir, this information could be used for gps hold of a quadcopter ?, I'm currently using it but i dont have any good result. Have you ever implemented a position controll for a quadcopter any recomendation?
Great video! You might be able to make this code even smaller by filling up the buffer and looking for the sync word of "ub" and the message ID and laying the structure of the message over the buffer instead of iterating over each byte.
Not sure exactly how that would work. My method makes sure the bytes following 'ub' will always be at the beginning of the struct, and requires only the number of bytes that the message actually needs, and the message struct itself acts as the buffer. It sounds like your method would require a second buffer of at least as much memory as the message size, and would often find the 'ub' in the middle of the buffer. Of course it would work fine and might even be less lines of code, but seems a little less straight-forward.
Thanks for the great tutorial ! Like to ask one question. Is it possible to modify maximum altitude(which is 50 km for NEO-6) using u-center or programming.I hobbyist and doing high altitude ballooning ..
I don't know. But if you got that 50km number from the spec sheet of the Neo6 then I would think that is the limit of the Neo6 itself, not the firmware running on it.
Hello First, thank you for all the work you’ve done in presenting this and the other very informative videos on you youtube site. I am not extremely proficient at C programming so I was a little confused by your use of the indirection (*) and address (&) operators you have used in the Arduino code associated with this video. In particular, there is the line of code: if ( (fpos-2) < payloadSize ) ((unsigned char*)(&posllh))[fpos-2] = c; A couple of questions about this: Is it technically “legal” or even a good idea to reference a structure in C (posllh) through indexing ([fpos-2]) as if the structure were an array? I tried to read a bit about this online and most of what I read said that this is not usually permitted, but may/may not work. In your program, it is apparently working just as you would want it to. Then I am confused about the * and then the address of & operator. Could you explain a bit about what is actually happening here? Finally, the quantities in the structure posllh that are > 1 byte are in “little endian” format. I confess that I wrote my own version of this code --- reading in each transmitted byte into an array of bytes. Then to get the correct quantities for lat and lon for example, I had to bit shift the bytes to take into account the little endian format. In your code, you do not seem to consider this formatting at all. Can you explain at all why you can basically ignore the little endian formatting - does the structure posllh somehow take this into account? Thanks very much for your time. Richard S.
Most compilers don't really care about 'legal', if it's all memory within your program then it's yours to play with and there is no concept of 'permitted'. Sure you can treat a struct as if it were an array, as long as you know the positions within the struct/array where the data members will be. On a 32 bit operating system you have to be careful because the data members may not all be packed into the minimum number of bytes necessary, because 32 bit systems often place variables at 32 bit addresses for efficiency. In that case you would need to explicitly specify that the struct should be 'packed'. en.wikipedia.org/wiki/Data_structure_alignment www.catb.org/esr/structure-packing/ stackoverflow.com/questions/4306186/structure-padding-and-packing The arduino is an 8 bit architecture so structs will always have their data members at single byte offsets, no packing is required. The operation of * and & is explained ad-nauseum in so many C textbooks and blogs everywhere, I'll leave it to you to figure that out. It might help to break down the nasty looking parts into more steps, instead of putting it all in one line. Eg: ((unsigned char*)(&posllh))[fpos-2] = c; is equivalent to: NAV_POSLLH* structPtr = &posllh; unsigned char* charPtr = (unsigned char*) structPtr; charPtr[fpos-2] = c; Actually I never considered the endian format issue, it just worked like this so I guess for the arduino system the format was already ok. Other platforms may do this differently, maybe the code you're talking about was not running on an arduino.
Really Nice Video, Do you have an example sketch using the Tiny++ Library, I am using a Neo-7M gps module and Wemos D1 mini Type ESP8266 Board. Not having ANY success with the TinyGPS++ library so far.
Yes, almost everything applies similarly. I used this UBX method with no problems with the M8P. Keep in mind that the firmware versions differ slightly across some modules, and the size of message packets may vary. See the pinned comment in this video for an example: ua-cam.com/video/ylxwOg2pXrc/v-deo.html
Hello iforce2d! what if the vcc and grnd pins appear as shorted out when checked with the multimeter. Not on the board but shorted out on the chip ? (ublox 6M) (GY-GPS6MV2). I bought a new one recently and plugged it with APM 2.8 flight controller. I think it did not work. I also tried the TinyGPS test library and received nothing from the GPS on Arduinomega 2560. Yes the Gps module was hot when plugged in to 5 volt . But later connected to the 3.3 volt option on arduinomega. Never did the GPS green light lit up and neither did i receive any information on serial monitor . Should i check using FTDI connector on ucenter or do u think the module shall not work ( as it might be damaged). Looking forward to ur response!
Hey iforce2d and Muneeb, I have the same Problem.my neo 6m module i got from ebay around 1 week ago and i checked it with multimeter and i'm facing same problem.Shorted and not getting anything.if you got any fix plz post it here,or contact me.(imeshsps@gmail.com) Thanks..
Thank you for a brilliant video, I have been experimenting with the NEO-6M gps module using your code with some success. I have noted however that the Lat and Lon values are only to two decimal places. My knowledge of C++ is very limited so my efforts to date have not been successful in increasing the number of decimal places. Comparing the value from the NEO6 and a Garmin Etrex there is approx. 400mtrs difference. Can you point me in the right direction please.
It sounds like you might be using arduino's Serial.print function to look at the values, and not specifying the number of decimal places, which defaults to two. www.arduino.cc/reference/en/language/functions/communication/serial/print/
Hello @@iforce2d, Thank you so much for the pointer I have modified my/your code to give 4 decimal places, the result is now more acceptable. My next step is to send the data to my OLED display. Thank you again for your help :)
@@iforce2d Hello again, I have been experimenting with the my NEO6M GPS and an 128x64 OLED display using the multi message sketch you have produced. Adding a display function I have been able to display LAT/LON, hMSL, vAcc and hAcc, from POSLLH onto my display with not issues. Then I tried to add gpsFix from message NAV_STATUS , Serial printing is ok I get a value say 3. I then created a second struct as you did for POSLLH for the STATUS message using this value (locData2.gpsFix) I get a value of 3 on my oled display, then it toggles to what appears to be an address which increments up to 255 then starts from 0 back up to 255. the curious thing is if I serial print (locData2.gpsFix) it will display the correct value say 3. If I call the display function from the STATUS message only and don't include the POSLLH message I get the correct information on the display and the serial monitor. This is bugging me any ideas!! . My other option is to use a NMEA sentence which has all the data I need, unfortunately my NEO6M wil not give me the PVT sentence. Apologies for the essay.
Thank you for showing me how to use u-center. Do you please have a link for the data sheet? I may now be able to change output time using u-center from UTC to local time (NZ). Lowering the rate caused writing to an SD Card to fail- I am using NMEA, not UBX, Arduino UNO and an SD card shield. Writing to a .CSV file - date / time, lat, lon and altitude. Many thanks.
pretty sure you can get the datasheet by googling "ubx protocol". Changing the time is just a matter of adding a few hours isn't it... not sure you would really need u-center to do that if you are reading in the values into your own program. You mean increasing the rate? Not sure why lowering it would be a problem.... if you're gonna write values to a file and throughput is an issue, you might want to write these binary values to the file instead of .csv, which would be more efficient.
***** Yes, sorry increasing the rate. Adding a few hours is probably the easiest but I dont want to do this adjustment in the sketch as I need to keep code as tight as possible. Getting corrected local time straight from the GPS would be ideal. Found the PDF - there are predefined datums I should be able to use. Thanks again.
do we really need an ftdi adapter to program gps module or can we upload arduino a blank code and make connection vcc , rx ,tx , gnd and do the gps module update ?
Great video. I am programming an arduino UNO and Mega 2560 to get GPS out of a BN-220 GPS and save it to sd card. The sketch works find but is not working on a pro mini or nano because its too big. Now I found this video and will try to use UBX protocol instead of NMEA and make it work on a Arduino NANO. The plan is fly around with my rc glider. GPS receiver in the glider sends data to ARduino and then Arduino sends it to X8R receiver and gps data is shown on my FRSKY Taranis X9D transmitterscreen and maybe also stored on the sd card of the TAranis. I already reconfigured the BN-220 wit Ucenter. I also noticed it doesnt always store the settings. If it works I will make a video. I also want to check OpenXsenser, maybe they have a sketch for this.
Changing the settings and storing them permanently are two different steps. After you have confirmed the module is outputting the messages you want, you can do Receiver > Action > Save Config. Otherwise the settings will revert to what they were before, after a power cycle.
@@iforce2d i just found out that I can connect my BN-220 gps to my OpenXsensor Vario I made. Its a matter of activating it in the sketch and it must work after alter some bitrate settings maybe. Thanks for your advice.
Wow, I watched this when I was in high school (I was making a toy self-driving car for my school project) and I learned a lot of things from this video. Now I am a computer science major working part-time as a junior software engineer. Thank you so much for making this video, it really taught me a lot and gave me an idea of what programming is all about. You are awesome !!
(I don't know why UA-cam recommended this to me now, but I am glad it did, bought back so many memories :) )
Glad it helped!
@@iforce2d Good material to study.
Can I ask the author or subscribers a question about receiving data about VELNED?
I rewrote the parser code to get values, but the values are parsed once every 40 seconds, while NAV_POSLLH normally parses once a second.
If anyone answers with a hint, I'll show you the code.
What a gift! Nine months of learning boiled down to 39 minutes. Thanks! And your follow-up video is also a gift - especially the SendMessageOutputs information.
Wow! That was so helpful! I am very grateful you have done this research. Like you, I was only looking for a handful of values for my application, LAT / LON and perhaps speed and heading etc. But parsing the numerous text based NEMA sentences just to find the one of interest, and trying to keep up with the rate to prevent a buffer overflow seemed so silly when I only needed 16 bytes of so. Thank you so much for drilling deep into this and helping us understand (at least for ublox devices) how to reconfigure them for just the data we need , turn of the endless text messages in favor of the UBX binary or hex mode. Brilliant!
I just reconfigured my two UBLOX 8M modules which happily accepted the upgraded rate of 10 HZ versus the default of once per second. Cant wait to try it out in my app. Thanks again for demonstrating a game changing mode to talk to our GPS! Nice work!
This video is so incredibly useful, I finally understand exactly what's going on in those modules and how to talk to it on my own thank you
Don't worry about the length of your videos. People can fast forward over things not applicable, so please keep being detailed in your explanation and picture inlays. Great work.
This looks like great fun - I'm going to get one of these. I might even go to Greenwich so I can see genuine zeros coming in for longitude. Might be a bit tricky getting both to show zero though :)
You won't be as close to Greenwich as you think, even without 0deg N/S
.. oops 3yo message... nvm
You'll need a boat, (0,0) is in the middle or the Mediterranean.
For a real challenge, you may want to go to 0.000000, 0.000000... which is about 620 Km almost exactly South from Accra (bring a bathing suit).
@@christopherguy1217 they mean north south
Just have to say this video stands the test of time. I watched it at least 100 times, NOW I’M making a nixie clock out of a vintage HP nixie counter with no modifications to the counter itself. Pulling the time from gps through an uno displaying time on the counter. THANKS
C structs and pointers have fallen from heaven. Combining these two when sending, receiving or storing packets of data is absolutely the way to go. Thank you for a very clear and informative video. Please keep them coming.
(chuckle) "Is anyone still watching?" Of course! I love the amount of down to earth detail I get from your videos (pun not intended but I'll accept any credit anyway). Don't stop.
Thanx, WDP
Yes, still watching. I now have a better understanding. Thank you.
This is brilliant. Designing a GPS disciplined real time clock. Looks like I can keep the GPS code very small and use a Maxium TCXO chip to hold the time during power failures. Update the Maxium chip every 4 hours from the GPS time and have a pretty accurate clock. Using binary and turning off everything but what I need is really a great idea. Thanks for the great video!!
Watching this 5yrs Later in Kenya(Africa) and really helpful, thank you.
The most complete and didatic document UBX in the INTERNET :) Thank you! I will recommend it
I'm still watching! :) Thanks iforce2d for putting this together. It was tremendously helpful! I just want to post this for anyone having trouble: I was getting no information displayed in the serial monitor despite making sure only the one (NAV_POSLLH) or two (NAV_STATUS) were being sent via the U-center software. I tried using hardware serial (RX-TX and TX-RX) and it worked with no problem. Convert all the lines of code with "serial. " to "Serial." to let the arduino use hardware serial. Also make sure to disconnect RX/TX lines while you upload the code to the arduino.
Yep, I'm "still watching", Freak'n AWESOME !!! Binary is SEXY. I've watched this one and many of your other videos over and over. I don't know how many times over the last x months. At first I was frustrated with what I thought was just rambling on. But, YT, ie, google search kept bringing me back. And, as I watched until the end, you REALLY do cover all the DETAILs. Thanks for all the research, work and time creating these! Character text is for wimps. Real programmers know the difference in a byte and a char, nothing, it’s all left up to interpretation. Cheers BG
Yes, I'm still watching! Great video! Please keep making these videos. Thank you very much!
Greet video after five years. Really helps me with my f9p+f9h for ubuntu :)
BRILLIANT video, iforce2d! Thanks to you, I was able to use UCenter to configure my NEO-M7 to deliver 10Hz updates, even after I power-cycled it. Now I can read the UBLOX messages using Python (my original goal), and will move on to Arduino as you've done. So I believe that following your instructions carefully produces a robust solution.
"Is anyone still watching this?" HELL YES!
oh def!!
Yes! :)
Yep yep
Glad you did the video. I had worked this all out about 4 years ago but didn’t remember how. Hang onto that version 8.12. I can’t get the née 20 point something to work at all and it wants the internet all the time.
Well done 👍
Absolutely FANTASTIC VIDEO! Best information on Arduino+GPS I have come across. Great work sir!
Dude, please let me work on my thesis. I cannot keep myself away from watching your newly updated videos.
What are you doing here you slacker, get back to work :D
iforce2d a neo 6m.
Thanks so much for your video
I watched it all the way through.
I don't mind long videos. ;-)
It was just what I was looking for as I've got the NEO6MV2 module and need to convert the data out from the GPS to another Binary Format for input into another piece of gear, a Telescope Controller, which does not use NEMA Strings.
You've been a great help on this.
Cheers from South Australia.
Jeff
Mate ... really appreciate this. Totally late to the party but after a bit of getting it wrong I got it right with a C94 M8P and a Uno.
Thank you for the tremedous value added with this video. Worths watching every second
Thank you for that. A very comprehensive description that I did watch all the way through.
Your code works fine on a Teensy 3.2. Your explanation of navigating UBlox's interface was also pretty good. it took me a long time to find my way around it. My autonomous object will fly and i had almost given up being able to do it with a single controller - two or three, but the teensy is just the thing. 256k program space and three serial ports in addition the the first one, plus swift processing 96mHz.. on teensy sketches which i'm migrating from arduino, I get them running on an uno or mega first, then go to the teensy. teensy compiler seems fussier about the sorts of things where C compilers used to object to C+, but not consistently.
Thanks man, I'm working making a formula car at my university and that video helped me a lot
That was cool man. I was struggling to decipher the documentation and I find this video. Thanks a lot.
Thank you! Trimmed down data to my dashcam, and increased data rate. No more 1hz speed update on videos. Thank you
Very informative and thanks for going the length to explain and show how it is done. Going to watch the follow up video now. Thanks again.
Still watching in 2021 :D you helped me a lot!
Good information and video. I’m still using the old system and two Arduino boards for now so my brain can keep the functions separate but likely will do this in future modifications. Thanks.
I believe another benefit of using this scenario instead of libraries is to avoid float type & resulting inacuracy of dealing with float type. Anyways, this was quite deep insight, thank you!
Thank you for the effort to explaining this, brilliant and clear.
Hey, great video! It helped me understanding the whole ubx thing a lot better.
Great video! Thanks for taking the time to document this chip
A comment from the future ... There are very few things one can do to produce an abridged version of this without leaving out salient details. Its even refreshing to see someone struggle through the same issues we are experiencing.
Many thanks a really very fine tutorial ---it would take masses of time to get all this information by trial and error. Thanks again
Good video. Looking closely at a problem often reveals better solutions. U-center won't work to turn off sentences on other GPS's. I made my own NMEA state machine library that efficiently discards the sentences it doesn't want, and it takes far less resources that way, and it works with any GPS module that outputs NMEA.
Great video explaining the ublox protocol. Very helpful. Thank you.
Fantastic! Thank you! You just made my project manageable.
Desde Argentina te digo... Excelente video!!!! gracias!!!!!
i once connected my GPS module with an FTDI to my computer and opened a serial monitor in the Ardiono IDE, looked very much alike what you showed in the text console :)
Yes, the factory defaults seem to be quite similar for most modules. Unless you change the settings like I did, you will get exactly what we saw in the text console to start with.
***** hi there, thank you for reply, i did check the battery voltage , it seam to be holding charge, am so frustrate, some how with the laptop in u-centre , i got the gps fix very fast, and first time in the copter it pick up fast too, but lol leave it for a bout 10 mins or more , then maybe need to waited forever ;-)
at last, an explanation how to change to ubx in u-center; thank you!!
You are an everyday hero my man! :)
Wow! What a great video. Thank you so much. Thanks to you, my GPS is working.
Yeap to the end, well done. Show the data sheets and format of how the struct is mapped to it is great.
Big thanks for detailed video
Best video ever love you This is going to be great for my supersonic rocket. Thank you
"well my car was driving itself into the wall, wasn't my fault"
Thank you, my friend. You are the man
Two words:
Perfect !
Thanks !
well, you did it again - one more in a series of great vids that shoot right to a topic i've been interested in. i've read before about shutting down a lot of the info on a GPS so that the Quad can better utilize just the pertinent info it needs. - and while U-Blox is a great piece of software - it is not all that user friendly. you were able to clear up 90% of what i wanted to glean off the software. thanks for that.
I have a question, though... when using Cleanflight - the CF software allows you to pick a bit rate. does CF push ANY data to the GPS module or do you just set that bitrate according to what you programmed it to?
keep up the great work - as far as i'm concerned - your videos are just long enough.
Thanks,
Russ from Coral Springs, Fl, usa
To be honest I'm not sure how that works. hm..... just checked the source code - Cleanflight sends a 'change baud' instruction to the GPS module on all baud rates one after another. One of them has to succeed, after that they will both be using the desired baud rate.
ahh... there had to be a reason why there was a dropdown selection for the baudrates... so - you believe that the software only tries to GET the baud rate & doesn't SET any gps options? Is there a way of telling which "G" code line that CF looks for when it grabs the Lat/Long? are there any other lines. my guess is that it would be more beneficial to shut down the other data lines so that the CF would not have to read thru all the lines of data the GPS would (at default) be sending down the Tx line to the CF, and therefore having less lines to read, the processing time of obtaining the Lat/Long would then be shorter.
No, quite the opposite. The flight controller sets the baud rate and a bunch of other things too, the SBAS settings, the update rate, which messages to provide etc. If we are talking about the UBX protocol as covered in this video, it doesn't use any text string 'G' codes. Part of said settings is to disable those NMEA messages and use UBX binary messages instead (as at 22:24 in this video).
As for the setting of baud rate, my explanation before was perhaps a bit brief. Suppose you choose a baud rate of 57600 as your desired baud rate. When the FC starts up it will tell the GPS module "Let's talk at 57600 baud". But the FC doesn't know what baud rate the GPS is currently listening to, so it sends that message at 9600, then at 19200, then at 38400.... and so on, to cover all the possibilities. By the end of that process, it doesn't matter what baud rate the GPS was originally using because one of those messages will get through, so it will switch to using 57600 thereafter. This would be at github.com/cleanflight/cleanflight/blob/master/src/main/io/gps.c#L269
I'm on a bus, I apologize for any text errors. I now understand. The FC actually DOES send control codes. Codes are dependent on the type of GPS you select in the clean flight software or I have software.
yeah - that last remark did not finish up correctly - bumpy bus ride. so the bottom line is, it does no good to fool around with the Ublox because it will all be taken care of in iNav Flight. thanks. so now i'm moving on to your "tagging" videos. sleep tight.
Height abolve ellipsoid is height above the Mean Sea Level (MSL) model that does not account for gravity inconsistency (Geoid), not height above ground level (AGL). POSLLH - POSition Lat Long Height
One Arduino-specific issue, at least with presenting the Lat and Lon data, in 'human readable' form (on any model, apart from Due)... Arduino Uno float variables are strictly single-precision. That means, when you divide the values by (/10000000.0f) you aren't getting 1e-7 precision. If you watch the data stream by, you'll notice that the number will be static for long periods and then, the last 2-4 digits will all change together. Since the height is only divided by 1000, it doesn't appear to lose any precision.
For the inner workings of a multi-copter, best to work with the 'raw' long number and don't give up the 1e-7 precision lost in converting to single-precision floating point.
True, that is how a lot of the multirotor code (that I've seen at least) does it.
This was such a useful video, thanks. How good is the u-center software, after using that I think I'll be sticking to using u-blox as my go to GPS module, especially given the price :)
NOTuNOTme "how good" is a bit vague, but it lets you set any option available on any ublox module, there are many views available to see the data, and it doesn't crash... :) It's free and you could have it running on your computer in a few minutes to see for yourself. www.u-blox.com/en/evaluation-tools-a-software/u-center/u-center.html
***** Sorry, "how good" was supposed to be a rhetorical question like "how good was the rugby last night" haha.
They did a quality job on this application, right down to the field descriptions in the NMEA sentences. The best feature is they display the byte code for the command you've selected, that's so useful.
I'll get a NEO-7 next. Will be a cheap way for me to play around with GLONASS.
Thanks again for your great video.
Awesome awesome! You just saved us a whole lot of headache.
hai. i'm using gy-neo6mv2. i had problem when i attached it on arduino nano. there is no serial output result. but when i try it directly on u-center it's working. can you help me? i use ýour UBX_GPS_SS
thank you iforce2d
Thank you so much. Excellent video and information.
Yes - still watching :-) Many thanks, helpful and informative
nice! this will save me alot of time trying to figure this out.
Thank you, thank you, thank you!!! Excellent video. My most immediate concern has been getting an accurate time value from the GPS unit, accurate to the millisecond. The iTOW (Time Of Week) value would seem to do exactly what I need. I followed along, running the u-center program connected to my GPS unit and the iTOW values do indeed seem to be providing millisecond accuracy, with sequential values of 28.552 s
, 29.552 s, 30.552 s, 31.552 s, etc. So, exactly 1,000 milliseconds between each subsequent message.
HOWEVER, I notice that in your test setup in which your GPS unit has no antenna and is therefore showing no lat/long values, it nevertheless IS showing what look like valid iTOW values, AND every single one of the iTOW values ends with 00, incrementing by 100 each time, which corresponds to the once-every-tenth-second that you have set for its rate. But where is it actually getting those iTOW values if not from satellites? It looks very strange to me that your values are always coming in precisely on the tenth of a second, while my values (from a GPS that's definitely accessing satellites) happen to be coming in on the .552 second.
Are the iTOW values actually received from the satellites, or is it somehow just calculated and local to the GPS device?
I think it just gives some local value based on when it started up. Usually there is a tiny button cell battery used to store the ephemeris information for quicker startup, so perhaps it also stores the last time it saw and begins with that. Either way, just ignore all data until the 'fix' value is valid.
@@iforce2d Thank you for the quick response, even though this video is over six years old! :)
Thank you for sharing this. So often the library code uses too much the available memory of the Arduino. I will be using the code for my project. My challenge is to minimize memory usage and power consumption. I have GSM (SIM800L) , GPS (NEO-6M) , MOTION (gy9255), radio (NRF24L01) and weather (BME280) devices to manage with a single PRO MINI.
Thankyou. Very useful info. I think I might use NAV-SOL as it contains the GPSFIX info in it already...10hz is great.
Yes, I am still watching (even the 'Wrong Button' event).
Most useful - now all I have to do is to figure out how to make the changes stick to my NEO 6 and NEO 8 after power-off.
A better idea is to have your sketch tell the GPS what settings it should use, every time the sketch starts.
ua-cam.com/video/ylxwOg2pXrc/v-deo.html
You've helped me greatly
Dude, great video!
Thanks for sharing!!!
Nice tutorials, normally, I use GPS with Arduino for datalogger, also I use Laptop with U-blox for Lat and Long coordinating. Just a questions. Each time when I use GPS module, their time is in Greenwich Time Zone or 00:00 U.T.C which is 6 hours ahead of Central Time Zone -6:00. How do I change it from Greenwich Time Zone to Central Time Zone? Thank you.
By the way, Where can I buy Breadboard soldering PC board? The one you have are awesome!
Sry for the late reply but it seems to me that save and load the configuration refers to saving on the PC not the ublox.
Send is indeed the act of committing the config to the unit.
It can also be that the PC software could make a auto-commit, that is sending the configuration, to the unit on exit or the like. it's a matter of checking how the U-Centrer sotware exit warnings are alerting the user to sedn or save the changes made to the configuration.
Good amount of information. Thanks 👍
Great Job ! Do you think it's possible to do RTK using this kind, or similar, modification with the ucenter software ?
No. RTK requires different hardware, and a separate base station. ua-cam.com/video/n8PUyOtiGKo/v-deo.html
Thankyou so much for this video helped me a lot .
Thank you so much, this was incredibly helpful.
You got 10hz off a bro-6m?
That’s pretty awesome. I only went to 200ms for update. I never tried 100 for a 10hz. The manual said 5hz max so I figured it won’t go to 10hz but never tried.
I shal try and see if I can get close to 10hz which would be awesome.
Great video REALLY APPRECIATE THIS DETAIL
Great! Thank you for your explanation!
LOVED IT THANKYOU FOR DOING THIS INFORMATION
Amazing work sir, this information could be used for gps hold of a quadcopter ?, I'm currently using it but i dont have any good result. Have you ever implemented a position controll for a quadcopter any recomendation?
Great video! You might be able to make this code even smaller by filling up the buffer and looking for the sync word of "ub" and the message ID and laying the structure of the message over the buffer instead of iterating over each byte.
Not sure exactly how that would work. My method makes sure the bytes following 'ub' will always be at the beginning of the struct, and requires only the number of bytes that the message actually needs, and the message struct itself acts as the buffer. It sounds like your method would require a second buffer of at least as much memory as the message size, and would often find the 'ub' in the middle of the buffer. Of course it would work fine and might even be less lines of code, but seems a little less straight-forward.
Thanks for the great tutorial ! Like to ask one question. Is it possible to modify maximum altitude(which is 50 km for NEO-6) using u-center or programming.I hobbyist and doing high altitude ballooning ..
I don't know. But if you got that 50km number from the spec sheet of the Neo6 then I would think that is the limit of the Neo6 itself, not the firmware running on it.
Hello
First, thank you for all the work you’ve done in presenting this and the other very
informative videos on you youtube site.
I am not extremely proficient at C programming so I was a little confused by your use of
the indirection (*) and address (&) operators you have used in the Arduino
code associated with this video. In particular, there is the line of code:
if ( (fpos-2) < payloadSize )
((unsigned char*)(&posllh))[fpos-2] = c;
A couple of questions about this:
Is it technically “legal” or even a good idea to reference a structure in C (posllh) through
indexing ([fpos-2]) as if the structure were an array? I tried to read
a bit about this online and most of what I read said that this is not usually
permitted, but may/may not work. In your program, it is apparently working just as you would want it to.
Then I am confused about the * and then the address of & operator. Could you explain a bit about what is
actually happening here?
Finally, the quantities in the structure posllh that are > 1 byte are in “little endian”
format. I confess that I wrote my own version of this code --- reading in each transmitted byte into an array of
bytes. Then to get the correct quantities for lat and lon for example, I had to bit shift the bytes to take
into account the little endian format.
In your code, you do not seem to consider this formatting at all. Can you explain at all why you can basically
ignore the little endian formatting - does the structure posllh somehow take
this into account?
Thanks very much for your time. Richard S.
Most compilers don't really care about 'legal', if it's all memory within your program then it's yours to play with and there is no concept of 'permitted'. Sure you can treat a struct as if it were an array, as long as you know the positions within the struct/array where the data members will be. On a 32 bit operating system you have to be careful because the data members may not all be packed into the minimum number of bytes necessary, because 32 bit systems often place variables at 32 bit addresses for efficiency. In that case you would need to explicitly specify that the struct should be 'packed'.
en.wikipedia.org/wiki/Data_structure_alignment
www.catb.org/esr/structure-packing/
stackoverflow.com/questions/4306186/structure-padding-and-packing
The arduino is an 8 bit architecture so structs will always have their data members at single byte offsets, no packing is required.
The operation of * and & is explained ad-nauseum in so many C textbooks and blogs everywhere, I'll leave it to you to figure that out. It might help to break down the nasty looking parts into more steps, instead of putting it all in one line. Eg:
((unsigned char*)(&posllh))[fpos-2] = c;
is equivalent to:
NAV_POSLLH* structPtr = &posllh;
unsigned char* charPtr = (unsigned char*) structPtr;
charPtr[fpos-2] = c;
Actually I never considered the endian format issue, it just worked like this so I guess for the arduino system the format was already ok. Other platforms may do this differently, maybe the code you're talking about was not running on an arduino.
Really Nice Video, Do you have an example sketch using the Tiny++ Library, I am using a Neo-7M gps module and Wemos D1 mini Type ESP8266 Board. Not having ANY success with the TinyGPS++ library so far.
Thank you for your video. I saw your C94-M8P video as well, could I apply this set up to C94-M8P one as well?
Yes, almost everything applies similarly. I used this UBX method with no problems with the M8P. Keep in mind that the firmware versions differ slightly across some modules, and the size of message packets may vary. See the pinned comment in this video for an example: ua-cam.com/video/ylxwOg2pXrc/v-deo.html
Yes, I'm watching. Anyone else watching this in 2020?
loved this video! subscribed
Hello iforce2d!
what if the vcc and grnd pins appear as shorted out when checked with the multimeter. Not on the board but shorted out on the chip ? (ublox 6M) (GY-GPS6MV2). I bought a new one recently and plugged it with APM 2.8 flight controller. I think it did not work. I also tried the TinyGPS test library and received nothing from the GPS on Arduinomega 2560. Yes the Gps module was hot when plugged in to 5 volt . But later connected to the 3.3 volt option on arduinomega. Never did the GPS green light lit up and neither did i receive any information on serial monitor . Should i check using FTDI connector on ucenter or do u think the module shall not work ( as it might be damaged).
Looking forward to ur response!
To be honest I have no idea. Sounds like a faulty module.
Hey iforce2d and Muneeb,
I have the same Problem.my neo 6m module i got from ebay around 1 week
ago and i checked it with multimeter and i'm facing same problem.Shorted
and not getting anything.if you got any fix plz post it here,or contact
me.(imeshsps@gmail.com)
Thanks..
Thank you for a brilliant video, I have been experimenting with the NEO-6M gps module using your code with some success. I have noted however that the Lat and Lon values are only to two decimal places. My knowledge of C++ is very limited so my efforts to date have not been successful in increasing the number of decimal places.
Comparing the value from the NEO6 and a Garmin Etrex there is approx. 400mtrs difference.
Can you point me in the right direction please.
It sounds like you might be using arduino's Serial.print function to look at the values, and not specifying the number of decimal places, which defaults to two.
www.arduino.cc/reference/en/language/functions/communication/serial/print/
Hello @@iforce2d,
Thank you so much for the pointer I have modified my/your code to give 4 decimal places, the result is now more acceptable. My next step is to send the data to my OLED display. Thank you again for your help :)
@@iforce2d Hello again, I have been experimenting with the my NEO6M GPS and an 128x64 OLED display using the multi message sketch you have produced. Adding a display function I have been able to display LAT/LON, hMSL, vAcc and hAcc, from POSLLH onto my display with not issues. Then I tried to add gpsFix from message NAV_STATUS , Serial printing is ok I get a value say 3. I then created a second struct as you did for POSLLH for the STATUS message using this value (locData2.gpsFix) I get a value of 3 on my oled display, then it toggles to what appears to be an address which increments up to 255 then starts from 0 back up to 255. the curious thing is if I serial print (locData2.gpsFix) it will display the correct value say 3.
If I call the display function from the STATUS message only and don't include the POSLLH message I get the correct information on the display and the serial monitor.
This is bugging me any ideas!! . My other option is to use a NMEA sentence which has all the data I need, unfortunately my NEO6M wil not give me the PVT sentence.
Apologies for the essay.
hi, i followed your tutorial and it worked, thanks for sharing it! but i also was wondering, is it possible to also use a neo-m8n as a speedometer?
ua-cam.com/video/q4ZA6KtYGRg/v-deo.html
Note of caution, when you reverse power leads to m8n it becomes very very quiet with no magic smoke.
Thank you for showing me how to use u-center. Do you please have a link for the data sheet? I may now be able to change output time using u-center from UTC to local time (NZ). Lowering the rate caused writing to an SD Card to fail- I am using NMEA, not UBX, Arduino UNO and an SD card shield. Writing to a .CSV file - date / time, lat, lon and altitude.
Many thanks.
pretty sure you can get the datasheet by googling "ubx protocol". Changing the time is just a matter of adding a few hours isn't it... not sure you would really need u-center to do that if you are reading in the values into your own program. You mean increasing the rate? Not sure why lowering it would be a problem.... if you're gonna write values to a file and throughput is an issue, you might want to write these binary values to the file instead of .csv, which would be more efficient.
*****
Yes, sorry increasing the rate. Adding a few hours is probably the easiest but I dont want to do this adjustment in the sketch as I need to keep code as tight as possible. Getting corrected local time straight from the GPS would be ideal. Found the PDF - there are predefined datums I should be able to use. Thanks again.
Very useful information man
I will need to watch this several times, my question is what ublox module do you recommend for mapping recording and playback path
do we really need an ftdi adapter to program gps module or can we upload arduino a blank code and make connection vcc , rx ,tx , gnd and do the gps module update ?
Great video. Thank you very much!
Can you provide some more information regarding the USB device that allowed you to plug the GPS module into the computer?
Search for "usb serial adapter", should be a few dollars on most online retailers.
www.aliexpress.com/item/2019244368.html
Great video. I am programming an arduino UNO and Mega 2560 to get GPS out of a BN-220 GPS and save it to sd card. The sketch works find but is not working on a pro mini or nano because its too big. Now I found this video and will try to use UBX protocol instead of NMEA and make it work on a Arduino NANO. The plan is fly around with my rc glider. GPS receiver in the glider sends data to ARduino and then Arduino sends it to X8R receiver and gps data is shown on my FRSKY Taranis X9D transmitterscreen and maybe also stored on the sd card of the TAranis. I already reconfigured the BN-220 wit Ucenter. I also noticed it doesnt always store the settings. If it works I will make a video. I also want to check OpenXsenser, maybe they have a sketch for this.
Changing the settings and storing them permanently are two different steps. After you have confirmed the module is outputting the messages you want, you can do Receiver > Action > Save Config. Otherwise the settings will revert to what they were before, after a power cycle.
@@iforce2d i just found out that I can connect my BN-220 gps to my OpenXsensor Vario I made. Its a matter of activating it in the sketch and it must work after alter some bitrate settings maybe. Thanks for your advice.
Great video btw, do you have any videos that talk about how we can setup 2 RTK receivers using Arduino? To get cm level precision?
ublox has the M8P evaluation kit, two receivers with antennas etc. which basically comes all set up and ready. Costs $400 though :)
thank you! I guess there's no way to combine their cheaper receivers to do the same thing right?
nope
got it, thank you for the confirmation
love the video bad is it posebel two do this with the speed also and then let the speed valeu control how fast a few leds are blinking ?