Closed ammarqs closed 5 years ago
Overview: I have customized the program to run with our setup, not using GPS. The controller does not sleep. It loops to checks for any triggers and run functions accordingly. So my program does not include any sleep functions. So the question here is: Does the module have the tendency to log off from network when not active for too long?
if so, using this with before every http get funciton will make sure that the modem connects to the network before posting: while (!netStatus()) { Serial.println(F("Failed to connect to cell network, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Connected to cell network!"));
No, it should stay connected to the network at all times. That bit of code you posted will not ensure it connects, but will only check that it's connected. Because the modem will always want to connect unless you tell it explicitly not to. So I'd recommend that you check for the network status periodically as part of your loop (like every 20s or something).
Yea thats what i thought it should be doing. but i left it online yesterday to make sure it stays connected when i come back this morning. I came this morning and the net status light was blinking slowly compared to when connected. Soo i tried to trigger an event but it didnt send out a message. so i had to open my serial port and the connection established and it starting posting messages when function triggered.
So what you say is in my main loop, i check for connection every 20sec or so, if not connected, what should it do to connect back? I guess the request to check for connection will make sure that the modem is communicating at all times and does not go to sleep?
Blinking slowly means it's connected but data isn't enabled. Blinking somewhat rapidly (but not very quickly) means it's not connected.
Per the SIM7000 Hardware Design Document, 64ms ON/800ms OFF indicates no connection, 64ms ON/3000ms OFF indicates registered to network, 64ms ON/300ms OFF indicates transmission of data, and OFF indicates power-off or power-saving mode.
The modem will never go to sleep by itself under normal circumstances where you're supplying proper power to it, and it should also always stay connected to the network.
So why do you think this would be happening? Anything that i can do it make sure its connected to the network before it tries to post data?
On Fri, Dec 21, 2018 at 11:51 AM Timothy Woo notifications@github.com wrote:
Blinking slowly means it's connected but data isn't enabled. Blinking somewhat rapidly (but not very quickly) means it's not connected.
Per the SIM7000 Hardware Design Document, 64ms ON/800ms OFF indicates no connection, 64ms ON/3000ms OFF indicates registered to network, 64ms ON/300ms OFF indicates transmission of data, and OFF indicates power-off or power-saving mode.
The modem will never go to sleep by itself under normal circumstances where you're supplying proper power to it, and it should also always stay connected to the network.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-449439850, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarX0xDfw-aic1e6vrKCT-3fcMgurPOks5u7RGlgaJpZM4YzlYS .
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
If you check for the network status you could start a timer right when it's NOT connected, then if it remains disconnected for too long then you could pulse the RST pin (pin 7) to restart the module. But I've run long-term tests without problems.
If you are sending a SMS note that Verizon seems to block the Hologram number so you may not get the text if your phone is using Verizon. Please see this wiki page for how to get around that using a Hologram SMS Route.
No we arent using any sms.. our package from kore does not allow any sms. Its purely data.
On Fri, Dec 21, 2018 at 11:53 AM Timothy Woo notifications@github.com wrote:
If you check for the network status you could start a timer right when it's NOT connected, then if it remains disconnected for too long then you could pulse the RST pin (pin 7) to restart the module. But I've run long-term tests without problems.
If you are sending a SMS note that Verizon seems to block the Hologram number so you may not get the text if your phone is using Verizon. Please see this wiki page https://github.com/botletics/SIM7000-LTE-Shield/wiki/SMS-Messages#hologram-sms-route for how to get around that using a Hologram SMS Route.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-449440359, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarX4qfg8VXtmURqeV_Hhi6Rn2nZ-Eyks5u7RIhgaJpZM4YzlYS .
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
OK, so if you're trying to send something to the cloud then that means it was probably still connected to the network but data wasn't enabled. What exactly did you see from the AT command log when it failed? Did it fail to run a certain command?
Thats the thing, it was disconnected from the computer and powered with an actual power source.. before i left, everything worked fine.. i came back it didnt work, so i connected my usb and as soon as i opened my serial port, it did the setup routine and started communicating.. so i didnt get the chhance to check the errors if any..
On Fri, Dec 21, 2018 at 11:57 AM Timothy Woo notifications@github.com wrote:
OK, so if you're trying to send something to the cloud then that means it was probably still connected to the network but data wasn't enabled. What exactly did you see from the AT command log when it failed? Did it fail to run a certain command?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-449441217, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarX0go2dj9BpJLgf9KPe1NVJlUV2Puks5u7RLsgaJpZM4YzlYS .
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
By "it did the setup routine" do you mean the microcontroller was reset? The module won't be reset simply by opening the serial monitor. However, opening the serial monitor will restart the Arduino (or microcontroller, depending on what type it is).
Sorry, without getting an AT command log to see exactly what was happening I really can't tell if it's something small in your code that might be tripping it, or something else. It's really hard to say.
Yes thats what it did, turning on serial monitor restarted the controller and the modem connected and everything started working as normla
On Fri, Dec 21, 2018 at 12:02 PM Timothy Woo notifications@github.com wrote:
Sorry, without getting an AT command log to see exactly what was happening I really can't tell if it's something small in your code that might be tripping it, or something else. It's really hard to say.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-449442475, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarX-MuinToVi9jYIqho9DxDxp0zDfvks5u7RQagaJpZM4YzlYS .
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
Yup.. i will do this again today, this time leaving the serial port open.. and leave it for a few hours to check what happened.
On Fri, Dec 21, 2018 at 12:04 PM Ammar Surti ammarqs@gmail.com wrote:
Yes thats what it did, turning on serial monitor restarted the controller and the modem connected and everything started working as normla
On Fri, Dec 21, 2018 at 12:02 PM Timothy Woo notifications@github.com wrote:
Sorry, without getting an AT command log to see exactly what was happening I really can't tell if it's something small in your code that might be tripping it, or something else. It's really hard to say.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-449442475, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarX-MuinToVi9jYIqho9DxDxp0zDfvks5u7RQagaJpZM4YzlYS .
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
Unfortunately I can't tell you exactly what's wrong. However, you could implement a counter that increments for each unsuccessful attempt to do something (like post data to the cloud) and if it reaches a certain value then you could reset the SIM7000 module and try again.
You can also use the command AT+CFUN=6 to restart the module via software. Just make sure after restarting that you do the entire fona.begin() setup code as well, because it has to find it again.
EDIT: You can use "fona.setFunctionality(6)" to set AT+CFUN=6 in Arduino code.
i just doubled checked my code. there is nothing in the loop function to to enable or disable modem. After the setup routine, there is nothing except for the HTTP get requests to do anything with the connection. Here is the Setup: `void setup(){ Serial.begin(9600); Serial.println(F("Hello World!"));
pinMode(ContainerLSW, INPUT);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
pinMode(FONA_RST, OUTPUT); digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT); powerOn(); // Power on the module moduleSetup(); // Establishes first-time serial comm and prints IMEI
fona.setFunctionality(1); // AT+CFUN=1 fona.setNetworkSettings(F("c2.korem2m.com")); // For KORE SIM card fona.setPreferredMode(38); // Use LTE only, not 2G fona.setPreferredLTEMode(1); // Use LTE CAT-M only, not NB-IoT fona.setOperatingBand("CAT-M", 12); // AT&T uses band 12
/ // Enable GPS while (!fona.enableGPS(true)) { Serial.println(F("Failed to turn on GPS, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Turned on GPS!")); /
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!")); // Turn on GPRS while (!fona.enableGPRS(true)) { Serial.println(F("Failed to enable GPRS, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Enabled GPRS!"));
TotalCycles = EEPROM.read(0); // Total Cycles
CycleSincePickup = EEPROM.read(1); // Cycles Since Return
PowerONMessage(); // RecevieGPSCoordinates(); } ` i am going to try and repeat this tonight. and check what happens.
I suppose this is 64ms OFF/ 300ms OFF Its working right now!
Hey, I managed to leave it for 4 hours and it started doing the same thing. looks like the light is blinking for 64ms ON and 3000ms OFF.
This is the error screen once i try to trigger an event. The system was left untouched for a few hours.
Looks like it leaving it ideal for a few hours disconnects the module from the network.
No, it's connected to the network but data is being disabled. You just have to use "enableGPRS(true)" before posting each time.
Thanks. But why do you think it would be doing it? Do i still need to set these: fona.setFunctionality(1); // AT+CFUN=1 fona.setNetworkSettings(F("c2.korem2m.com")); // For KORE SIM card fona.setPreferredMode(38); // Use LTE only, not 2G fona.setPreferredLTEMode(1); // Use LTE CAT-M only, not NB-IoT fona.setOperatingBand("CAT-M", 12); // AT&T uses band 12
On Sat, Dec 22, 2018 at 10:16 PM Timothy Woo notifications@github.com wrote:
No, it's connected to the network but data is being disabled. You just have to use "enableGPRS(true)" before posting each time.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-449611497, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarXxzi5WDmfbTPC2lxWdFyeD4IxRAsks5u7vV9gaJpZM4YzlYS .
Is there any other way i can check for data connection before tring to connect? If data is not there it does the enablegprs routine, else it just goes through?
It's probably turning off data to save data, but it won't disconnect from the network. You shouldn't have to set those other parameters again. Just run the enableGPRS(true) command to make sure data is enabled. I believe you can also check with AT+CNACT? as well.
Hello Timothy, Did you by any chance figure out a way to send an image attachment via POST or GET requests?
Or the ftp seTUP?
Basic FTP example is shown in the FTP_Demo sketch
Using FTP with full pictures is a whole different ballgame that I haven't played with yet.
The only i see here is that the FTP is not secured. Would this also work with a SFTP protocol or some other secure gateway?
Or can we do a simple HTTP GET/POST to post the pictures to the web server?
I don't believe the FTP commands would work over SSL. That would require separate commands. Yes, you can do HTTP GET/POST requests but the AT command manual specifies max data size of 319488 bytes.
Yes this should be good enough. The max pic size i will be using is around 80KB. Is there anything special in your library i would have to implement in order to attach a file to the post request?
Should be fine as long as you make sure you don't run out of memory or something.
What i meant is: how do i attach a file to a post request within your system?
`void setup(){ Serial.begin(9600); Serial.println(F("TEST FUNCTION"));
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
pinMode(FONA_RST, OUTPUT); digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT); powerOn(); // Power on the module moduleSetup(); // Establishes first-time serial comm and prints IMEI
fona.setFunctionality(1); // AT+CFUN=1 fona.setNetworkSettings(F("c2.korem2m.com")); // For KORE SIM card fona.setPreferredMode(38); // Use LTE only, not 2G fona.setPreferredLTEMode(1); // Use LTE CAT-M only, not NB-IoT fona.setOperatingBand("CAT-M", 12); // AT&T uses band 12
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!")); // Turn on GPRS while (!fona.enableGPRS(true)) { Serial.println(F("Failed to enable GPRS, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Enabled GPRS!"));
Serial.println("Initializing SD card...");
if (!SD.begin(SD_CS)) { Serial.println(F("initialization failed!")); while (1); } Serial.println(F("initialization done.")); }`
Timothy,
in the above code, nothing works after initializing SD card. I get the initialization done message but after that the system stop communicating with the sim7000 module. It sends AT commands but doesnt receive any replies, none of the GET/POST request work either. If i comment the SD card initialization, everything works normal. What i am missing? Something to do with SPI communication ?
never mind. It was the software serial port clashing with the SPI pins. changed the software serial to 8 and 9
What i meant is: how do i attach a file to a post request within your system?
Without using FTP you cannot post a file to a directory, or just "attach" the file, but you can only post the contents of that file.
I have an image that i need to post. if POST wont work for that, what will? TCP server client connection?
If you just need to send the image data then POST should be just fine. FTP keeps everything as a file system, but the underlying principle is that you still need to send the data.
any thing that can help me get started with the post requests? i see examples but adding image data would be something i might get stuck with.
Sorry I am extremely busy. I can't give one-on-one support for everyone :(
very well..
Timothy, does the library allow me to use flash memory to store data? This will be very helpful to send the images via POST...
Storing data to flash memory has nothing to do with the library itself, although the library does need to be able to handle the data that is sent to it in the postData() function. Storing large amounts of data to flash memory can either be hard-coded in the program using PROGMEM for AVR microcontrollers (which I'm assuming you won't want because you can't change it afterwards) or to use an ESP8266's SPIFFS file system or SD card. However, interfacing it with the library to handle those large amounts of data is a whole different story which I haven't investigated yet.
I am probably OK with doing that. Mega has 256 kb of flash that i can use to store the image data while sending it out. Sending out an image as been a pain, tcp client server takes a long time to send data in blocks, somi got mo other way other than doing poststart and postend requests.
On Thu, Jan 17, 2019 at 9:02 PM Timothy Woo notifications@github.com wrote:
Storing data to flash memory has nothing to do with the library itself, although the library does need to be able to handle the data that is sent to it in the postData() function. Storing large amounts of data to flash memory can either be hard-coded in the program using PROGMEM for AVR microcontrollers (which I'm assuming you won't want because you can't change it afterwards) or to use an ESP8266's SPIFFS file system or SD card. However, interfacing it with the library to handle those large amounts of data is a whole different story which I haven't investigated yet.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/52#issuecomment-455400768, or mute the thread https://github.com/notifications/unsubscribe-auth/AQarX6VTVcYh3vAWzA6jAjfF41MdxfMbks5vESs-gaJpZM4YzlYS .
-- Ammar Quaid Surti, Contact:+1-681-212-9752 Email: ammarqs@gmail.com;
`void SendPicture(){
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!")); // Turn on GPRS while (!fona.enableGPRS(true)) { Serial.println(F("Failed to enable GPRS, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Enabled GPRS!"));
uint16_t statuscode; int16_t length; char filename[14] = "1.jpg"; char url[80]; char contenttype[80]; char postdata[20000];
sprintf(url, "xx.xxx.xx.xx/process.php"); sprintf(contenttype, "multipart/form-data; boundary=AaB03x");
String start_request = ""; String end_request = ""; start_request = start_request + "\n" + "--AaB03x" + "\n" + "Content-Disposition: form-data; name=\"fileToUpload\"; filename="+filename+"\n" + "Content-Type: file" + "\n" + "Content-Transfer-Encoding: binary" + "\n" + "\n"; end_request = end_request + "\n" + "--AaB03x--" + "\n";
File myFile = SD.open("1.jpg"); uint16_t jpglen = myFile.size(); uint16_t extra_length; extra_length = start_request.length() + end_request.length(); uint16_t postdatalen = jpglen + extra_length;
if (myFile) { byte clientBuf[20000]; unsigned int clientCount = 0;
while(myFile.available()) { clientBuf[clientCount] = myFile.read(); clientCount++; } if(clientCount > 0) sprintf(postdata, "%s %s %s", start_request, clientBuf ,end_request); }
while (counter < 3 && !fona.HTTP_POST_start(url, F("multipart/form-data; boundary=AaB03x"), (uint8_t )postdata, postdatalen, &statuscode, (uint16_t )&length)); { Serial.println("Couldn't Post Data"); counter ++; } fona.HTTP_POST_end(); Serial.println("Image Sent");
delay(5000); }`
Ok now i see what you were saying. Using the flash memory can only be done initially while programming the controller, i cannot write variable to flash memory during live operation, right??
In general, correct.
right. appreciate for clearing out the confusion. I saw the update that you made yesterday for including the json script to postdata function. and also providing small hints on how the image can be sent. me and my other developer are still having issues to understanding the concept of sending images. We know for a fact that the usual post script where we can give the path of the location of the image wont work here. Here we have to send the raw format of the image to the server and then merge that on the server side, RIGHT? I am NOT asking you to help me out with the code, but just a walk through on what needs to be done in order to get this going, will help us to try and understand the concept of what needs to be done.
I tried doing your latest code down below, but i am pretty sure we are still missing on how to process the image in the script.
`void SendPicture(){
Serial.println(F("Entering SendPicture"));
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!")); // Turn on GPRS while (!fona.enableGPRS(true)) { Serial.println(F("Failed to enable GPRS, retrying...")); delay(2000); // Retry every 2s } Serial.println(F("Enabled GPRS!"));
uint16_t statuscode; int16_t length; char filename[14] = "1.jpg"; char url[80]; char contenttype[80];
sprintf(url, "xx.xxx.xx.xx/process.php"); sprintf(contenttype, "multipart/form-data; boundary=AaB03x");
File myFile = SD.open("1.jpg"); char body[150] = "{\"Content-Disposition\":\"form-data\",\"name\":\"file_upload\",\"filename\":\"1.jpg\"}";
uint16_t jpglen = myFile.size(); uint16_t postdatalen = jpglen + strlen(body); counter = 0; while (counter < 3 && !fona.postData("POST", url, body,"",postdatalen)); { Serial.println("Didn't Work!! Trying again!"); counter ++; }
Serial.println("File Sent"); } `
Well the problem is that right now the library function doesn't work alongside the SD card library. When you read the contents of a file on the SD card using the SD card library, it reads byte by byte and if you try to pass the data of a file that's too large to the postData() function, it won't work.
My previous issue was resolved. I was missing a library. After uploading the IoT_example code, and changing the APN to match our providers APN, the system is trying to enable GPRS but fails. Keep so retrying.![image](https://user-images.githubusercontent.com/17214303/49034155-19c0b380-f17f-11e8-8f5f-8d7b1f7197eb.png)