GSM Shield updates only once | Arduino | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
GSM Shield updates only once
No permission to create posts
July 31, 2016
6:14 pm
Avatar
aelizondo
New Member
Members
Forum Posts: 2
Member Since:
June 23, 2016
sp_UserOfflineSmall Offline

Hi,

I am using an Arduino Mega and a GSM Shield (M10 modem) to send data to ThingSpeak. I found some examples that show how to send one or more parameters after a given time period that work well, as long as I don't modify the loop code.

If I add the examples code as part of a longer/bigger program the data is updated in Thingspeak ONLY the first time that the program runs.

Has anyone have such issues before? I can post the code I used to update ThinSpeak.

Thanks in advance!

July 31, 2016
10:40 pm
Avatar
pramod
New Member
Members
Forum Posts: 3
Member Since:
July 19, 2016
sp_UserOfflineSmall Offline

aelizondo said
Hi,

I am using an Arduino Mega and a GSM Shield (M10 modem) to send data to ThingSpeak. I found some examples that show how to send one or more parameters after a given time period that work well, as long as I don't modify the loop code.

If I add the examples code as part of a longer/bigger program the data is updated in Thingspeak ONLY the first time that the program runs.

Has anyone have such issues before? I can post the code I used to update ThinSpeak.

Thanks in advance!  

Yes I also have same problem. I was able to see it also on mobile app ThingView. Then suddenly it stopped I see entries and last update information but no data on field chart. I see the chart records when I first connected .I can see total 139 entries. now no updates

August 1, 2016
6:57 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 210
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

Can you test connectivity from your GSM shield? Are you sure the GSM shield is not going into some sort of hibernate mode? Before you send data to thingspeak, can you program your device to ping http://www.thingspeak.com or http://www.mathworks.com? 

To troubleshoot, It would help if you linked your sketch here.

August 2, 2016
12:55 am
Avatar
pramod
New Member
Members
Forum Posts: 3
Member Since:
July 19, 2016
sp_UserOfflineSmall Offline

This is my code which is copied from " GSM-ParticulateSensor" example

void thingspeakPost() {

 
 
  char itoaBuffer[8];

  char end_c[2];
  end_c[0] = 0x1a;
  end_c[1] = '\0';

// PM25 int to char
  char data25[50];
  String str25;
  str25 = String(Pm25);
  str25.toCharArray(data25, 50);
 
// PM10 int to char  
  char data10[50];
  String str10;
  str10 = String(Pm10);
  str10.toCharArray(data10, 50);

if (inet.connectTCP(thingSpeakAddress, 80)) {

   Serial.println("connected to thingspeak");

   

    gsm.SimpleWrite("POST /update HTTP/1.1
");
   
    gsm.SimpleWrite("Host: api.thingspeak.com
");
    gsm.SimpleWrite("Connection: close
");
    gsm.SimpleWrite("X-THINGSPEAKAPIKEY:");
 
    gsm.SimpleWrite(writeAPIKey);
    gsm.SimpleWrite("
");
    gsm.SimpleWrite("Content-Type: application/x-www-form-urlencoded
");
    gsm.SimpleWrite("Content-Length: ");
   
   sprintf(sentMsg, "field1=%s", data25);
   itoa(strlen(sentMsg), itoaBuffer, 10);
 
    
    gsm.SimpleWrite(itoaBuffer);
    //inet.httpPOST("api.thingspeak.com", 80, "/update?key=B325M1U9WB2JGC9Z&field1= itoaBuffer");
  //gsm.SimpleWrite("PUT https://api.thingspeak.com/channels/137269/api_key=K9WNHI32J4346GL6");
   // gsm.SimpleWrite(" api_key=K9WNHI32J4346GL6");
   // gsm.SimpleWrite(" name=Updated Channel");
    
     //gsm.SimpleWrite(Pm25);
     gsm.SimpleWrite("

");

     gsm.SimpleWrite(sentMsg);

     gsm.SimpleWrite("

");

     gsm.SimpleWrite(end_c);
   delay(20000);
    Serial.println("update to thingspeak");

August 4, 2016
12:42 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 210
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

It appears that your code has some debugging statements it prints to the serial port. You should be able to program your arduino and monitor the output on the serial port to look at the messages are being printed. That will help you isolate the problem. Your starting point is to see what messages are being printed to the arduino serial monitor (Ctrl+Shift+M) in the Arduino IDE when your sketch is running. Try to write out some more messages using Serial.println() as debugging aids between the different steps. If your sketch is based on this one, are you seeing "failed" messages in your serial monitor? This would indicate that the connection is being dropped. etc.

Note that based on just this code snippet, depending on how often you call this function, you could be trying to post to http://www.thingspeak.com every 0.02 seconds. This is likely just wasting your GPRS data as the current data rate to http://www.thingspeak.com is one write per channel every 15 seconds.

August 18, 2016
11:24 pm
Avatar
aelizondo
New Member
Members
Forum Posts: 2
Member Since:
June 23, 2016
sp_UserOfflineSmall Offline

Hi,

Thanks for the recommendations and sorry about my delayed reply Vinod. I was using a different code than the one posted by pramod and I found the problem on mine. There were a couple of validations made every time the code ran, reading data from the website I was trying to connect to and then validating whether the client was still connected.

The example I used as a baseline made updates every 5 minutes and in my case I needed to send the udpates that were event triggered, so I got read of the two validations, forcing the client to connect when the event took place and diisconnect right after the update was made.

I hope this makes sense.

Alonso

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: samdavies
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Lakshmanaprakash S B, bettetj60, ronnievw3, bessiesj18, Pavan kumar, Williampup

Administrators: Hans: 387, lee: 457