GSM Shield updates only once | Arduino | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
GSM Shield updates only once
Avatar
aelizondo
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
1
July 31, 2016 - 6:14 pm
sp_Permalink sp_Print sp_EditHistory

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!

Avatar
pramod
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
2
July 31, 2016 - 10:40 pm
sp_Permalink sp_Print

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

Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
3
August 1, 2016 - 6:57 pm
sp_Permalink sp_Print

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.

Avatar
pramod
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
4
August 2, 2016 - 12:55 am
sp_Permalink sp_Print

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");

Avatar
Vinod

Forum Posts: 179
sp_UserOfflineSmall Offline
5
August 4, 2016 - 12:42 am
sp_Permalink sp_Print

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.

Avatar
aelizondo
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
6
August 18, 2016 - 11:24 pm
sp_Permalink sp_Print

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: cstapels
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

yeseniara11

RomanFug

JamesPes

RobertBak

ScottSmiva

Amourhotte

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee