botletics / SIM7000-LTE-Shield

Botletics SIM7000 LTE CAT-M1/NB-IoT Shield for Arduino
https://www.botletics.com/products/sim7000-shield
GNU General Public License v3.0
477 stars 215 forks source link

Library compatible with SIM5320A? #5

Closed dahdo1m closed 6 years ago

dahdo1m commented 6 years ago

Hi all,

I am trying to make a diy 3G cellular data logger for my school project, I'm using a TinySine 3G/GSM/GPS module with an Arduino UNO and an AT&T sim card. I keep getting:

AT+HTTPTERM ERROR AT+HTTPINIT ERROR

I used the Adafruit library and this one uploaded here, but keep getting the same results. Could you please help? Thank you,

botletics commented 6 years ago

It should be compatible, although I know HTTPS uses different commands. Did you first enable GPRS before posting? That's critical for the HTTP to work properly. You should also replace the Adafruit library with my version of the library. Follow the wiki in this Github and load the LTE_Demo code and use the "G" command to enable GPRS then use the "2" command to send data to dweet.io.

As a side note, I actually wrote a function for the SIM5320 HTTPS in my fork of the Adafruit FONA library in a different repo. The function is called "postData3G" in the .cpp file if you want to take a look.

Let me know if you get it working!

botletics commented 6 years ago

Sorry, actually now I recall that the SIM5320 doesn't use the same HTTP commands as the other modules. It uses the "AT+CHTTP____" commands instead. I would have to update my library to get it working.

dahdo1m commented 6 years ago

I have been trying to send AT+CHTTPS___ using the pass through tunnel, this is what I'm getting:

AT+CHTTPSSTART OK AT+CHTTPSOPSE="https://dweet.io/dweet/for/dahdo1m?temp=24.6",443

"no response"!

dahdo1m commented 6 years ago

I have been reading the SIM5320A AT Commands List, the HTTPS commands are quite different, and I feel that I don't fully understand what they are supposed to do.

botletics commented 6 years ago

I haven't tried pass through tunnel. I'll update my library shortly with an HTTP/HTTPS function for you to try shortly. Will keep you updated. However, I can't actually test it out since I don't have a SIM5320A anymore.

botletics commented 6 years ago

OK, I just updated the library and the "LTE_Demo" sketch. Just follow these steps:

Let me know if it works! I'd love to know since I don't actually have one to test it out. Thanks

dahdo1m commented 6 years ago

Hi Tim,

I tried it today, the code you wrote does send the following AT Command CHTTPSSTART and CHTTPSOPSE. The response for the first is OK, but the response for the second is ERROR, just similar to what I described earlier when I used the pass through tunnel. Are we using proper AT Commands? Do you think that SIM5320A is not suitable for connecting to the internet and sending data? The reason I'm asking is because the AT Commands list for SIM5320A does not show HTTP commands, and the HTTPS commands feel insufficient to send data through the 3G network.

botletics commented 6 years ago

The SIM5320A definitely works with HTTP and HTTPS, I tried it before. It just uses different commands than the other 2G modules. Let me ask again:

dahdo1m commented 6 years ago

I enabled it by pressing G, or by pressing g then G, the network was available, signal appeared to be OK, and network was registered.

botletics commented 6 years ago

Hmmmm that's strange. I'll investigate this when I get a chance.

botletics commented 6 years ago

By the way, did you set the right APN for your SIM card? By default I use "hologram" but you need to change it for your specific SIM card if you're not using a Hologram.io SIM card.

dahdo1m commented 6 years ago

I used the APN for AT&T "m2m.com.attz"

dahdo1m commented 6 years ago

I have an AT&T trial sim card

botletics commented 6 years ago

Please verify that it's sending the following AT command exactly as the line below:

AT+CHTTPSOPSE="www.dweet.io",443,2

botletics commented 6 years ago

If it is and it's failing, then go to the LTE_Demo sketch and search for this line:

if (!fona.postData3G("www.dweet.io", 443, "HTTPS", URL)) // Server, port, connection type, URL

and use good 'ole HTTP instead and see what happens:

if (!fona.postData3G("www.dweet.io", 80, "HTTP", URL)) // Server, port, connection type, URL

Also try getting rid of "www" and see if that works. I'm pretty darn sure this worked with "www" when I tested it on SIM5320A.

dahdo1m commented 6 years ago

Hi Timothy,

I tried doing this today I kept getting the response: ERROR, whenever it sends the "AT+CHTTPSOPSE" command

botletics commented 6 years ago

Could you please take a screenshot of the serial monitor output? Thanks!

dahdo1m commented 6 years ago

capture

dahdo1m commented 6 years ago

I tried changing it to "HTTP" and 80,2 , and removing "www." also, all gave the same response

botletics commented 6 years ago

Looks like you have some weird characters showing up at the end of the "CHTTPSOPSE" command. That could very well be the problem. Does it do that every time?

dahdo1m commented 6 years ago

Only after I changed it

botletics commented 6 years ago

Doesn't look like you were entering the port 80 correctly. You should be copying/pasting this line instead:

if (!fona.postData3G("www.dweet.io", 80, "HTTP", URL)) // Server, port, connection type, URL

the "2" means HTTPS and is interpreted inside the function, so you shouldn't input that. In this case it will interpret the "HTTP" as "1" and not a "2". Try that and take another screenshot please! Also, keep the "www" because I'm sure that worked with mine before.

dahdo1m commented 6 years ago

capture

botletics commented 6 years ago

Ahh OK, must be a library thing then. Will look into that.

botletics commented 6 years ago

OK, just uploaded a new Adafruit_FONA.cpp file in the repo. Download that and replace the existing one in your Arduino libraries folder (Documents -> Arduino -> libraries -> Adafruit_FONA by default), restart the IDE, and re-upload and see if that fixed the weird characters.

dahdo1m commented 6 years ago

It worked :)

botletics commented 6 years ago

Awesome! You were able to post data via HTTPS as well?

almagroos commented 6 years ago

Hi, I need your help, I am trying to sen data my web page using Adafruit 3G FONA SIM5320A

I got the same error. Please see the attached picture. capture1

botletics commented 6 years ago

Sorry, currently I don't have a SIM5320A to test personally, but people say the library works with the same AT command sequence.

almagroos commented 6 years ago

Thank you for your replay.

I downloaded the folder "code" and I followed all the instructions that you posted in your page. I am not sure if I used the right Adafruit_FONA.CPP because the code cannot recognize the fona.postdata3G function.

any suggestions my project has been suspended.

botletics commented 6 years ago

You might have an old version of the library. When did you download the code folder?

almagroos commented 6 years ago

yesterday.

botletics commented 6 years ago

Can you please copy the error message here? It compiles just fine for me.

botletics commented 6 years ago

And did you uncomment the line

#define SIMCOM_3G // SIM5320A/E

near the top of the code, and comment out all the other lines?

almagroos commented 6 years ago

I did that

botletics commented 6 years ago

Can you please copy the error message? You also need to delete any existing Adafruit FONA library inside your Arduino libraries folder (default for Windows is Documents/Arduino/libraries). Most likely you have redundancies and it's using the old library.

almagroos commented 6 years ago

I used this line instead of the other if (!fona.postData3G("www.dweet.io", 80, "HTTP", URL)) // Server, port, connection type, URL

C:\Program Files (x86)\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.h:151:101: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

boolean postData(const char server, uint16_t port, const char connType, char URL, char body = "");

                                                                                                 ^

C:\Program Files (x86)\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::postData(const char, const char, char, const char)':

C:\Program Files (x86)\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp:1552:51: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

if (! sendCheckReply(dataBuff, "DOWNLOAD", 10000))

                                               ^

C:\Program Files (x86)\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp: In member function 'boolean Adafruit_FONA::postData(const char, uint16_t, const char, char, char)':

C:\Program Files (x86)\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp:1659:42: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

if (! sendCheckReply(auxStr, ">", 10000))

                                      ^

C:\Users\magro\AppData\Local\Temp\ccFiS6UQ.ltrans0.ltrans.o: In function `loop':

ccFiS6UQ.ltrans0.o:(.text+0x1e66): undefined reference to `Adafruit_FONA_3G::postData3G(char const, unsigned int, char const, char*)'

collect2.exe: error: ld returned 1 exit status

exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560.

botletics commented 6 years ago

Please see my previous comment and delete any old Adafruit FONA libraries that you may have installed before installing mine.

almagroos commented 6 years ago

I did and I will do it again now

almagroos commented 6 years ago

I got the same error message

botletics commented 6 years ago

Also, if it doesn't even compile, how did you get it to run the code? You showed it running the LTE_Demo already...

almagroos commented 6 years ago

When I use if (!fona.postData("www.dweet.io", 80, "HTTP", URL)), it is working but the error as in message below

FONA> G ---> AT+CGATT=1 <--- OK ---> AT+CGSOCKCONT=1,"IP","m2m.com.attz" <--- OK ---> AT+CIPMODE=1 <--- OK ---> AT+NETOPEN=,,1 <--- ERROR Failed to turn on FONA>

almagroos commented 6 years ago

it works when I use fona.postData() instead of fona.postData3G()

botletics commented 6 years ago

Please use the updated version of the examples as well, you have an old version. The new LTE_Demo does not have the "postData3G()" function.

https://github.com/botletics/SIM7000-LTE-Shield/blob/master/Code/examples/LTE_Demo/LTE_Demo.ino

almagroos commented 6 years ago

Should I change the port to 80 or not

almagroos commented 6 years ago

Same error

FONA> n ---> AT+CREG? <--- +CREG: 0,1 Network status 1: Registered (home) FONA> 2 ---> AT+HTTPTERM <--- ERROR ---> AT+HTTPINIT <--- ERROR Failed to complete HTTP GET... FONA>

botletics commented 6 years ago

For the SIM5320 you need to use the "3" command, not "2". You can try port 80 and "HTTP" but I doubt that would make any difference. Sorry, I don't know what's going on with your setup.

almagroos commented 6 years ago

Do you mean this line

define SIMCOM_3G // SIM5320A/E

botletics commented 6 years ago

In the post above you used the "2" command in the LTE_Demo. You should use "3" instead. But yes, you should also use the SIMCOM_3G define line.

almagroos commented 6 years ago

when I chose 3 in command I get this error

+STIN: 25 3 ---> AT+CHTTPSSTART <--- ERROR ---> AT+CHTTPSSTART <--- ERROR Failed to complete HTTP/HTTPS request... FONA>

Please is there any error in this line of code

if (!fona.postData("www.aelmagrous.com", 80, "HTTP", "GET /SensorDemo/add_data2.php?dataRow=50 HTTP/1.1")) // Server, port, connection type, URL Serial.println(F("Failed to complete HTTP/HTTPS request..."));