arduino gps speedometer
What this is so this big old mess of stuff here is actually functioning as a GPS tracker, so there’s two parts to it. You just have to read in the current location using the GPS, and then you use the sim module or the some module to send that to a web server. So I guess there’s three parts to it really isn’t that there’s a web server as well and then you can look at it afterwards and see the recorded journey that you took so it’s it’s running here at the moment, so I’ll just there’s quite a lot to Look at really but let’s start off just by looking at this little screen here I found that I really had to add a screen on because there’s quite a lot going on and if you don’t have some immediate feedback as to what it’s doing it’s it’s. Just a nightmare to figure out what’s going on and the way I’m working the way I’m getting this input is I’m using software serial to talk to the GSM module or the sim module. When I say GSM module eight, I mean the sim module so I’m sort of used those names interchangeably, so that’s running on software serial and then I also want to talk to the GPS. But I found that you can’t really do two software serials at least not very quickly and not very successfully, so I ended up using pins 0 and 1, which is just the normal hardware serial of the Arduino to talk to the GPS.
But that means that you can’t use the serial monitor to display any debug info, so that’s why this screen became all the more important. I also tried this on an Arduino mega 256 0, which has two hardware serial ports, and that made things a lot easier. So if anybody wants to try this, you might find it a lot easier to do it with it Arduino mega instead of the ordinary Arduino Uno, but anyway back to the story. So in the very top left there is a little spinner character that just turns around and around and it it’s just to. Let us see that the program hasn’t crashed and it hasn’t just you know frozen. So we want to make sure that something’s happening. Sv5 means that there are five satellites currently locked. The 200 to the right of that in brackets is the HTTP request status. That was returned last time. We did a request to the server and we want to see that as 200, because that means it’s a successful request and the reason it goes to zero every now and then like that. That means it’s that there’s a HTTP request currently in progress. So it sets it to zero to. Let us see that it’s doing a request, and you also notice that the other stuff pauses for a bit while it’s doing that not really so. This was another very important thing. You want to see whether your requests are getting through to the server successfully or not, and if they’re not you want to see what the HTTP requests error status was.
So sometimes it comes back saying 504, which means stack busy, which means that you’ve tried to start another request. While it was already a request in progress and I’ve, also seen a 604 and a 601, which are something to do with, I think, was one one is where you’re not signed on to the Internet network probably properly in your mobile cellular provider and the other one Was just sort of a more general area that I never really figured out, but I haven’t seen it much okay, so just below that we have the latitude and longitude and those numbers directly read from the GPS, and you divide those by a million. I think to get numbers and degrees and just below that we have HACC, which is horizontal accuracy, that is a measurement in millimeters yeah, so it’s, like 14 meters at the moment, 15 meters, so it’s not very accurate where we’re indoors, and we only have three satellites. The next one is ground, speed, that’s, a number and millimeters as well so that’s about half a meter per second, which I was obviously incorrect and just below that we have. It looks like aid, but it’s actually hid and it’s the heading and that’s in degrees. Multiplied by ten thousand, a hundred thousand sorry so at the moment, it’s reading, three hundred and twelve degrees and that’s also wrong, because we’re not really moving. So this the screen. This is the Nokia five one one zero screen, and this turned out to be very, very good screen because it runs on SPI and has quite a fast update rate and it doesn’t seem to use a whole lot of memory.
I also tried with one of those little tiny, 128 by 64 pixel LED screens, but the amount of memory that it uses. I think just just smashed all the program that was trying to run other stuff, so it it just was untenable. You couldn’t, you couldn’t, have that screen working with the amount of memory that this program is using right. So, on the other side of this we have a web server, and this is the oh just got one literally see if we can see we can catch this in the act. I have to put that on top, so there we go alright, so we just that went to zero there. Maybe you just caught it. Hopefully you just saw that, but you can see that we’ve just sent the information here. So five satellites fixes 3 3, meaning proper 3d fix, and then we have the latlong and those other variables that I just mentioned, and over to the right here. There’S one other variable that it’s sending that is a 10 character journey code I’m, calling it a journey code and we’ll see what that is all about when we look at the source code in a minute, but to look at the final output that we get from This because that’s, probably what you’re interested in right off the bat. So this is a Google map displayed in the web browser and we can mouse over these points and see all of that information and the ground.
Speed. I’Ve converted to kmh here, of course, because that’s a bit more sensible than looking at it in millimeters per second or millimeters per second. So you can see. I was driving at 47 kilometres an hour horizontal accuracy of 1.3 meters on the 23rd of February. At 7 minutes past 500 in the evening with 8 satellites, so each one of these points has all of that data recorded for it and because it’s doing it every 10 seconds it’s. You don’t see nice smooth lines. So obviously I didn’t drive through these people’s back out. I drove around the corner, but occasionally it looks like it’s cutting off or going strange, but each each one of these individual points are in the heading. You can see there from the arrow each one of these points should be accurate, so it’s only the lines and between them that are not accurate all right. Hopefully that makes sense. So you can see I drove around there back over there around there and sometimes from the frequency of these arrows. You can get an idea of how fast I was going so zoom 40 there and then we’ve got more arrows here. So obviously it’s a bit slow and yet 18 kilometres an hour there, and here it looks like I stopped at this shop it’s a supermarket. I think, and you can sort of roughly see where I parked. I think I parked in this one, but over a while let’s see how long was I in the supermarket for seventeen fifteen to seventeen.
Forty four about half an hour or so I was in the supermarket. The blue circle is the accuracy horizontal accuracy so it’s. One point three meters there: some of these other ones look a little bit bigger 1.8 meters, it’s, interesting that when you’re moving faster, that accuracy seems to get better, I would have thought it would be the other way around, but no, it actually gets better when you’re Moving faster, so let’s have a look at some photos that I took, or some screenshots of some other journeys. So what I’m calling as a journey is each time I come home, I’ll change that 10 character code, so that I can differentiate each trip that I’ve been out somewhere. So this is another trip and you can see now you can see. I just drove around town a bit and I guess it’ll be more interesting for you to look at your own ones. If you make some, but this is another town one, and what do we do? This is the one that we just looked at. I think, okay, this. This is a little bit more out in the country and you can see that we get pretty steady measurements, so the arrows here are fairly equal distances apart and most of this was open road, so I was doing but probably hundred kilometres an hour along there. This road here you can see it’s a little bit slower arrows are a bit closer together, but there’s nothing missed out much now this part here I was a little bit disappointed to see some big gaps in the recordings so I’m.
Talking about these big long straight lines, you can see it’s jumped. That is not 10 seconds. I didn’t get from there to there in 10 seconds. Neither did I get from there to there in 10 seconds, but it’s interesting that they’re in the same place roughly. So I recorded I’ve been at this for a bit later, probably a month for most now, and I recorded a few more so take a look at that and then take a look at that there’s, more gaps and there’s a huge gap and there’s. Even this problem is even worse down there as well, and then there’s more gaps and they’re all in the same place and either side of that gap, we’re getting generally fairly good readings, there’s a little bit more. That was probably the best day, but we still got some long long, ish gaps in that middle section, and then we have something terrible on that occasion and what I’m guessing here is so this is this is the area there, so you can see right right about There we get some missing gaps and in this other area that I just mentioned down, there is even worse. So what I’m theorize is is it’s just simply a lack of the cell cellular coverage, because this is quite a rural area, as you can see from those other maps so I’m, just guessing that just just not cellphone, not enough cell phone coverage there to report the Location, what else do we have? Okay? On this occasion I pulled into the gas station and I parked under this roof, so I was actually under the roof here, see that car there I was probably about there.
Well, there may be, and you can see that the you get less satellites actually is it less Settlements? Oh, this is a screenshot, so I can’t see all the satellites work, but you can generally see that when you’re getting wider circles the be accuracy is is lower, and this is another situation here seems to drift quite a bit when you’re parked. But you can see here, this is supposed to be all in one spot. So is that what else we got – and this is probably the worst of the parked cases where the accuracy dropped quite a lot, so you can see here. Not only has the accuracy dropped, so this is where I’m supposed to be the XE is dropped, but it’s also moved way way over there as well. So no none of these large blue circle readings are very accurate and I’m, not really sure. Why? Because I wasn’t really parked under a roof or anything, so I guess just occasionally it’s likes to be inaccurate right. What else do we have? Okay, so this is. This was saying about very accurate in the FASTA section, so this is a section of road that’s, nice long and straight, and I was doing 100 kilometers now along here both ways and in this situation accuracy was always very good and I mean it’s so so good That these two lines look almost like perfectly parallel lines, because it’s clearly placing me on one side of the road there and the other side of the road there.
The lines don’t exactly match up perfectly with the map underneath it, but they do match up perfectly with the other line, which is really nice to see so yeah faster speeds generally gave better or better at horizontal accuracy, results in more photos. Okay, I think it’s all the photos I had to look at so now. We need to look at the source code right so, like I say this is something I’ve been working towards for a while now and in my other videos in the last couple of months. I’Ve described or explained a lot of the code that’s gone into this, so we have some tabs here. So I’ll just explain these other tabs first. In fact, it’s not really much to explain the the offset tab is just putting a little offset to so that I don’t show my exact location on YouTube, because I don’t want any of those hot swimsuit models. Stalking me anymore, so that GSM is all it starts. Gps losses let’s just save that right, so the GPS, stuff I’ve done quite a few videos on this now, so I won’t describe it in too much detail, but I’ll just point out a couple of little changes that I’ve made from previous videos that I’ve done the First is that I’m using the nav pvt message, whereas previously I was using their posts llh or something like that and I’m using this one, because it has the fixed type, and it also has the ground speed and hitting somewhere other.
So it has quite a lot of useful information and it also gives us a nice year month, day hour minute second time so that’s the message that I’m using and as well as that I’m also keeping a separate structure to copy some parts of that nav pvt Structure into so these are just the things that I’m interested in keeping and giving to the server, and we need to keep a separate copy of that because, when we read in bytes from the GPS, we’re continuously overwriting those bytes or writing those bytes into the structure. So there’s only one point in the program and that’s here. This is the only point in the program where we can be guaranteed that we have a fully intact GPS message or packet or structure the nav pvt thing. So at this point here we need to just copy all of those member variables that we want to look at into a second structure so that we can use that structure knowing that it’s not going to get over it and the next time we read a byte From the GPS, so I think that’s all I did there. It was different, yes, all right so for GSM or the the sim module. This is all pretty much the same as I’ve had it in my previous videos, with the exception of HTTP result this variable here. I added that and keeping this as a global variable and then, when we read the response back from this server, we set it here like this, HTTP result equals, and then we just look at the number that it gave back to us at that point.
So this is where I’m getting the number 200 from that we saw on the screen before, and I haven’t really bothered to look at this before, but in this for the sketch it is very important so I’m doing that there. I think everything else is unchanged. One thing in here I just noticed when I was looking at this before making the video when we get the response back from the server and before we were in one of my previous videos. We were looking at this to check up check some content that we got back from the web server as the sketch stands or as this little GPS tracker thing stands at the moment. We don’t need to look at the content that the server gave back to us. We’Re, just ignoring it so this thing here where we read what the server told us is actually unnecessary, but I’m just leaving it in there, because everything was working and I didn’t want to mess it up and it could be useful in the future. So that’s all there is to look at for that now this page here, gsm, gps tracker is obviously new. Why is it not saved okay? So this is where we’re going to have to have a little bit more in depth. Explanation so the beginning of this file. We define a 10 character string to use as the journey ID, so this is just a string that you can choose randomly just choose 10 characters, it doesn’t matter what they are and I’ve put a.
If anybody wants to use this, you can use my server and all that stuff that’s one yeah so like I say it doesn’t really matter, but if you want to make sure that you’re not going to use anybody else’s journey ID, you can use this URL here And just change the last bit at the end to the journey ID that you want to use and it will tell you whether that is available at the moment or not. So you have to check that. If you want to be polite I guess oops all right. So that’s the journey ID this stuff here, I’ve included for the screen and at the top here, I’ve defined use screen. So if you comment out this line at the top, none of the screen stuff will come into play. So you might just not want to have a screen not recommended. Probably we might want to use your your own screen. In that case, you, wherever, where we have this used screen stuff, you can have to put in your own code to use a different screen type, and then I just have some setup for the nokia five 10 screen and at this point here, there’s a couple of Things you can do. You can choose these two things here. If you want to run it on a mega two five six zero and that will let you use serial port 2 on those pins to do some. Debug output.
That’S right go for the GPS and debug Syria we’ll go on to the normal serial port. Now, if you’re using a mega three to eight like an Arduino Uno, you would have to have these ones and actually we’ve been nicer. If we commented one of them out wouldn’t it just to be clear about what we’re doing doesn’t really matter, but that would be a nicer way to have it for readability. So in this case we have to use. We only have one hardware serial so we’re using that from the GPS and a undefined debug serial debug serial just prints out some stuff in, for example. Here we have this if def debug serial that would just print out something about what the GSM module is doing and stuff. But we we can’t do that if we’re using the GPS on this serial connection so that’s, why I have this undef and everywhere I’m using serial. I have this if def checking around it right, so you’ll choose either that or that, depending on which board type you’re using and up here. I guess this is not really necessary but to find us import gsm. Actually, I think you can ignore that, because I’ve kind of forgotten that was there and I’m, not really paying nor really using it, but oh yeah. I guess this is what it’s, for so you could also direct your software serial. What are you using your whatever port you’re, using to talk to the GSM module? You could change that here, it’s, probably not very clear, but if, if anybody’s following this so far, hopefully they’ll be clear to you what this is doing.
So this is going to become GSM, so software serial is going to be when the program is compiled. It’S going to do it’s going to do that. So then we can see later on. We are using, for example, GSM using that GSM variable to print stuff out to the GSM module um oops. No, where was I all right? So now we have a big bunch of bytes here, and I also covered this in one of my videos quite recently, and the point of this is to give some instructions to the GPS module about what kind of messages we want to get from it. And here we’re saying we don’t want any of the text based NMEA messages and then we just force to be sensible. We disable those ubx ones and then we enable just one of them and it saves. I know it seems a little bit unnecessary but, as I’ve talked to occasions now, I’ve wasted over an hour, because I forgot that I had one of these other messages turned on and my GPS module so to be sure about it. I turn them all off. At least the ones that I’ve been playing around with, and then I turn just the ones that I want on and then we also say this is probably not necessary. Considering that we’re only updating the we’re only sending results to the server every 10 seconds, but just for fun, I’ve made it made the GPS give us results every tenth, every fifth of a second which gives us some nice fast updating display on the screen here.
Just nicer to look at really and then okay, so this this bunch of bytes here we’re, going to send that to the GPS at the start of the program and speaking of start of the program here it is so we have 9600 board on both the GPS And the sim module and if we’re running on in on a mega, we can also have a third one, a third port for serial, monitor debugging on 9600 as well. And then we draw something on the screen just to say: we’re starting and wait a bit, and then we send that stuff to the GPS module to tell it what kind of messages we want to see print something else to the screen. Wait 10 seconds for the GSM module to connect to the mobile network. This is quite important. I’Ve never seen it take more than about five seconds, but I thought I’d give 10 seconds just to be safe and then we need to set up the GSM module to say which access point access provider in what does the N network access provider network? Maybe that we want to use – and I looked at this in one of my previous videos as well – I’ll – try and put a link in the description to the previous videos that are relevant for this stuff. Then we print something to the screen again and then at this point we call process GPS just so that the first time we display something on the screen we can, instead of displaying, displaying all zeros, which is what we’ll have at this point.
We can display the actual values that are there. We got that that are currently no one by the GPS, all right and then we say done and clear the display, and then we go into the the loop function now. There’S, a helper function here called flush GSM and all that does is reading whatever bytes the GSM module has currently given us and processed them, and I found this to be very, very important as we’ll see a little bit further down the page. We really need to get everything out of that buffer as quick as we can, so that we don’t miss anything so that’s that’s. What this is going to do. Let me just have some characters for the spinner, so this is zero is just keeping track of which position we are in here. We just cycle around to make that bar look like it’s spinning in the upper left of the screen and then in the loop function. We check the GPS and if we are in the action state idle, which means we are not currently sending a message to the server, then we check if we have a valid fixed type. And if we haven’t sent a message for 10 seconds and if that’s the case, then we come in here and we in the message to this URL, and so you can see all the parameters here. Jn is short for journey. Tm is short for time and we just append all of those time member variables the Year month and day and everything into one parameter.
So I guess it’s pretty obvious what’s going on here. If you are familiar with URLs there’s, a bunch of parameters that we’re giving and then we we do one, so this is here again we’re trying to get something from the GPS and then another thing is that we also need to do that. For the G. Sorry, the GSM, I meant to say that we also need to process messages out of the GPS as quickly as we can to so. We can’t leave either neither the GPS or the GSM alone for any length of time. We have to quickly process whatever they give us so that’s why we have processed GPS in here process, GPS again after that, so this I think maybe this takes a little bit of time. I can’t remember: maybe that takes a little bit of time and in that time we need to quickly catch up with what the GPS was doing right and then we set the action state to waiting for a response. So if that, if statement was not true, it means that we are currently waiting for a response from the server. So we’ve already sent a GPS location and we’re just waiting to get the server’s reply, and I found that sometimes the server can’t reply or the internet connections bad or the cell cellular area is weak. Like we saw in the maps that response will never come so in that case we have to give it a timeout, in this case I’m waiting 15 seconds, and if we don’t get a response within 15 seconds, we just reset everything back to the beginning state.
So we say action status, idle path, stators that and then reset the buffer. So these these things are normally done in the GSM tab there, but we’re just sort of doing them here as a once off thing, occasionally, if it’s necessary right and that. So if you don’t have a screen that’s about all, you need to do and we just flush the GSM and update some timing state if you do have a screen. Every half a second, so that’s, 500 milliseconds I’m doing the stuff here clear, display plus GSM. Now look how many flush GSM is I had to put in here to get this to work. First, you see and flush GSM plus to use him so basically, after every couple of writes to the display to the screen I’m catching up with whatever the GSM module was doing just to make absolute sure we don’t miss anything. So all this is doing here is putting the display on the little Nokia screen that we saw right at the beginning of the video and saban it there. We go so um here. So if you want to use this, you can by all means help yourself to with a gun so that’s. The URL you’ll need GT standing for GPS tracker and then these are the parameters that you’ll need to give it and to look at those parameters. You can use a URL like this. Once again, we didn’t prepare this obviously just grab.
That so say you wanted that it was your journey ID that you wanted to look up. You would use this URL. I suppose I should put this in the link in the description as well. So this is the kind of URL that you’ll need to access. This page here with your tracker results on it so it’s I Force to Dean, it GT index.php and then again we have JN, which is short for journey and then you’ll put your duty ID there, the ten characters and then TZ is a time zone, and this Is your offset from UTC or Greenwich Mean Time and in New Zealand we are plus thirteen from Greenwich Mean Time so that’s. Why I have a thirteen there, so you could make it. You know minus nine or no yeah, whatever, whatever you need to put for your time zone. That’Ll just change these. When you do this mouse over on each of these data points, it will change the displayed time there to your local time, just to be a little bit more useful, so that’s timezone offset means so let’s, say you’ve recorded five hundred points in your journey. Offset will let you start the display from not from the beginning, but for in this case, from the hundredths point, so I found I’ve got a lot of a lot of garbage at the beginning before I before the GPS got a lock. So in that case, I only wanted to start from about the fifteenth or the twentieth point most of the time when I’m, looking at my results so that’s, what OS is offset and lt is limit, so it’s a little bit like offset but it’s, for example, offset Equals 100 and limit 150 means that we would start from point 100 and we would go up to point 250, so the last point would be well.
This is the number of points you want to look at. Think of it that way, so that just lets you define a range of points in your journey to look at, and I guess that’s about all I wanted to cover for this video, so this little tray that I have it sitting on here. This is actually a rubber like a thick wetsuit kind of material, and I just put it on here with some sticky double sided tape on the bottom and stuck it on my dashboard, and the idea of this was to reduce the vibration that had got what it Was sitting there and also to stop it sliding off onto the floor and I’m running it from a little 3 s? Lipo, oh and one other thing i didn’t mention here – is that there’s a little voltage regulator on there? Well, not not really that little compared to what I usually use, but this voltage regulator is capable of 5 amps. I think because the GSM module apparently can pull 2 amps when it’s in full, full on transmit mode or whatever it does. But I figured that, while I was told that you can’t really run it from the Arduino. The reason why I ran it successfully through that Arduino before I think was because it was running on USB power and it wasn’t actually using the voltage regulator that’s on this Arduino, but the voltage regulator that’s on there is not not capable of pushing out 2 amps When it’s converting it down from a 3 s battery or whatever so anyway, this was just to make sure that the there was enough power for everything to run so yeah.
I just put it on my dashboard and drove around and that’s that’s what I got so I’m, not sure what I’ll do from here on. It would be nice to make it tidy R. You know make the whole thing you know about sort of about that. Big. Would be nice, but I don’t know if I can be bothered it’s, just more really the challenge of making it for me: that’s that’s the attraction and seeing what kind of results we can get anyway.
arduino gps speedometer Video
arduino gps speedometer news
Posted on Thursday April 25, 2019This GPS Speedometer Hangs Off Your Handlebars Hackaday … Continue Reading »
Posted on Tuesday June 28, 2016Analog Guts Display GPS Velocity In This Hybrid Speedometer Hackaday … Continue Reading »
Posted on Thursday March 09, 2017Arduino + Geometry + Bicycle = Speedometer Hackaday … Continue Reading »
arduino gps speedometer Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr
Originally posted 2016-08-18 06:47:10.