Closed dahdo1m closed 6 years ago
You should include at least the host name, otherwise how does it know where to go?
HTTP/1.1\r\nHost: dweet.io\r\n\r\n
Sorry, Github is not the place to debug other people's code. If it doesn't work with the code I provide I will look into it, but once you change it I really don't have the time.
Hi, ive been following your steps but no matter what .cpp or .h i use i get lots of compilation errors... I am using ESP32 and Sim5320A, this is what i get when trying to compile from your files. My files work fine for HTTP posting but now i want to use HTTPS.
Archiving built core (caching) in: C:\Users\rene6\AppData\Local\Temp\arduino_cache_949788\core\core_espressif_esp32_featheresp32_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_5cb0df2a6ba85453e296ce37c363884e.a sketch\F7A8X6BI6WOTYGJ.ino.cpp.o:(.literal._Z5setupv+0x48): undefined reference to `Adafruit_FONA::setNetworkSettings(FlashStringHelper const*, FlashStringHelper const, __FlashStringHelper const)'
sketch\F7A8X6BI6WOTYGJ.ino.cpp.o:(.literal._Z9setupGPRSv+0x1c): undefined reference to `Adafruit_FONA::postData(char const, unsigned short, char const, char, char)'
sketch\F7A8X6BI6WOTYGJ.ino.cpp.o: In function `setup()':
C:\Users\rene6\Desktop\Rene\TAB\F7A8X6BI6WOTYGJ/F7A8X6BI6WOTYGJ.ino:617: undefined reference to `Adafruit_FONA::setNetworkSettings(FlashStringHelper const*, FlashStringHelper const, __FlashStringHelper const)'
Thanks
Please use the .cpp and .h files in this repo as well as the example sketches and you shouldn't have any problems compiling for SIM5320 (3G).
okay, there is compatibility issues with the ESP32 board, which i can change code for in the .cpp, however there is still the undefined commands i am getting. Is there a place to see what changes you made to the original fona.cpp file?
Oh, you're using ESP32? Sorry I haven't explored that much. I'm currently really busy but will try this when I get a chance.
Im not sure if the issue is from ESP32 or not (ESP32 is only the microcontroller, HTTPS is from sim5320A), this is what i get in my output logs:
C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp:1585:9: error: prototype for 'boolean Adafruit_FONA::postData(const char, uint16_t, const char, char*)' does not match any in class 'Adafruit_FONA'
boolean Adafruit_FONA::postData(const char server, uint16_t port, const char connType, char *URL) {
^
In file included from C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp:19:0:
C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.h:151:11: error: candidates are: boolean Adafruit_FONA::postData(const char, uint16_t, const char, char, char)
boolean postData(const char server, uint16_t port, const char connType, char URL, char body = "");
^
C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp:1507:9: error: boolean Adafruit_FONA::postData(const char, const char, char, const char)
boolean Adafruit_FONA::postData(const char request_type, const char URL, char body, const char token) {
^
First of all, could you please provide your full code here so I can debug? If you compile for Arduino Uno, Mega, Leonardo, etc. it should work just fine.
Sure, i am trying to use your LTE demo code, the only changes i made are software serial to hardware serial. Here is the changes ive done, the rest is your code:
HardwareSerial Serial2(2); HardwareSerial *fonaSS = &Serial2;
while (!Serial); // ss.begin(GPSBaud); // begin the GPS serial connection Serial.begin(115200); Serial.println(F("Initializing....(May take 3 seconds)")); //fonaSerial->begin(115200); Serial2.write("AT+CDIPR=115200"); // Set Baud to 115200 delay(500); Serial2.begin(115200); delay(500); if (! fona.begin(fonaSS)) { Serial.println(F("Couldn't find FONA")); pinMode(FONA_RST, OUTPUT); //set a pin mode on the FONA_RST int attempt = 0; // a counter to check the number of times the fona has been reset while (! fona.begin(fonaSS) && attempt != 5) { //try to reset the FONA 5 times before giving up Serial.print("Resetting FONA...Attempt"); Serial.println(++attempt); digitalWrite(FONA_RST, LOW); //set the FONA_RST pin low (Reset the fona) } } digitalWrite(FONA_RST , HIGH); //pull FONA_RST back to high
and with the Uno i get this library error:
In file included from C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\includes/platform/FONAPlatStd.h:33:0,
from C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\includes/platform/FONAPlatform.h:40,
from C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.h:22,
from C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\Adafruit_FONA.cpp:19:
C:\Users\rene6\Documents\Arduino\libraries\Adafruit_FONA\includes/platform/Arduino.h:34:31: fatal error: freertos/FreeRTOS.h: No such file or directory
^
If you are getting errors while compiling for Arduino Uno then it's something on your end (either package installations, libraries, etc.). Sorry, but I don't have time to dig deeper.
Using the LTE_Demo code I have on Github compiles with "ESP32 Dev Board" with the hardware serial change:
`// We default to using software serial. If you want to use hardware serial
// (because softserial isnt supported) comment out the following three lines
// and uncomment the HardwareSerial line
//#include
// Hardware serial is also possible! //HardwareSerial *fonaSerial = &Serial1;
// For ESP32 hardware serial use these lines instead
HardwareSerial fonaSS(1);`
The issues im getting is calling the PostData command, it says const *char to char is -fpermissive or something in that manor.
But you said when you try compiling the LTE_Demo sketch for Arduino Uno without making any modifications, you get an error. That means something else is wrong.
Hi... Has there been significant changes on library regarding support on SIM5320 module. Cause at this moment there comes compiling error 'class Adafruit_FONA_3G' has no member named 'setNetworkSettings' Using LTE_DEMO example with correct changes to enable the SIM5320
It's still supported but a function name was changed from the default Adafruit function name.
---> AT+CIPSHUT
<--- ERROR
Failed to connect to TCP/IP! <--- ERROR Failed to connect to MQTT broker! Publishing data to their respective topics! <--- ERROR Failed to publish data! <--- ERROR Failed to publish data! <--- ERROR Failed to publish data! <--- ERROR Failed to publish data! ---> AT+CIPCLOSE <--- ERROR Failed to close connection! Shutting down...
With a Wi-Fi device I can connect with server using below line:
_if (conn.connect(serveraddr, 3380, user, password))
but this doesn't work with FONA.
I would really appreciate your help. Do you have any ideas? Thank you in advance
Sorry I don't use MySQL. If you can set up MQTT on it or an HTTP endpoint then the library should work just fine.
I've been chasing my tail on this, well I'll keep trying. Thank you.
Hello botletics! Sorry for reusing this issue and thank you very much for this library. I'm using ESP32 + SIM5320E with LTE Demo code. The dweet post through command '3' is working well (unless by the second return from server which returns that it failed but it posted). When I try to use command 'W' to post data to a website, even with the httpbin post example (I've already tried others website that worked using curl in my desktop) it doesn't work. The log above represents my test:
G ---> AT+CGATT=1 <--- OK ---> AT+CGSOCKCONT=1,"IP","zap.vivo.com.br" <--- OK ---> AT+CGAUTH=1,1,"vivo","vivo" <--- OK ---> AT+CIPMODE=1 <--- OK ---> AT+NETOPEN=,,1 <--- Network opened FONA> 3 ---> AT+CHTTPSSTART <--- OK Waiting 1s to ensure connection... ---> AT+CHTTPSOPSE="www.dweet.io",443,2 <--- OK Waiting 1s to make sure it works... ---> AT+CHTTPSSEND=79 <--- > ---> GET /dweet/for/861311006277858?temp=0.00&batt=3700 HTTP/1.1 Host: dweet.io
<--- OK ---> AT+CHTTPSSEND <--- OK <--- +CHTTPSSEND: 0 ---> AT+CHTTPSRECV? <--- +CHTTPSRECV: LEN,0 ---> AT+CHTTPSRECV=0 <--- ERROR ---> AT+CHTTPSCLSE <--- OK <--- ---> AT+CHTTPSSTOP <--- OK Failed to complete HTTP/HTTPS request... FONA> W NOTE: in beta! Use simple websites to post! URL to post (e.g. httpbin.org/post): http://httpbin.org/post Data to post (e.g. "foo" or "{"simple":"json"}"): foo
---> AT+HTTPTERM <--- ERROR ---> AT+HTTPINIT <--- ERROR Failed! FONA>
Regards!
Thanks, I'll look into it when I get a chance.
So I looked at it and the "W" function was written by Adafruit and it doesn't support the SIM5320. I would recommend just using the "3" option to post data, and in the meantime I'll edit the LTE_Demo so that "W" doesn't show up as an option when SIM5320 is selected.
Hi botletics! First of all, thank you so much for providing this library. It helped me a lot. Apologies coz I will ask for help this time.
I am reusing the option '3' on your LTE_Demo.ino which sends an HTTP GET request to a website. However, the shield cannot successfully send the request. Kindly see results from Serial monitor below:
I am also trying to send the exact same GET request thru my browser and it works fine.
Regards!
First of all, does the dweet example work? And does the domain only accept HTTPS?
Hello, yes it worked on the dweet example. Seems like the shield is working fine and the fault is on the side of the web hosting. Btw, thank you for the response.
Hi botletics! My issue is fixed now by finding another hosting site. Again, thank you so much for your work!
OK, acabou de carregar um novo arquivo Adafruit_FONA.cpp no repositório. Faça o download e substitua o existente na sua pasta de bibliotecas do Arduino (Documents -> Arduino -> libraries -> Adafruit_FONA por padrão), reinicie o IDE, faça o upload novamente e veja se isso corrigiu os caracteres estranhos. Hi, I'm having a similar problem, I'm trying to send data via HTTP over a SIM5320A Shield, I've enabled the network and I've used the Adafruit_FONA.cpp file quoted above with the correction but not obitive. I get this error: <--- OK ---> AT + CHTTPSSEND <--- OK <--- + CHTTPSSEND: 0 ---> AT + CHTTPSRECV? <--- + CHTTPSRECV: LEN, 0 ---> AT + CHTTPSRECV = 0 <--- ERROR ---> AT + CHTTPSCLSE <--- OK (I.e. ---> AT + CHTTPSSTOP <--- OK Failed to complete HTTP / HTTPS request ...
Oi botletics! Meu problema foi corrigido agora ao encontrar outro site de hospedagem. Mais uma vez, muito obrigado pelo seu trabalho!
Hello, I'm using web hosting and I'm not able to send the data, which site did you use?
Hello everyone I'm in need of help to run the post 3g example. I'm having the following error
I hope someone can help me, thanks.
Hi botletics!
Do you happen to know a way to modify the code for SIM5320A to send data to things.ubidots.com?
I keep getting (Bad Request) or (Your Browser sent an Invalid Request) trying to upload data. Here's the dweet part of the code that I modified:
` case '3': { // Post data to website via 3G or 4G LTE float temperature = analogRead(A0)*1.23; // Change this to suit your needs
// Voltage in mV, just for testing. Use the read battery function instead for real applications.
uint16_t battLevel = 3700;
// Create char buffers for the floating point numbers for sprintf
// Make sure these buffers are long enough for your request URL
char URL[500];
char tempBuff[16];
char battLevelBuff[16];
// Format the floating point numbers as needed
dtostrf(temperature, 1, 2, tempBuff); // float_val, min_width, digits_after_decimal, char_buffer
dtostrf(battLevel, 1, 0, battLevelBuff);
// Construct the appropriate URL's and body, depending on request type
// Use IMEI as device ID for this example
// GET request
sprintf(URL, "POST /api/v1.6/devices/cello1/?token=(MYTOKEN) HTTP/1.1\r\nHost: things.ubidots.com\r\nContent-Type: application/json\r\n\r\ncellotemp=100\r\n");
if (!fona.postData("things.ubidots.com", 443, "HTTPS", URL)) // Server, port, connection type, URL
Serial.println(F("Failed to complete HTTP/HTTPS request..."));
break;
}
`
Would you please help me adjust the code to post data to ubidots as well as dweet?
Hey, would you do me a favor and post that on the newly-created Botletics forum since it's less of a Github question? Thanks!
(Sorry, just trying to get more people on there lol)
OK
Posted
Hi botlectics,
I'm using your sketch for sim5320E in Italy with Iliad network (apn: iliad) but everytime I'm trying to connect with HTTP it's saying "Failed to complete HTTP/HTTPS request...". I'm new with this and I tried to shred your program as per my requirement. Can you check and let me know where the trouble is? Thank you
#include "Adafruit_FONA.h"
#define SIMCOM_3G // SIM5320A/E
// For TinySine SIM5320 shield
#define FONA_PWRKEY 8
#define FONA_RST 9
#define FONA_TX 2 // Microcontroller RX (note: won't work on Mega)
#define FONA_RX 3 // Microcontroller TX
char replybuffer[255];
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
#if defined(SIMCOM_3G)
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);
#endif
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
uint8_t type;
char imei[16] = {0}; // MUST use a 16 character buffer for IMEI!
void setup() {
// while (!Serial);
pinMode(FONA_RST, OUTPUT);
digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT);
Serial.begin(9600);
Serial.println(F("FONA basic test"));
Serial.println(F("Initializing....(May take several seconds)"));
fonaSS.begin(9600); // Default SIM7000 shield baud rate
Serial.println(F("Configuring to 9600 baud"));
fonaSS.println("AT+IPR=9600"); // Set baud rate
delay(100); // Short pause to let the command run
fonaSS.begin(9600);
if (! fona.begin(fonaSS)) {
Serial.println(F("Couldn't find FONA"));
while (1); // Don't proceed if it couldn't find the device
}
type = fona.type();
Serial.println(F("FONA is OK"));
Serial.print(F("Found "));
switch (type) {
case SIM5320A:
Serial.println(F("SIM5320A (American)")); break;
case SIM5320E:
Serial.println(F("SIM5320E (European)")); break;
}
// Print module IMEI number.
uint8_t imeiLen = fona.getIMEI(imei);
if (imeiLen > 0) {
Serial.print("Module IMEI: "); Serial.println(imei);
}
// Set modem to full functionality
fona.setFunctionality(1); // AT+CFUN=1
fona.setNetworkSettings(F("iliad")); // For Iliad SIM card
printMenu();
}
void printMenu(void) {
Serial.println(F("-------------------------------------"));
#if !defined(SIMCOM_3G) && !defined(SIMCOM_7500)
Serial.println(F("[w] Read webpage"));
Serial.println(F("[W] Post to website"));
#endif
}
void loop() {
Serial.print(F("FONA> "));
while (! Serial.available() ) {
if (fona.available()) {
Serial.write(fona.read());
}
}
char command = Serial.read();
Serial.println(command);
#if defined(SIMCOM_3G) || defined(SIMCOM_7500)
// Post data to website via 3G or 4G LTE
float temperature = analogRead(A0) * 1.23; // Change this to suit your needs
// Voltage in mV, just for testing. Use the read battery function instead for real applications.
uint16_t battLevel = 3700;
// Create char buffers for the floating point numbers for sprintf
// Make sure these buffers are long enough for your request URL
char URL[150];
char tempBuff[16];
char battLevelBuff[16];
// Format the floating point numbers as needed
dtostrf(temperature, 1, 2, tempBuff); // float_val, min_width, digits_after_decimal, char_buffer
dtostrf(battLevel, 1, 0, battLevelBuff);
// Construct the appropriate URL's and body, depending on request type
// Use IMEI as device ID for this example
// GET request
sprintf(URL, "GET /dweet/for/%s?temp=%s&batt=%s HTTP/1.1\r\nHost: dweet.io\r\n\r\n", imei, tempBuff, battLevelBuff);
if (!fona.postData("www.dweet.io", 443, "HTTPS", URL)) // Server, port, connection type, URL
Serial.println(F("Failed to complete HTTP/HTTPS request..."));
#endif
}
// Power on the module
void powerOn() {
digitalWrite(FONA_PWRKEY, LOW);
// See spec sheets for your particular module
#if defined(SIMCOM_2G)
delay(1050);
#elif defined(SIMCOM_3G)
delay(180); // For SIM5320
#elif defined(SIMCOM_7000)
delay(100); // For SIM7000
#elif defined(SIMCOM_7500)
delay(500); // For SIM7500
#endif
digitalWrite(FONA_PWRKEY, HIGH);
}
The issue is that you are not enabling data. Try the "enableGPRS(true)" command before doing the actual HTTP request.
I tried your original one, the problem remains. On "AT+CHTTPACT=?" its showing: Ringing/in progress (outgoing). And on command 3 its showing: --> AT+CHTTPSSTART <--- ERROR Failed to complete HTTP/HTTPS request...
Can you give me a simplified program for https because I want to use it with blynk. Thank you
Maybe you're connected to a call somehow? Maybe hang up first. Use the LTE_Demo.ino sketch but with #define SIMCOM_3G
uncommented and comment out the default #define SIMCOM_7000
and then use command "G" and then command "3" to post data. Sorry, I'm not in the position to make customized code for people.
So I did like this:
#include "Adafruit_FONA.h"
// Define *one* of the following lines:
//#define SIMCOM_2G // SIM800/808/900/908, etc.
#define SIMCOM_3G // SIM5320A/E
//#define SIMCOM_7000 // SIM7000A/C/E/G
//#define SIMCOM_7500 // SIM7500A/E
// For TinySine SIM5320 shield
#define FONA_PWRKEY 8
#define FONA_RST 9
#define FONA_TX 2 // Microcontroller RX (note: won't work on Mega)
#define FONA_RX 3 // Microcontroller TX
// ESP8266 + SIM7000 shield
//#define FONA_PWRKEY 14 // D5 on NodeMCU
//#define FONA_RST 12 // D6 on NodeMCU
//#define FONA_TX 4 // D2 on NodeMCU, microcontroller RX
//#define FONA_RX 5 // D1 on NodeMCU, microcontroller TX
// For SIM7000 shield
//#define FONA_PWRKEY 6
//#define FONA_RST 7
//#define FONA_DTR 8 // Connect with solder jumper
//#define FONA_RI 9 // Need to enable via AT commands
//#define FONA_TX 10 // Microcontroller RX
//#define FONA_RX 11 // Microcontroller TX
//#define T_ALERT 12 // Connect with solder jumper
and changed "fona.setNetworkSettings(F("iliad"))", then I'm getting the following:
FONA> G ---> AT+CGATT=1 <--- OK ---> AT+CGSOCKCONT=1,"IP","iliad" <--- OK ---> AT+CIPMODE=1 <--- ERROR Failed to turn on FONA> 3 ---> AT+CHTTPSSTART <--- ERROR Failed to complete HTTP/HTTPS request... FONA>
Try to hang up with "h" and then do "g" then "G" then "3".
This is how it's coming. What could be the problem?
FONA> h
---> ATH
<--- OK
Failed
FONA> g
---> AT+NETCLOSE
<--- +IP ERROR: Network is already closed
Failed to turn off
ERROR
FONA> G
---> AT+CGATT=1
<--- OK
---> AT+CGSOCKCONT=1,"IP","iliad"
<--- OK
---> AT+CIPMODE=1
<--- OK
---> AT+NETOPEN=,,1
<--- Network opened
FONA> 3
---> AT+CHTTPSSTART
<--- OK
Waiting 1s to ensure connection...
---> AT+CHTTPSOPSE="www.dweet.io",443,2
<--- OK
Waiting 1s to make sure it works...
---> AT+CHTTPSSEND=81
<--- >
---> GET /dweet/for/867057031039730?temp=687.57&batt=3700 HTTP/1.1
Host: dweet.io
<--- OK
---> AT+CHTTPSSEND
<--- OK
<--- +CHTTPSSEND: 0
---> AT+CHTTPSRECV?
<--- +CHTTPS: RECV EVENT
---> AT+CHTTPSRECV=558
<--- OK
<---
+CHTTPSRECV: DATA,378
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
Content-Length: 213
Date: Mon, 05 Aug 2019 17:47:30 GMT
Connection: keep-alive
{"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing
---> AT+CHTTPSCLSE
<--- OK
<---
---> AT+CHTTPSSTOP
<--- OK
Failed to complete HTTP/HTTPS request...
FONA>
Not sure why it's saying it failed, but that's on the library side. As you can see from the server response, it posted successfully.
So should I reinstall everything?
No, it's doing what it should be doing correctly. The only reason it's saying "Failed to complete HTTP/HTTPS request..." is because in the library file it's checking for a "+CHTTPSSTOP: 0" response when it sends "AT+CHTTPSSTOP" but it didn't get that response. It might be the firmware you're running or something, I'm not sure. What you could easily do is go into the library file and instead of lines 1929-1930 just write getReply(F("AT+CHTTPSSTOP"));
I'll now do what you suggested but 5 minutes ago I got this. What does "+CHTTPSNOTIFY: PEER CLOSED" means?
FONA> G
---> AT+CGATT=1
<--- OK
---> AT+CGSOCKCONT=1,"IP","iliad"
<--- OK
---> AT+CIPMODE=1
<--- OK
---> AT+NETOPEN=,,1
<--- Network opened
FONA> 3
---> AT+CHTTPSSTART
<--- OK
Waiting 1s to ensure connection...
---> AT+CHTTPSOPSE="www.dweet.io",443,2
<--- OK
Waiting 1s to make sure it works...
---> AT+CHTTPSSEND=101
<--- >
---> GET /dweet/for/T+CGPSOUT=000?temp==%s HTTP/1.1
Host: dweet.io
&batt= HTTP/1.1
Host: dweet.io
<--- OK
---> AT+CHTTPSSEND
<--- OK
<--- +CHTTPSSEND: 8
Failed to complete HTTP/HTTPS request...
FONA>
+CHTTPSNOTIFY: PEER CLOSED
Not sure why you're getting that. Looks like this time it didn't work.
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,