Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM800Twilio example not working ... #786

Open
Humancell opened this issue Aug 15, 2019 · 2 comments
Open

SIM800Twilio example not working ... #786

Humancell opened this issue Aug 15, 2019 · 2 comments

Comments

@Humancell
Copy link

Humancell commented Aug 15, 2019

I've got a SIM800L powered up and working with a 3.3v Pro Mini.

I've written my own code to send the specific AT commands to the SIM800L, and it works perfectly ... I get the commands to Twilio and on to my application.

I wanted to use the SIM800Twilio library and example from here so that I'm not re-writing all of this functionality. I installed it and ran it. And it doesn't work. :-(

https://github.com/TwilioDevEd/api-snippets/tree/master/wireless/quickstart/m2m_commands_arduino_sim800

There is not much debug output, but it does initialize ... says that it is sending the SMS ... and then says it's waiting for incoming SMS. BUT ... nothing ever shows up at Twilio ... and so it isn't working.

Thoughts on recommended ways to debug this and get it working? Is this supported code going forward or should I locate and adapt an alternative library?

@pkamp3
Copy link
Contributor

pkamp3 commented Aug 15, 2019

@Humancell happy to help! Want to mail me at pkamp [at] twilio.com ? Feel free to attach your working code and I'll try and help debug it

@Humancell
Copy link
Author

Humancell commented Aug 17, 2019

Thanks for the quick reply ... I'll contact you via email also.

I wanted to post my findings here also, as I believe that I've resolved my issue and this might assist others.

I'm just testing/using the example code from the link above (https://github.com/TwilioDevEd/api-snippets/tree/master/wireless/quickstart/m2m_commands_arduino_sim800) and I what I've found is that the failure seems to be related to the time it takes for the SIM800L to register on the network.

When I power up both the SIM800L and the Pro Mini at the same time, the code begins to run immediately.

When modem.begin() is called this simply sets up the SoftwareSerial, and then calls reset_modem().

reset_modem() issues the AT command until it gets a response of OK. On my SIM800L this occurs very quickly ... but the modem is STILL NOT registered on the network.

The example code then enters the loop() and almost immediately issues a modem.send_command() to attempt to send the command/sms.

send_command() calls the private method _send_SMS().

_send_SMS() immediately begins to try and send the AT commands to send a mobile command/sms ... but again in my case the modem is STILL NOT registered on the network. In addition, this method is discarding the responses from the modem so it does not detect that the responses are NOT "OK" ... they are still a random combination of asynchronous events of the modem completing the registration process.

At this point the code is out of sync with the state of the modem, and so everything fails.

If I power the modem, and give it 15-30 seconds to complete the registration on the network, and THEN power up the Pro Mini ... everything works perfectly. Once the modem has been powered and registered everything works. The code is simply missing checks to ensure that the network is ready before attempting to send the mobile command/sms.

What is missing from the example is a while loop checking for network registration using the AT command AT+COPS? until it returns more than +COPS: 0 ... in my case when registered it returns +COPS: 0,0,"T-Mobile USA" and then I can proceed with the rest of the code.

I'll keep hacking on the code and looks like I'll need to issue a pull request at some point. :-)

UPDATED: The other AT command to use is the AT+CREG? which provides details about the registration status. The response of +CREG: 0,2 means NOT registered ... and +CREG: 0,1
when registered. https://m2msupport.net/m2msupport/atcreg-network-registration/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Humancell @pkamp3 and others