This is yet another of the cool things that you can do with an Arduino suppose you had a switch or a sensor of some kind, and you have that somewhere in the world anywhere in the world, and you want to be notified with a text message to Your cell phone, when that switch or sensor has been well let’s, call it a switch because that’s what I’m going to do here and you want to know when that switch, has been turned off or on. Well, you can do that with a GSM module like that, and you can do a lot more interesting things besides just switches being turned off and on stuff, but we’ll. Look at that as a simple case to start with. So this is going to be my switch and it’s just a wire connected to pin 2 of this Arduino and when I plug this into the ground or the other end of it into the ground. That’S going to represent the switch being turned off yeah off because it’s going to go to going to be pulled low, so I’ll keep both of my hands in the shot here so that you can see I’m not doing anything tricky like sending a text message with Another cell phone in the background – and it takes a few seconds but we’ll see switch – was turned off and I was a little bit hard to see. Maybe that switch was turned off and we can see what what time it was done and then yeah so just to go the other way.
We’Ll unplug the switch – and this should say switch was turned on in a moment. There we go so let’s have a look at what this thing is and how you can set it up and use it to do this and a few other more interesting things as well. There are a variety of these modules around, but this particular one came from IC station and have to say a big thank you to IC station because they actually provided this one to me free of charge for review, slash promotion. You know how does and what we’re. Looking at here is a search on IC station. I just searched by GSM, so you can see that they have a bunch of other modules there as well, and this one that we’re going to look at is the top left one on the list there and to the cheapest one. As you can see – and I think this icon means that it’s an icy station branded one so it’s only one in the list that’s there and it probably helps them to make it a little bit cheaper, perhaps but to be fair, it’s lacking a few of the Features that these other more pricey ones have, and you can see that some of them like it’s a little bit small to see, but they actually have an audio jack for headphones and microphones on there. So you can do voice calls as well. Somehow, I think, I’m not sure if you can do that with Arduino what or what what you would use it for, but this one doesn’t have that feature and it does have an antenna, though, actually saw another module similar to this, but even more basic on banggood.
A little bit cheaper, but it didn’t have an antenna connection and it didn’t even have any pins of any kind. So you, if you got that one you’d, be stuck with some tricky soldiering to get it up and running. So I think this this one is a pretty good middle of the road. If all you’re doing is Arduino programs, so you’re not going to be using this audio stuff, and yet you don’t have to do any awkward, soldering or you don’t have to figure out how to attach an antenna, and the price is pretty good. So let’s have a closer look at this one, and I just noticed before that this, the special price of 25 is actually only going to be valid for another day. So, probably by the time you watch this video it’s going to go back to the normal price of 29, and the other thing I like about this is it’s, not a shield. So some of these other ones like this one here is pretty cheap as well. It’S. Only thirty or thirty five dollars after the special finishes, but this is a shield, so I’m, not a big fan of shields in general, and this one’s for Raspberry Pi anyway, which I don’t have. So I like it that it’s a little bit more modular or a little bit more independent of any particular Arduino form format, form factor. So what is it it’s? A four frequency capable gsmgprs transmitter receiver.
I guess you could say pretty small, only 24 millimeters each side. Oh that’s, not right. Sorry. What we’re talking about here is the the actual chip that’s on the by the looks of it. So this thing is only 24 millimeters yeah look wouldn’t, my browser go there. So I guess you can just look at the page here and I guess read it yourself, but I will draw your attention to one thing that can be quite important and that is power supply current more than one amp and apparently during transmission. These things can use up to two amps of current, so you really need to have a fairly capable power supply to run them with, but for now, as you can see, I’ve managed to get away with just powering it directly from the 5 volt pen of the Arduino Uno and that, actually, I have not tried it with the this external power connection. Here it seems to be ok with USB I’ve read some things on the net where people say it works great with USB, but soon as they take the USB away and they try and power it with this one. Then they run into problems and I suspect that’s, because when you power it through here you’re using this voltage regulator here, which is a bit of a Wimpy one. And I guess that probably cannot provide the full two amps that are required when you’re doing transmission. So let’s have a look at the physical side of getting this running physical connections that is there’s really only three wires apart from power wires that are actually needed.
So this little white plug and the base there just by the antenna is the power and you’re going to have the aforementioned 5 volts 2 amps coming in through there, and the only other wise that you need are a ground and an Rx and a TX. So you do all of your communication over the UART style connection and that’s it. So I took took me a long time to get this running at the beginning, because I saw this here and I thought well ground, rx TX. You would think that you, just you, know plug your wires on there wouldn’t you. You would think that you silly duffer but that’s. Not what you do. You need to use these other plugs over here and I’ll just jump over to the description page, where, instead of trying to get my camera to focus on that plug section, I’ll just show you what they are here. So this little bit here, that’s the white power plug and just above that you can see there’s actually six pins there, so they haven’t really drawn it here. Oh I’ll put a little line over here in the video to show you what I mean is actually six pins there and they’re laid out in this arrangement this fashion this this layout there. So it says: if you are using 3.3 volt interface, do we know, then you can use the 3v ones at the top. Otherwise, as in my case I’m using a 5 volt ID, we know so I’m using the 2 in the middle.
So that is OVR is the receiving pin and then ovt is the transmitting pin. So then so the t would go to the Eric’s on your Arduino and then the only other one that you need is ground. So maybe we should have a look at that, but it’s probably not going to focus as it is going to focus for us. Oh here we go so the two pins at the top are unused. Then the two in the middle are Rx and TX and then the one on the bottom or hard to see there. But the one on the left and the base is ground and over here these are going to ground and then I’m using pins, seven and eight, because I have a software serial connection setup to use, pin 7 and 8 there. But we’ll have a look at that. A little bit later on in the code and, of course, another thing that you’re going to need is a SIM card. Fortunately, here in New Zealand, they are pretty easy to get. You can just get them for five dollars over the counter. You just walk into a Vodafone shop. You can walk out probably two minutes later with one in your pocket and brute cheap and a twenty dollar carry over prepay will get you 500 megabytes of data per month. What you got to keep paying every month, unfortunately, but you don’t, need to have a data plan to do the SMS that we just saw before.
But you will need a data plan if you want to do HTTP connections like looking at web sites and web pages, and so on. So another thing I should mention is that depends. It may depend what country you’re on and what cellular provider you’re using as to whether this is even going to show up on the network when you plug it in and turn it on anyway, because I actually had this given to me way back in September. Of last year before I left Japan – and I tried it there and it didn’t work and apparently there’s a serial number on here IMEI number and if that number is not one of the recognized ones that they’ve. Basically, if it’s, not one of the phones that they’ve sold, you they’re not going to allow it to connect to their network, and I talked to the AU people in Japan and they they just didn’t want to have any of it. So if you heard living in Japan – and you want to try this forget it forget it – it ain’t going to happen. But, like I say in New Zealand, a lot of other countries, it’s really quite easy, and there may actually be depending on what SIM card you get again. Listen didn’t happen didn’t happen to me in New Zealand, but some cards can have a password on them. So you may need to unlock that somehow, and I think you’ll need to put that into your cell phone and unlock that with you using a cell phone.
I didn’t have to do that, so I can’t really help you with the procedure for that. Unfortunately, but I think at least, if you’re in Australia, New Zealand you’re not going to have any issues with a Vodafone SIM card, okay, let’s have a look at what happens when we power this up, because there’s a little LED here. That gives us some information and we can use that to figure out if we should start writing some software yet or what, if we just haven’t made any connection to the network at all, so I’ve disconnected the SIM card and we’ll have a look at what it Looks like what happens when we fail to make a connection so plug that in and LED comes on for a bit, and then we get a fast flash which is about one second, maybe a little bit less than one second, and if it just stays like that. That means you have not established a connection to the mobile network, so just unplug that and I’ll put the SIM card in close. That let’s have a look at what happens when we do establish a connection. We get the fast flash again at the beginning for a little bit and then it sort of pauses and then we have a slow flash and the slow flash is about three seconds between flashes. So if you see that slow flash, you should be good to go. So from here we can start to look at the software side of it and try communicating with it, but I should mention also that you don’t actually need an Arduino like I’m using here to to talk to this module.
You can also communicate with it directly using and if two di adapter like one of these ones here and plug your Rx and TX into those connections there you can see the Marik’s and TX and ground. So again, you just need the three wires are x, TX and ground on these to talk to them directly. The reason I’m not using these is because I’m eventually going to be using that we know to do something like I was doing with the switches before anyway, and also because I wanted to use the Arduino IDE serial monitor to do the communication and so I’m going To program the Arduino to just pass the serial monitor stuff through to this module, and this module will show us on the serial, monitor what it’s sending back to the Arduino. But I should mention, of course, that you can just you can just do that with one of these depends what the software is you’re using if you’re using Windows, you can use putty or teraterm, and you can connect to one of these when you plug it in It should show up as a comport and then you should be able to talk to the module directly, so you don’t need to now do we know for this, but course, since we’re going to be programming the Arduino later that’s, what I have set up? Okay. So this is the Arduino sketch that I’m using to start with – and this is just going to – let me type a command to the GSM module and have the GSM module returner bonds.
To me now, like I said, if you, if you’re using an FTD, I adapt, but you don’t need to have this program. You don’t need don’t need to have an Arduino at all, but this is necessary if you’re going to do it with an Arduino and all it is really is a serial relay. The Arduino will patch, as a fancy word azide pass. I guess I got this off. The net somewhere and it will just pass that message through and whatever the GSM shield says it will pass back to us. So in the setup function we just do a begin on each of those think. Well sorry, let me go back up here. We have a software serial port and we’re, calling that GPRS and it’s on pins, seven and eight so that’s. Why? I had the pen seven and eight connected to the GSM module before and we have a buffer to store some incoming text and account of how much is in there and in a setup function. We begin each of those serial connections at the baud rate of 96 bits per second 9600 bits per second, and then the loop function is just this. All it does is checks that there is something available coming in from the GSM module and if there is it reads it into a buffer and then it writes it out to the serial, monitor and then clears the buffer. And if we have typed something into the serial monitor to send to the GSM module it’s going to check if that’s there and it’s going to read in what we’ve typed and then well, essentially it’s going to just write that out to the GSM module directly.
Now I have a little if statement here that says if one of the characters that I’ve typed in is an asterisk instead of writing an asterisk to the GSM module we’re going to write this byte here, hexadecimal 1a and this corresponds to a control, Z or control. Z, if you like key press on the keyboard, so don’t worry about that yet, but just keep in mind that every time we put an asterisk into the serial monitor it’s not going to send that directly it’s going to send a control, Z, key press. So we’ll get to that a little bit later, but if I just upload that to my Arduino and open the serial monitor oops so here let me just sort of arrange this a bit better, so you can see okay there we go on the right hand, side I’Ve opened up a web page, which I found to be very helpful when I was doing this, because I wanted to do everything step by step manually before I tried to program the Arduino to do it and I’ll put a link in the description to this page And we’re going to look at the first of their tutorials how to send SMS messages using 80 commands. So if I just click on that, we’ll see a page which lets us know what to do in the commands for doing this. So let’s just have a look at 80 commands in general, and the most basic command is just the command 80 what’s.
It stand for I’ve, never really even thought about it till just now. But anyway, if we send that by hitting Enter or clicking sin there, we will see the GSM module will return to us. Usually, it returns something along the lines of what you just typed, and then it will give you a status for the succeed, successful failure of that command as well. So what you want to see at this point is just 80. Okay, if that doesn’t work, you may have to change the line ending type selection at the bottom of the the serial monitor window. So there’s a few different. You probably can’t, see this but let’s do this, so you can select some options there and you’ll have to. I found that I had to choose both new line and carriage return to get this to work properly and, of course, has to be 9600 board as well. So if the 80 command like that does not work, you may find that if you just do a whole bunch of A’s with the T at the end like that, that should also work and maybe a little bit more successful. Though I find that I almost never have to do that, but I read somewhere on a website which I can’t find at the moment. But apparently, if you send a whole bunch of the same thing it how to synchronize, where the beginnings of each bite is in the bitstream that’s coming in through the serial connection, so oops.
So apparently, a tea with any number of A’s is just as good as an ad with just one a so that lets us see that we have a connection up and ready to use now, of course, that’s a boring command. So we want to do something. A little bit more interesting and the first thing that’s quite important to do – is check if your gsm phone or modem supports SMS text mode. So we can do that by issuing this command here and I’ll. Just put that in and we’ll see what happens and then we’ll look at it and a little bit more detail. So, as you can see, it’s just echoed back to me the command that I put in and then it’s told me ok. So if I just look at it again, general structure of the 80 commands is, you have an 80 plus and then you’ll have usually a four letter code for the command type. And then, after that, you can have an equal sign and then a value which means that you’re trying to set the value of that variable to something which is what we just did. If you take away that equals and the value – and you put a question mark there, that means that you want to query the current value of that variable. So if I send that we can see it now, it gives me three lines in the response. So it’s echoed the thing that I said and now it’s giving me the value the current setting of that value so well it’s one because we just set it to one, but it could have been something else before, and then we get the okay after that, as Well, and the other thing that we can do is leave the equals there and put a question mark after the equals, so it will be equals question mark and what this is doing is we are querying what type of parameters we can give for that command.
So if I try that it’s telling us here that we can give a value of zero or one, in other words, we could do like that or we could do like that, so any other value would be invalid. I I presume so those are the three forms you can query you can set, and then you can also query the types of parameters. So what we’ve just done there is we’ve set the CMG if value to be 1 whatever that stands for. I didn’t generally bother to look at what these deviations are for alright, so moving along there’s, a few things here that I found out Ned did not need to bother with, and you probably won’t need to bother with them too. So I apologize but I’m just going to skip over them. I did try them out and all of the values that they show there I already had set, so I didn’t need to set any of them, so let’s just skip down to something which is a bit more interesting, sending the message – and we can do that with This command here, oh of course I have to change the number of the cell phone, so let’s just put that in here, and I think that the final letter here would obviously be send not sure what these first ones are. So what we’re doing here is we’re, saying we’re setting the value of CMG cmgs to be this, and this also brings us into another mode where we start entering the text for the SMS.
So let me just change that to the phone number that we’re going to be sending to ok. So when I hit enter here now, we’ve set the cell number of the text and, as it says here, the modem will respond with a right hand, square bracket or greater than sign. What, if you want to call that which is exactly what we see there so now we’re in a mode where it’s expecting us to type what we want to put as the contents of the text message? So you could do something like go world and then you need to finish that with a control, Z, character and I found out that you, you cannot put a control, Z character into the Arduino IDs serial monitor. So that was the reason why I had. If I just pull this over for a little bit that’s, why I had this little exception when I was typing things into the serial monitor, so if it encounters an asterisk, it will enter this control Z character instead. So what I’m going to do here is this oops. This is a test, SMS message and then I’m going to put an asterisk at the end, so that will close that message for us. So let me just bring my cellphone up, so we can have a look at it and when I click send, we get a response. Cmgs 21, and we have a text showing up here that we can look at and it says this is a test SMS message.
So that’s great and the response here 21, this is actually the ID of the message that we’ve sent. So if we want to refer to this later in order to delete it, I guess I’m not sure what else we could do with it. Read it perhaps that’s the ID of that message that is stored, and then we have an OK to say that everything was okay. So this is a test SMS message message now: let’s see what happens when we respond to that message, say thanks tanks, all right, let’s, say tanks, so we say tanks and we send and keep an eye on the serial monitor. Now we didn’t type anything in there, but we just got a notification of something. So this notification lets us know that there is a text message that has just been received and it is ID 2 and it has been stored on the SIM card. So let’s have a look at that webpage again: where did they go and this one so let’s go back and then we can look at how to receive SMS messages. So once again, I won’t go through all this in detail, because the first part of it is kind of similar, but I’ll just point out that there are potentially other memory areas, at least on a proper cell phone. You would not always be storing stuff on the SIM card, you have other types of memory – storage as well, and you can query which ones you have, but on the hardware that we’re using we’re just using an Arduino GSM module.
So we don’t have a SD card or any of that other kind of storage anyway. So I won’t bother with that. But I’ll just go to the interesting part which is listing the messages. So we can use this command here. A t c mg l equals all, and i was going to just paste that straight in there and we’ll see what happens CIND. I need a bit more space here. Okay, so after I put that command you can see. I actually have two texts in my list and the one that the second one is the tanks that we just sent to ourself and that has come up with status record unread. Although what happens now that we’ve looked at this, that actually will be changed to status of read, and then we can see the phone number that came from and the time. So if I just do that again, we should see that now both of them will be changed to status of red, so the both red – and we can also list them individually and so that’s ID 2. Of course, as we saw before so ID 2, when we got that notification now we see there’s a ID 2 there, so it’s all a bit primitive the formatting, it’s, just comma separated values, really isn’t it. So, to read a specific message: we can do something like this and although actually got ID there for us, so I’ll just use that so let’s just just read a specific message and we can also delete them like this.
So I can so there’s just the last character changing in each of these commands there so d, I guess, stands for delete and it gives us an OK as well, so that text has now been deleted. This one here by the way, was just one that I was doing before when I was testing for making the video so that’s that’s. Why that’s there? Ok, so now that we know that let’s have a look at the program that was running right at the beginning of this video, where we sent a notification for a switch being turned off and on I’ll just go over this briefly. We have including software serial, and then we have the same thing that we had before. So we just have that on pins 7, amp 8 and then I’m recording there’s only two variables really there’s a state and in a last state. So this is the state of the switch and we need to record both of these so that we can tell when it’s changed and in the setup we set, pin mode for, pin digital pin 2 to be an input and its input pull up. Which means that if we don’t have it connected to ground, it will default to being pulled high. So that just means that we don’t need to use a pull up resistor and then we check the state at the beginning, and then we set last state to be the same as state.
So at the beginning, the switch is just that there is no state change and then we do similar thing to before. We start a 9600 board connection to the GSM module and also to the serial monitor, and then this is unnecessary, but I did this just so. I could see what was happening as I was programming it, because if we don’t get a response to 80 at the beginning, well the rest of its not going to work and also found that we need to have a this is probably a little bit long. I found that 500 milliseconds is enough for the other things at the bottom of this file, it’s, not a big file by the way, just in case you were getting scared that’s, all of it right there it’s 50 lines in total, so I just put a little Bit of delay there after that 80 and then in the loop function, all we do is we just if there’s any information or any text given to us by the GSM module. We just write that out to the serial, monitor just echo it straight out, so we can see what it’s doing then we set the last state to be state, and then we set state to be whatever the actual state is right now, so that then we can Compare them and if the state has changed, in other words, state is not equal to last state, then we send an SMS and we don’t want us to be doing running flat out because we might get problems when we plug the pin in and we get an Issue called bouncing where the the state of that pen goes on and off very quickly, so we don’t want that to happen.
So we just delay for half a second between each iteration of this loop. So then in the send emit SMS function. We have another couple of things, not a couple of lines here that are not necessary. This is just so that I can see what is happening, and then we have the oh I’m. Sorry yeah, I guess there’s only two commands really. This is probably not necessary. We could have done this once at the beginning, so you know what I could probably just take these two lines out and put them into the setup function: that’s not not necessary to do it right here every time, but that just sets the mode to be a Plain text messaging mode, and then we give that a chance to finish. And then we do what we did earlier, which was cmgs and then the phone number to call and delay again. And then we print out the actual message that we want it to send. So in this case we’re going to say the switch was turned and then if the current state is true, then it was switches turned on otherwise was turned off and then at the end of the message we have to once again send the control z character. To close that message, and then we wait again so let’s well yeah. We have to upload that to the I just want to show you what’s going on on the serial monitor when we are running that, because I didn’t show you at the beginning, so I’ll upload that and as soon as it finishes uploading, I will open a serial Monitor message and we can see right at the beginning, that’s what happens in the setup procedure and now let me just change the state of that pin.
So we can see it all happening all at once. Hopefully, right and whoops hold on sorry yep. Here we go so a switch was turned off and you can see those messages happening on the side. So that gives you an idea of the time it takes to process this stuff. We couldn’t really see it clearly at the beginning, because I was kind of hiding that window there, but it takes sort of three or four seconds for that to get through most of the time now, as neat as it is to be able to do SMS text Messaging to your phone from your Arduino, like that that wasn’t really what interested me in these modules originally, because these modules are also capable of doing HTTP, GET and post requests to a web server, which is what I really wanted to try. So let’s have a look at that because I figured out how to do that and it’s a little bit more complicated than the SMS, but not much more complicated. So on the right side, I have a website or web page, and this is just a little test. Page on my web server and when we reload the page we’ll see that it’s just telling us the current time in UTC group. I think it’s GMT really isn’t it. So you can just see the seconds are: changing there and I’m going to use this as a test page and I’m going to access this page using the GSM module and at the beginning I’m, going to do it again by command by command by command manually.
Like this, so I have my commands ready to go here and I won’t go. I didn’t actually find one single web page that really explained this pretty well. I had to sort of piece it together from other sources, but I’ll just show you my cheat sheet that I have over to the side. So you can see this is the stuff we’re going to be putting in I’m just going to copy and paste it in? For the most part, but you’ll see it’s, not there’s, not too much to it, so don’t, if it seems like it’s dragging on don’t, worry that the end is not that far away right ahem. So what we need to do at the beginning is we need to say we want to start using HTTP commands or the HTTP service, and that gives us an error now. Why would that be giving us an error? Okay, I figured that problem out. It seems that if you do HTTP in it twice every time after the first time, you’ll get an error in response to that. So looks like it just you don’t need to do it more than once, I think would be nicer if it just said. Okay, really because it’s not really an error, is that I mean is what’s going to work all right. So the next thing that we need to do is I’m going to put this in here, and this is a slightly different form of thing than we’ve.
Seen so far, and so we what we’re doing here is we’re, saying we’re going to set an HTTP parameter so that’s what this is short for and the parameter that we’re going to set is called cid and we’re going to set it to value 1. So this is sort of deferring the name. We have a set of two parameters that we’re giving it once it’s a bit hard to explain, but this is this is the first parameter that we’re going to set and then within that we have multiple parameters. So perhaps before I do this, let me just take this away and I’ll delete that and I’ll put a question mark here. So we can query what this is. What this value is at the moment and when we do that, we’ll see that there’s actually a whole bunch of things that are part of that, so it’s a set of multiple parameters. Hopefully that should be clear when we see what what we just thought, what we can see here and the very first one CID set to 1 already because actually I’m, not sure if it is to begin with or not but maybe 8, because I was just trying Something before that it could already be set to 1, so we don’t really need to do this command right here and just to see what happens if we do equals question. This will give us. So what we’re doing here is we’re querying what kind of parameters we can give to this HTTP power command.
So the response to that is to say the form for that command. Is you give a tag, and then you give the value so that’s? What we see here, tag value tag, value tag value, so we can set any one of these sub properties. I guess you could say using this format so anyway, CID is set to 1. Sorry, I didn’t look up what the CID is anyway, but set it to 1. Just do it, and the next thing that we need to set is the URL to lookup, and we can see at the moment that that is empty. So we need to give that the URL that we’re going to look up and I’ll just make this a little bit wider. So this is the URL that I had before and again we have the command, and then we have the tag separated by a comma and this time this the value is a string, so we need to use, quotes around the value as well. So when we do that we should get an OK and then, if we do the 80c beware question mark again now we should see that in the URL field of those properties we have that URL set. So that is the groundwork ready for doing the actual HTTP connection and to make the actual HTTP connection go. We do HTTP action equals and then I’ll just query this again and see what we get with the query before we try it.
So this is HTTP action. Can be given a value of 0 to 2, and at this point I should probably show you another link that I was using. This is what is this called Sim 980 command manual? I didn’t really bring this up right at the beginning, because it’s it’s a bit of a it’s, not such a great document, really it’s sort of hard to get around and it’s not very well laid out, but alright. Now there is all right, so we can click on a link in here and we’ll see. We can find plenty of info about stuff if we, if we look hard enough, but what we’re doing here is we’re using HTTP power to set something, and we are sorry, no. You doing HTTP action now we’re going to try that again Hecate on alright there. It is HTTP action here it is HTTP action. So, like I say these, this documentation is kind of that’s just hard to read. I don’t know if anybody watching this video saw my other video about the, u blox or the micro blocks GPS module, but that had really really good documentation blows this away so anyway, the parameters that we’re looking at here are 0 for get. So this HTTP GET HTTP POST would be 1 and 2 would be hid. I haven’t tried posting here, but here this should be easy, but I haven’t tried post because I haven’t figured out the commands to add post data and I don’t really need to so I’m.
Just going to use get which is a zero, and so so once again, this is the values here that we’re matching that up with zero to two so let’s just do H. Eighty HTTP action equals zero for get, and that should we just look at the current time here on this websites 343, and if I send this now we get an error. This is an error. So if I just pop back over here for a minute, there is at least one thing that is: documentation is good for and it’s looking up these error codes, so we’ve got an error 601. So what we’re looking at here is we’re being told HTTP action. The type of action is get the response, code was 601 and then the length of the data that was returned is 0, so the 601 corresponds to network error. So this got me quite stuck for quite a while, until I came across a very helpful post here on yep on stack overflow, of course, and it says that you need to set up the connection to the bearer or the provider. I guess that might mean in more common terms, so there’s a couple of commands here that I found that I had to use and this w AP singular is what with what he used in his particular case, and I found that for Vodafone here in New Zealand. It is just Vodafone now I can’t really help you with looking at what it’s going to be for your particular cellular provider, but all you need to do is so just to look at my cheat sheet again.
This is what I needed to do at the beginning. I just wanted to show you that error before we fix the error, so in my case I’m, going to say Vodafone for that and I’m just going to just going to copy that in so that will fix that problem. We just need to say which access point: what does the APN? Was it Stanfill access point of something I don’t know anyway, so with a bit of luck, that will say: ok and then the next one. When we do this, it takes a little bit more time to do this. One ok ready go so it took a second or so to finish, but when we get an OK there, the rest of this HTTP action stuff should work now. So this documentation that we’re just looking at mentions nothing whatsoever to do with sa PBR. So I don’t know how that guy figured that out. Maybe this documentation I’m looking at is a bit old, but there is nothing in here baby holy shit where they’re cut from Oh. No. Now I look stupid missed this. I must have judged PBR something BPA and it puts us not that all right alright take that back. So there is that isn’t, a documentation, okay, well they mind, but suffice to say that now, when we try our HTTP action equals zero. Forget now it says: okay what’s it okay before, but when we wait for a moment this time the result is HTTP action, zero, forget and then 200 as a response code, which is, as you may know, it’s it’s, just the okay code for an HTTP response and Then we have 35 bytes of data returned which so 35 bytes.
It should be okay, so that worked that’s great. Now, where is that data? Well it’s it’s stored in memory? It’S? Not it doesn’t just pop up immediately after that, because that was sort of an asynchronous thing. As you might have noticed, we got the okay for the response for the request that we issued the command that we issued, but then the actual response to the HTTP action. Didn’T show up until a few seconds later so it’s asynchronous now the command that we use to actually read back. The data that was obtained is HTTP, read and I’ll do this again, so that we query what kind of parameters were going to give to that. So the answer to the query is HTTP: read, takes two parameters separated by comma first parameter is a number between 0 and 318000. Second number is a second parameter is a number between 1 and 318000. So what we can do what this is? I guess you have to look at the docs to to know this really, but what we’re doing here is the first number is the position in the data to start reading from so I’m going to say, that’s zero and then the next number is the number of Bytes to read now we just saw that we have 35 bytes available to read from there so I’ll just put 35 and for now and hit enter there and in the response to that command. We can see the text current UTC.
3. 4700. I just reload this now we can see that it’s 349, so I’ve been talking for two minutes and five seconds about this, since we did it but that’s the day that we got from the website very successfully done. If we try and access more than the available bytes it doesn’t matter, it just gives us to be: read: equals zero, so starting from zero. We try and get a thousand bytes and put into there. So, even though I said I want a thousand it’s come back with the response, HTTP read 35, so you could use that number to set up a buffer, an Arduino. If you were trying to read this into an Arduino, you know how many bytes you’re going to need to read in after this. So it’s it’s, not nothing bad, is going to happen by giving a number that’s too large there and just to illustrate how those numbers work. Let’S see if we start reading from the fourth bite and we read eight bytes this time we are given response of eight bytes of data length and it’s e in T, because that’s starting from the well that’s zero indexed starting from the v character, really isn’t it. So it’s ent and then we’re just reading eight bytes after that, so that’s how that works, and I would imagine that, because we have this value 318000, there is the maximum data storage that this module is capable of holding for us.
When we read back an HTTP page, so if we just, let me just try something here, I’ll put in the URL and I’ll change that to the front page of my website, which is a little bit bigger than that test page and then we’ll try. Http action equals zero for a get again so that’s, okay, and this will probably take a little bit longer because I wouldn’t didn’t take too long. So you can see we had a response of 200, which is okay, and this time we have 13 kilobytes or so of data. And if we do 80 Hz be read equal zero, so we’ll read all of those we’ll just go obviously 15000, because it’s not going to matter – and this will give us quite a bit of data back so so you can see this is the the HTML of The front page of my website takes a fair while to read read back over the slow connection doesn’t it that that speed by the way is about as fast as modems used to be back in the day 9600 boy, that’s that’s, how slow a webpage would have Come through go ahead. Those days are gone. Hey all right! I think I’ve pretty much covered what I wanted to cover here. So the next step for me, oops there’s, a bunch of crap on the side of my desk.
arduino gprs Video
arduino gprs news
Posted on Monday May 01, 2017New GSM/GPRS Projects book covers PIC and Arduino Elektor … Continue Reading »
Posted on Thursday July 04, 2019$15 TTGO T-Call Board Combines ESP32 WiFi & Bluetooth SoC with SIM800 GPRS Module CNX Software … Continue Reading »
Posted on Friday January 03, 2020Ringing in the new year with 136 open-spec Linux SBCs under $200 LinuxGizmos.com … Continue Reading »
arduino gprs Social