-
• #2
Your link to the board you're connecting it to got mangled (looks like copy-paste from one of those stupid sites that pits an ellipsis in the middle of the URL), so I'm not sure what you're doing.
Also, can you draw out your current wiring? By hand is fine.
-
• #3
I now have my problem resolved... after thinking more about it I was supplying to much voltage to the sim800L. I was giving it 5V and it has a max of 4.2 (4.4 depending on where I read). After wiring up some 1.2V 2250mah AA's to get ~3.8V it is now running just fine.
Now I just have to rewrite the sim900 espruino module for this thing to boot... its at least responding now!
-
• #4
I do have a question... In the sim900 module it issues the "AT+CIPSTATUS" command and what is returned from the AT module is just the first line of the response. Is there a way to get the entire response so I can compare that properly to the "STATE: IP INITIAL" response the module wants to compare.
Connecting to SIM900 module
] "\x00" <--- "\x00"
Got back
["ATE0\r\n"
] "\x00\r\nOK\r\n" <--- "\r\nOK\r\n"
["AT\r\n"
OK
["AT+CPIN?\r\n"
] "\r\nOK\r\n\r\n+CPIN: READY\r\n\r\nOK\r\n" <--- "\r\nOK\r\n\r\n+CPIN: READY\r\n\r\nOK\r\n"
OK
["AT+CGATT?\r\n"
+CPIN: READY
["AT+CIPSHUT\r\n"
OK
["AT+CIPSTATUS\r\n"
] "\r\n+CGATT: 0\r\n\r\nOK\r\n\r\nSHUT OK\r\n\r\nOK\r\n\r\nSTATE: IP INITIAL\r\n" <--- "\r\n+CGATT: 0\r\n\r\nOK\r\n\r\nSHUT OK\r\n\r\nOK\r\n\r\nSTATE: IP INITIAL\r\n"
+CGATT: 0
Error in 4: +CGATT: 0 -
• #5
It looks like to me the AT module does not reset its internal state when doing a at.cmd. Am I reading this wrong? When the AT+CPIN? is sent it returns 3 lines. Do all three of those lines have to be handled via a callback before the next AT command can be sent?
-
• #6
I've tried looking at the ESP8266WiFi module code to get a handle on this but it doesn't look like that module ever has to deal with multi-line responses from the AT module.
-
• #7
Can someone verify my understanding of the AT module is correct. It looks like it will continue to call your callback that you pass to the at.cmd for each line of data it encounters until the timeout occurs which then it calls your callback with no params. Is that a correct view? If so, does this pseudo code work for dealing with a multi-line response from an at cmd where you are looking for a certain response.
var somInitFunc = function(callback){ //This will get called for each line of data. If we return a func it will continue to be called //for each line. On timeout, it will get called with no params. var myLineCallback = function(d){ if(!d){ return callback("Error in SOMECOMMAND"); } if(d === 'ANSWER I WANT'){ //got a success keep going } else { //just return self b/c we can get multiple lines of extraneous responses from this cmd return myLineCallback; } }; //This command returns multiple lines of data that we need to handle. at.cmd('AT+SOMECOMMAND\r\n', 1000, myLineCallback); };
-
• #8
Hi Jake,
Yes, you're right there. When you do
at.cmd
, it'll call the function once, and if that function returns a function then it'll call that for the next line. Finally if it was still waiting for info and it hits the timeout, it'll call the function withundefined
.Only thing I'd say in your example is while it works you probably don't want to do
if (!d) return callback("Error in SOMECOMMAND");
- just call the callback and don't return anything.The reason for that one is later you might do
if (d!="what_i_want") return callback("Error in SOMECOMMAND");
, but thencallback
could return something and theAT
module might still end up waiting for a response - it just could be a source of bugs.I'd be interested to know what you have to change for SIM800 - I'd hope that we could maybe make the same module handle both devices, as I'm pretty sure people have had SIM800 working.
-
• #9
Actually just one more important thing:
You mentioned
VIO
- I think this is the voltage level used for the IO pins. On the Espruino board, some of the pins are not 5 volt tolerant (it's shown in the diagram on the board's page). Ideally you want to use 3.3v forVIO
because all the IO is 3.3v. -
• #10
Thanks for the VIO info. I did get it to work by connecting the 3.3 on the Espruino to the VIO on the SIM800.
I have another question and I'm not sure how to word it so I'll do my best. Currently the AT module will call the linecallback function if a function is returned. Here is a problem I 'think' I am seeing.
Lets for argument say that an AT command "AT+FOO" is going to return a 3 line response of
OK
SUPER DUPER
OMG
If my callback gets called for OK and I return my same handler it will get called again with SUPER DUPER as the param. I am looking for SUPER DUPER so I call my next AT command in my sequence of calls. That linecallback I pass to that AT command will first get called with OMG before it gets called with the resulting lines from my second AT command. Does that make sense? Shouldn't the AT command call basically flush any pending lines that have not been handled? Am I understanding that wrong?
-
• #11
If
AT+FOO
returns 3 lines, your handler needs to accept all of those lines.If it doesn't then yes, your next call to
AT.CMD
may return the extra line. The AT library does flush lines, but obviously if you issue the command right after, while the last response is still coming in, it has no idea what line is from the old command and what's from the new.For example, this is what you're suggesting I think?
Send> AT+FOO Recv< FooOne -> foohandler Recv< FooTwo -> foohandler Send> AT+BAR Recv< FooThree -> barhandler Recv< BarOne -> thrown away
or if you just waited, the line would be thrown away:
Send> AT+FOO Recv< FooOne -> foohandler Recv< FooTwo -> foohandler Wait 100ms before sending... Recv< FooThree -> thrown away Send> AT+BAR Recv< BarOne -> barhandler
Realistically you want to handle all lines you're expecting to receive though. Not doing that is just asking for pain later on :)
-
• #12
So if the AT+FOO would return 3 lines and you really just cared about FOOTwo you would just maybe issue a wait or a SetTimeout for the AT+BAR command to ensure all of the AT+FOO response lines have been either handled or flushed?
It is just weird that the callback handler for AT+BAR may get a response from AT+FOO. I would have thought the returned lines from the AT+FOO would be somehow indexed to that cmd and only that callback could/would get called for its returned lines. I guess though that can't happen because you don't know what response from the modem is tied to what command... now that I type this out I get why it works the way it does.
Now that I have a deeper understanding of this.. I may just go ahead and tackle a rewrite on the SIM900 module.
-
• #13
you would just maybe issue a wait or a SetTimeout for the AT+BAR command to ensure all of the AT+FOO response lines have been either handled or flushed?
I'd handle all 3 lines - adding a timeout would work, but it's pretty nasty and might bite you later on. It's not hard - at the most basic level:
at.cmd("AT+FOO", 1000, function (first) { return function(second) { return function(third) { // done }; }; });
Or you could actually count the lines - but in a lot of cases there's an
OK
message or something to signify the end of the response that you can use:at.cmd("AT+FOO", 1000, function cb(d) { // stuff... if (d!="OK") return cb; });
I guess though that can't happen because you don't know what response from the modem is tied to what command...
Exactly - it's really the responsibility of the
at.cmd
's callback to keep track of the response that it is expecting.I may just go ahead and tackle a rewrite on the SIM900 module.
Is the existing one not working for you? It sounded a lot like after the wiring issues, it was working ok?
-
• #14
Hello sir...for sim 800L and arduino pro mini you connected vcc of arduimo to vio of sim 800L ..which pin of sim 900a we have to use to connect to the arduino uno .... ?
-
• #15
@user83762, no one connected any Arduino pin in this conversation...
Just switch from Arduino (board) to any Espruino (board) and you leap from the time of the FlintStones into the 21st century... or from Arduino C process loop programming to JavaScript object-oriented, event driven programming.
PS: you may have interpreted Espruino Pico as an Arduino ...mini... - never mind my FlintStone comment... ;-) but it is still true: the few bucks you pay more for an Espruino board you save 10...100 fold in programming time on Espruino in JavaScript...
I could really use some help. I have an Espruino (http://www.espruino.com/EspruinoBoard). I am trying to connect the fona (https://learn.adafruit.com/adafruit-fona-mini-gsm-gprs-cellular-phone-module/pinouts) to our board.
As of right now I have the fona powered by an external 5v power source plugged into the JST port. I also have the VIO pin plugged into the VBAT of the Espruino. I have the KEY pin plugged into a GND on the Espruino. I have the RST plugged into my B4 gpio on the Espruino.
When I try to issue a command to the fona I get errors in my console that says "Boot Failed, Reset". Our code issues a reset on the B4 pin to reset the modem each time we turn it on.
We want to connect the fona in an 'Always On' configuration and connect to it via serial on the espruino to send http requests. Not sure if that helps. I connected the KEY pin bc the way I read the docs the module is OFF by default and you need to connect KEY to ground to have it always on... maybe I read that wrong too. :(
I think I fundamentally have something connected wrong. Any help would be greatly appreciated!