0

Adafruit io not receiving data
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Adafruit io not receiving data

by OneH2 on Sat Jan 02, 2021 3:01 pm

Can someone help me, I am having an issue where I am publishing data to different feeds in different groups. I kept getting a throttle warning so i paid to increase my rate on adafruit io now the issue i started facing lately is that the same feeds i publish to are not being updated, they randomly update and then do not update for hours and days before updating again.

I hope you can help because this is inconveniencing me a little as I have no means of monitoring my devices.

I am using a SIM7000A with an arduino mega.

OneH2
 
Posts: 6
Joined: Wed Dec 04, 2019 12:33 pm

Re: Adafruit io not receiving data

by brubell on Mon Jan 04, 2021 11:48 am

now the issue i started facing lately is that the same feeds i publish to are not being updated, they randomly update and then do not update for hours and days before updating again.


Since you're using a cellular modem instead of WiFi, the time to update a feed is expected to be longer. But the amount of time you specified seems too long...


Could you please paste your code below? If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

brubell
 
Posts: 1381
Joined: Fri Jul 17, 2015 10:33 pm

Re: Adafruit io not receiving data

by OneH2 on Mon Jan 04, 2021 1:41 pm

Code: Select all | TOGGLE FULL SIZE
void setup() {
  TCCR5B = (TCCR5B & 0xF8) | 0x01; // Very important: Sets PWM frequency for PWM pins 44/45/46 to 31.4 KHz instead of 490Hz
  pinModeSetup();
  matrixSetup(" HASKEL COMP 1 ", "");
 
  Serial.println("=========================================== fona setup ==============================================");
  fonaSetup();
 
 
  xTaskCreate( vTaskMQTT, (const portCHAR *)"MQTT", 1024, NULL, 1, NULL );
  xTaskCreate( vTaskLED, (const portCHAR *)"LED", 512, NULL, 2, NULL );

}

void loop() {
  // put your main code here, to run repeatedly:

}


static void vTaskMQTT( void *arg ){
    Serial.println(F("======= MQTT SUBSCRIBE ======"));
   
    mqtt.subscribe(&feed_command);
    Serial.println(F("====entering loop====="));
    uint32_t currentTime;
    prevCommsTime = millis();
    // this is loop for task that will run with other loop task
    //this loop is required because if we dont have one the task will end at the last function
    while( 1 ) {
        currentTime = millis();
             
        //Read and write to Adafruit every COMMS_RATE seconds
        Serial.println("---------Time--------");
        Serial.println(currentTime - prevCommsTime);
        if((currentTime - prevCommsTime) >= (COMMS_RATE * 1000)){

             
            Serial.println("Tasking");
            prevCommsTime = currentTime;
           
            Serial.println(F("=== connecting... ==="));
            networkConnect();
            Serial.println(F("=== done...read mqtt ==="));
            Adafruit_MQTT_Subscribe *subscription;
            char* cmd = NULL;
            while ((subscription = mqtt.readSubscription(5000))) {
                if (subscription == &feed_command) {
                    cmd = (char*)feed_command.lastread;
                }
                Serial.println(F("==== LOOP MQTT ===="));
            }
            if( cmd != NULL ) {
                Serial.print(F(" rec : "));
                Serial.println(cmd);
                readCommand(cmd);
            } else  {
                Serial.println(F("========== no command detected ======="));
            }

            Serial.println(F("===publishing==="));

            char suctionPressBuff[12];
            dtostrf(suctionP, 1, 2, suctionPressBuff);

            char dischargePressBuff[12];
            dtostrf(dischargeP, 1, 2, dischargePressBuff);
           
            char hydPressBuff[12];
            dtostrf(hydP, 1, 2, hydPressBuff);
           
            char dischargeTempBuff[12];
            dtostrf(dischargeT, 1, 2, dischargeTempBuff);

            char oilTempBuff[12];
            dtostrf(oilT, 1, 2, oilTempBuff);

            char coolantTempBuff[12];
            dtostrf(coolantT, 1, 2, coolantTempBuff);
           
            feed_cursuctionpress.publish(suctionPressBuff);
            feed_curdischargepress.publish(dischargePressBuff);
            feed_curhydpress.publish(hydPressBuff);
           
            feed_curdischargetemp.publish(dischargeTempBuff);
            feed_curcoolanttemp.publish(coolantTempBuff);
            feed_curoiltemp.publish(oilTempBuff);

            if(digitalRead(O_PUMP_ON) == HIGH){
              DI = 1;
              feed_hydpump.publish(DI);
            }else{
              DI = 0;
              feed_hydpump.publish(DI);
            }

            if(digitalRead(O_COOLANT_PUMP) == HIGH){
              DI = 1;
              feed_coolantpump.publish(DI);
            }else{
              DI = 0;
              feed_coolantpump.publish(DI);
            }

            if(digitalRead(O_COOLANT_FAN) == HIGH){
              DI = 1;
              feed_coolantfan.publish(DI);
            }else{
              DI = 0;
              feed_coolantfan.publish(DI);
            }

            if(digitalRead(O_INPUT_VALVE) == HIGH){
              DI = 1;
              feed_inputvalve.publish(DI);
            }else{
              DI = 0;
              feed_inputvalve.publish(DI);
            }

            if(digitalRead(O_DCV_OUT) == HIGH){
              DI = 1;
              feed_dcvout.publish(DI);
            }else{
              DI = 0;
              feed_dcvout.publish(DI);
            }

            if(digitalRead(O_DCV_IN) == HIGH){
              DI = 1;
              feed_dcvin.publish(DI);
            }else{
              DI = 0;
              feed_dcvin.publish(DI);
            }

            if(digitalRead(D_ENDSTROKE1) == HIGH){
              DI = 1;
              feed_endstroke1.publish(DI);
            }else{
              DI = 0;
              feed_endstroke1.publish(DI);
            }
           
            if(digitalRead(D_ENDSTROKE2) == HIGH){
              DI = 1;
              feed_endstroke2.publish(DI);
            }else{
              DI = 0;
              feed_endstroke2.publish(DI);
            }

            if(digitalRead(D_ESTOP_SWITCH) == HIGH){
              DI = 1;
              feed_estop.publish(DI);
            }else{
              DI = 0;
              feed_estop.publish(DI);
            }

            if(digitalRead(D_FLUIDOK) == HIGH){
              DI = 1;
              feed_fluidok.publish(DI);
            }else{
              DI = 0;
              feed_fluidok.publish(DI);
            }

            if(digitalRead(D_COOLANT_FLOW) == HIGH){
              DI = 1;
              feed_coolantflow.publish(DI);
            }else{
              DI = 0;
              feed_coolantflow.publish(DI);
            }
           
        }
        vTaskDelay(1); // this delay is required so processor can release a task for a moment
    }
}

static void vTaskLED( void *arg ){
    Serial.println("====== > start task led");
    uint32_t currentTime = 0;
    uint32_t displayTimer = millis();
    boolean updateOnce = false;
    while( 1 ){
        currentTime = millis();       
        //Read and print new pressure values every INTERVAL milliseconds
        if((currentTime - prevReadTime) >= READ_INTERVAL){
            prevReadTime = currentTime;

            suctionP = suction_calc(20);
            dischargeP = discharge_calc(20);
            hydP = hydraulic_calc(20);
            bigMatrix[0].writeInt(suctionP);
            bigMatrix[1].writeInt(dischargeP);
            bigMatrix[2].writeInt(hydP);
            Serial.println(suctionP);
            Serial.println(dischargeP);
            Serial.println(hydP);
           
           
        } 

        val = analogRead(A_GASPIN);
        //If estop OK and vals OK, actionStroke()
        if(digitalRead(D_ESTOP_SWITCH)){
          if(val > 160){
            prevDCV[0] = 1;
            digitalWrite(O_DCV_OUT, LOW);
            digitalWrite(O_DCV_IN, LOW);
            //publish Exception (Gas Leak Detected)
          }else{
            if(oilTemp < 20 ){
              digitalWrite(O_COOLANT_PUMP, LOW);
              digitalWrite(O_COOLANT_FAN, LOW);
              digitalWrite(O_INPUT_VALVE, LOW);
              digitalWrite(O_PUMP_ON, LOW);
              prevDCV[0] = 1;
              digitalWrite(O_DCV_IN, LOW);
              digitalWrite(O_DCV_OUT, LOW);
            }else if (oilTemp > 50 ){
              digitalWrite(O_PUMP_ON, LOW);
              digitalWrite(O_COOLANT_PUMP, HIGH);
              digitalWrite(O_COOLANT_FAN, HIGH);
              digitalWrite(O_INPUT_VALVE, LOW);
              prevDCV[0] = 1;
              digitalWrite(O_DCV_IN, LOW);
              digitalWrite(O_DCV_OUT, LOW);
            }
            else if(oilTemp > 20 && oilTemp < 50){
              digitalWrite(O_PUMP_ON, HIGH);
              vTaskDelay(30);
              digitalWrite(O_COOLANT_PUMP, HIGH);
              digitalWrite(O_COOLANT_FAN, HIGH);

              if(suctionP < MIN_SUCTIONPRESS){

                digitalWrite(O_INPUT_VALVE, HIGH);

                if(dischargeP >= MAX_DISCHARGEPRESS){
                  prevDCV[0] = 1;
                  digitalWrite(O_DCV_IN, LOW);
                  digitalWrite(O_DCV_OUT, LOW);
                  //digitalWrite(O_PUMP_ON, LOW);
                  toLowest = true;
                  alreadyTurnedOn = false;
                }else if(dischargeP <= MAX_DISCHARGEPRESS - 600){
                 
                  actionStroke();
                  alreadyTurnedOn = true;
                  toLowest = false;
                }else{
                  if(!alreadyTurnedOn && !toLowest){
                    actionStroke();
                  }
                }
               
              }else{
                digitalWrite(O_INPUT_VALVE, LOW);
                prevDCV[0] = 1;
                digitalWrite(O_DCV_IN, LOW);
                digitalWrite(O_DCV_OUT, LOW);
              }
             
            }else{
              prevDCV[0] = 1;
              digitalWrite(O_DCV_IN, LOW);
              digitalWrite(O_DCV_OUT, LOW);
              digitalWrite(O_PUMP_ON ,LOW);
              digitalWrite(O_COOLANT_FAN, LOW);
              digitalWrite(O_COOLANT_PUMP, LOW);
            }
          }
        }else {
          prevDCV[0] = 1;
          equipmentOn(false);
          digitalWrite(O_DCV_OUT, LOW);
          digitalWrite(O_DCV_IN, LOW);
          digitalWrite(O_INPUT_VALVE, LOW);
        }
       
        potToTemp();
       
        //check if lcd will be used to display data from mqtt
        if(!useForMQTT){
            lcdDisplay();
            //tell mqtttask that lcd is released, no data from this task will be displayed
            resourceReleased = false;
        } else {
            // tells taskMQTT that resource might be in use
            resourceReleased = true; 
        }
        vTaskDelay(10); // needed (10mS, smaller or higher), so the task is not creating busy loop
    }
}

void actionStroke(){
  if(prevDCV[0] == 1) {
    if(prevDCV[1] == 1) {
      digitalWrite(O_DCV_OUT, HIGH);
      digitalWrite(O_DCV_IN, LOW);
      prevDCV[0] = 0;
    }
    else if(prevDCV[1] == 2){
      digitalWrite(O_DCV_IN, HIGH);
      digitalWrite(O_DCV_OUT, LOW);
      prevDCV[0] = 0;
    }
  }
  else if(digitalRead(D_ENDSTROKE1)){
    digitalWrite(O_DCV_OUT, HIGH);
    digitalWrite(O_DCV_IN, LOW);
    prevDCV[1] = 1;
  }
  else if(digitalRead(D_ENDSTROKE2)){
    digitalWrite(O_DCV_IN, HIGH);
    digitalWrite(O_DCV_OUT, LOW);
    prevDCV[1] = 2;                                                         
  }

}


void equipmentOn(bool on){
  if(on){
    digitalWrite(O_PUMP_ON, HIGH);
    digitalWrite(O_COOLANT_PUMP, HIGH);
   
    digitalWrite(O_COOLANT_FAN, HIGH);
    digitalWrite(O_INPUT_VALVE, HIGH);
  }
  else{
    Serial.println("////////////////////////Equipment not on\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
    digitalWrite(O_COOLANT_PUMP, LOW);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    digitalWrite(O_PUMP_ON, LOW);
    digitalWrite(O_COOLANT_FAN, LOW);
    digitalWrite(O_INPUT_VALVE, LOW);
  }
 
}

//function to check data (type char) is a characted a to z lower case or upper case
boolean isChar( char data ){
    return ( (data >='a' && data <='z') || ( data >= 'A' && data <= 'Z' ) );
}

//function to check data (type char) is a digit from 0 to 9
boolean isNumber( char data ){
    return  data >='0' && data <='9';
}


uint32_t timerDisplay = 0;
boolean updateDisplayOnce = false;


void readCommand(char* cmd) {
  char cmdHeader[3] = "";
  strncat(cmdHeader, cmd, 2);
  double cmdBody = 0.0;
  //check is the first data is character
  if( isChar( cmd[0] ) ){
      uint8_t indexNumber = 0;
      //if it is, search until data is not a character, so we can assume that was a digit
      while( isChar( cmd[indexNumber++] ) );
      indexNumber--;
      //last index is index+1 of data which not a character because ++ operand
      //so we need to substract one

      // check if it is a digit if it is convert to float
      if( isNumber( cmd[indexNumber] ) ) {
          cmdBody = atof(cmd+indexNumber); 
      } 
  } else {
      // check is digit if it is convert to float
      if( isNumber(cmd[0]) ){
          cmdBody = atof(cmd);
      }
  }
/*--------------------------------------------------------------------------------My command set(Will change over time)---------------------------------------------------------------*/
  if(strcmp(cmd, "Chiller")== 0){
    Serial.println("Chiller setting");
    digitalWrite(O_COOLANT_FAN, !digitalRead(O_COOLANT_FAN));
  }
  else if(strcmp(cmd, "MainRelayo")== 0){
    Serial.println("Main relay on");
    digitalWrite(O_COOLANT_PUMP, !digitalRead(O_COOLANT_PUMP));
  }
  else if(strcmp(cmd, "Inputvalve")== 0){
    Serial.println("Input valve");
    digitalWrite(O_INPUT_VALVE, !digitalRead(O_INPUT_VALVE));
  }
  else if(strcmp(cmd, "Softstarto")== 0){
    Serial.println("Soft Start on");
    digitalWrite(O_PUMP_ON, !digitalRead(O_PUMP_ON));
  }
  else if(strcmp(cmd, "Dischargelow") == 0){
    MAX_DISCHARGEPRESS = 6750;
  }
  else if (strcmp(cmd, "DischargeHigh") == 0){
    MAX_DISCHARGEPRESS = 7500;
  }
  else if(strcmp(cmd, "DischargeTemp")){
    MAX_DISCHARGETEMP = 230;
  }
  else if(strcmp(cmd, "Suctionpress")){
    MIN_SUCTIONPRESS = 500;
  }
/*--------------------------------------------------------------------------------End of Command set-----------------------------------------------------------------------------------*/

 // uint32_t indicator2 = (int) cmdBody;
//  feed_indicator2.publish(indicator2);
  if( cmdBody > 0.0 ){
      Serial.print(F("========== contain a number : "));
      Serial.print(cmdBody);
      Serial.println(F(" ============"));
  }
  // tell task led that taskMQTT wants to use the lcd
  useForMQTT = true;
  Serial.println("waiting resource");
  while( !resourceReleased )
    vTaskDelay(30);
  Serial.println("resource released");
  lcd.clear();
  lcd.setCursor( 0, 0 );
  lcd.print(F("                "));
  lcd.setCursor( 0, 1 );
  lcd.print(F("                "));
  lcd.setCursor(0,0);
  lcd.print("Cmd: ");
  lcd.print(cmdHeader);
  lcd.print(" ");
  lcd.print(cmdBody);
  vTaskDelay(500);
  // tell taskLED that mqtt is done using lcd
  useForMQTT = false;
 
}

void lcdDisplay(){

  smallMatrix[0].squareDisplay((digitalRead(D_ENDSTROKE1)) ? 15 : 1);
  smallMatrix[1].squareDisplay((digitalRead(D_ENDSTROKE2)) ? 15 : 1);
  smallMatrix[2].squareDisplay((digitalRead(D_ESTOP_SWITCH)) ? 15 : 1);


  //Serial.print("Oil Temp : ");
  //Serial.println(oilTemp);
 
  lcd.setCursor( 0, 0);
  lcd.print( F( "  HASKEL COMP 1 " ) );
  lcd.setCursor(0, 1);
  lcd.print(oilTemp);
  lcd.setCursor(5, 1);
  lcd.print(coolantTemp);
  lcd.setCursor(10, 1);
  lcd.print(dischargeTemp);
  lcd.setCursor(15, 1);
 
}

void matrixSetup(String s1, String s2) {
  //begin matrices
  for(int i = 0; i < 3; i++){
    smallMatrix[i].begin();
    bigMatrix[i].begin();
  }

  //begin LCD
  lcd.begin(16,2);
  lcd.clear();
  lcd.print(s1);
  lcd.setCursor(0,1);
  lcd.print(s2);
  lcd.setBacklight(HIGH);
}


void pinModeSetup() {
  pinMode(ESTOP_BREAK, OUTPUT);
  digitalWrite(ESTOP_BREAK, HIGH); // HIGH to keep Estop loop intact
  pinMode(LED_PWR, OUTPUT);
  digitalWrite(LED_PWR, HIGH); // HIGH to provide power to Daughterboard
  pinMode(TRACO_24VDC, OUTPUT);
  digitalWrite(TRACO_24VDC, HIGH); // HIGH to enable 24V Power Supply

  //Digital inputs
  pinMode(D_ESTOP_SWITCH, INPUT);
  //pinMode(D_MAIN_RELAY_FEEDBACK, INPUT);
  //pinMode(D_FILTEROK, INPUT);
  pinMode(D_COOLANT_FLOW, INPUT);
  pinMode(D_FLUIDOK, INPUT);

  //Digital Outputs
  pinMode(O_INPUT_VALVE, OUTPUT);
  pinMode(O_PUMP_ON, OUTPUT);
  pinMode(O_COOLANT_FAN, OUTPUT);
  pinMode(O_COOLANT_PUMP, OUTPUT);
  pinMode(O_TEMP_READ, OUTPUT);
  digitalWrite(O_TEMP_READ, HIGH);
  //digitalWrite(D_ESTOP_SWITCH, HIGH);
}

int myCount = 0;
int countto = 100;//500;
long int n1temp = 0;
long int n2temp = 0;
long int n3temp = 0;
long int mtemp = 0;

const int thresh = 50;
float n1, n2, n3, m, k, R, Temp;
const int Rc = 10000;
int Rm = 426;
float a, b, c;

void potToTemp() {
  if (myCount < countto) {
    m = analogRead(A7);
    while (m > 50) {
      digitalWrite(42, LOW);
      delayMicroseconds(5);
      digitalWrite(42, HIGH);
      m = analogRead(A7);
    }
    digitalWrite(42, LOW);
    delayMicroseconds(5);
    digitalWrite(42, HIGH);
    n1 = analogRead(A7);
    n1temp += n1;
    digitalWrite(42, LOW);
    delayMicroseconds(5);
    digitalWrite(42, HIGH);
    n2 = analogRead(A7);
    n2temp += n2;
    digitalWrite(42, LOW);
    delayMicroseconds(5);
    digitalWrite(42, HIGH);
    n3 = analogRead(A7);
    n3temp += n3;
    digitalWrite(42, LOW);
    delayMicroseconds(5);
    digitalWrite(42, HIGH);
    m = analogRead(A7);
    mtemp += m;
    myCount++;
  } else {
    myCount = -1;
    n1 = (float)n1temp / countto;
    n2 = (float)n2temp / countto;
    n3 = (float)n3temp / countto;
    m = (float)mtemp / countto;
    n1temp = 0;
    n2temp = 0;
    n3temp = 0;
    mtemp = 0;

    R = (m - n1) * (Rc + Rm) / n1;
    Serial.println(R);   
    Temp = 1.0 / (1 / 298.15 + log(R / 10000.0) / 3994.4);
    Temp = Temp + .0000007318 * pow(Temp, 3) - .001011 * pow(Temp, 2) + .4318 * Temp - 58.23 - 273.15;
    oilTemp = Temp;
    oilT = oilTemp;

    R = (m - n2) * (Rc + Rm) / n2;
    Temp = 1.0 / (1 / 298.15 + log(R / 10000.0) / 3994.4);
    Temp = Temp + .0000007318 * pow(Temp, 3) - .001011 * pow(Temp, 2) + .4318 * Temp - 58.23 - 273.15;
    coolantTemp = Temp;
    coolantT = coolantTemp;

    R = (m - n3) * (Rc + Rm) / n3;
   
    Temp = 1.0 / (1 / 298.15 + log(R / 10000.0) / 3994.4);
    Temp = Temp + .0000007318 * pow(Temp, 3) - .001011 * pow(Temp, 2) + .4318 * Temp - 58.23 - 273.15;
    dischargeTemp = Temp;
    dischargeT = dischargeTemp;
  }
  myCount++;
}

float suction_calc(int numReadings) {
  float total = 0.0;
  float average = 0.0;
  float portVal = 0.0;
  for (int i = 0; i < numReadings; i++) {
    portVal = analogRead(A_SUCTIONPRESS);
    total += portVal;
  }
  average = total / numReadings;
  double sensorVoltage = average * (5.0/1023.0);
  return (sensorVoltage * 10000.0) / 5.0 - 2000;

}

float discharge_calc(int numReadings) {
  float total = 0.0;
  float average = 0.0;
  float portVal = 0.0;
  for (int i = 0; i < numReadings; i++) {
    portVal = analogRead(A_DISCHARGEPRESS);
    total += portVal;
  }
  average = total / numReadings;
  double sensorVoltage = average * (5.0/1023.0);
  return (sensorVoltage * 10000.0) / 5.0 - 2000;
}

float hydraulic_calc(int numReadings) {
  float total = 0.0;
  float average = 0.0;
  float portVal = 0.0;
  for (int i = 0; i < numReadings; i++) {
    portVal = analogRead(A_HYDRAULICPRESS);
    total += portVal;
  }
  average = total / numReadings;
  double sensorVoltage = average * (5.0/1023.0);
  return (sensorVoltage * 10000.0) / 5.0 - 2000;

}

void networkConnect(){
  // next optimalization, getnetworkstatus might be better if it is called only
  // if mqtt.connect is false because mqtt.connect is doing tcpConnection check on fona library
 
  int n = fona.getNetworkStatus();
  Serial.print(F("Network status ")); Serial.println(n);
  Serial.println(F("waiting network status"));
  while(n != 5){
    vTaskDelay(300);
    n = fona.getNetworkStatus();
    Serial.print(F("Network status ")); Serial.print(n);
  }
  Serial.println("done, waiting mqtt connect");
  if (!mqtt.connected()) {
    while(mqtt.connect() != 0){
      mqtt.disconnect();
      vTaskDelay(300);
    }
  }
  Serial.println(F("mqtt connection done"));
}

void fonaSetup(){
  Serial.begin(9600);
  delay(100);
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH);
  pinMode(FONA_PWRKEY, OUTPUT);

  //power on
  digitalWrite(FONA_PWRKEY, LOW);
  delay(100);
  digitalWrite(FONA_PWRKEY, HIGH);

  //set up module
  fonaSS.begin(115200);
  fonaSS.println("AT+IPR=9600");//configure baud rate
  fonaSS.begin(9600);
  //fonaSerial -> begin(115200);
  if (! fona.begin(fonaSS)) {
    Serial.println(F("Couldn't find FONA"));
    lcd.setCursor(0,1);
    lcd.print("Couldn't find FONA");
    Serial.println(F("reseting arduino...."));
    delay(1000);
    resetArduino(); // this is how to call function pointer to reset the arduino
  }

  fona.setFunctionality(1); // AT+CFUN=1
  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card
  uint8_t i = 0;
  while (!fona.enableGPS(true)) {
    Serial.println(F("Failed to turn on GPS, retrying..."));
    vTaskDelay(300); // Retry every 2s
    i++;
    if( i > 10 ){
        Serial.println(F("reseting arduino..."));
        delay(1000);
        resetArduino(); 
    }
  }

  // Disable GPRS just to make sure it was actually off so that we can turn it on
  if (!fona.enableGPRS(false)){
    Serial.println(F("Failed to disable GPRS!"));
   
  }
 
  // Turn on GPRS
  i = 0;
  while (!fona.enableGPRS(true)) {
    Serial.println(F("Failed to enable GPRS, retrying..."));
    delay(300); // Retry every 2s
    i++;
    if( i > 10 ){
        Serial.println(F("reseting arduino..."));
        delay(1000);
        resetArduino(); 
    }
  }
  Serial.println(F("Turned on GPRS!"));


  lcd.setCursor(0,1);
  lcd.print("FONA Setup ");
}

OneH2
 
Posts: 6
Joined: Wed Dec 04, 2019 12:33 pm

Re: Adafruit io not receiving data

by OneH2 on Mon Jan 04, 2021 1:43 pm

So I publish to adafruit every 30 seconds which is why t he publishing is wrapped around an if statement, I also was thinking this could be an issue with my IO+ account?

OneH2
 
Posts: 6
Joined: Wed Dec 04, 2019 12:33 pm

Re: Adafruit io not receiving data

by OneH2 on Mon Jan 04, 2021 3:08 pm

brubell wrote:
now the issue i started facing lately is that the same feeds i publish to are not being updated, they randomly update and then do not update for hours and days before updating again.


Since you're using a cellular modem instead of WiFi, the time to update a feed is expected to be longer. But the amount of time you specified seems too long...


Could you please paste your code below? If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.



So I just encountered this problem and i re uploaded my arduino code and it started working again for 30 minutes then stopped for an hour.

OneH2
 
Posts: 6
Joined: Wed Dec 04, 2019 12:33 pm

Re: Adafruit io not receiving data

by brubell on Wed Jan 06, 2021 12:03 pm

OneH2 wrote:So I publish to adafruit every 30 seconds which is why t he publishing is wrapped around an if statement, I also was thinking this could be an issue with my IO+ account?


You could monitor your device's calls to IO over on this page: http://io.adafruit.com/monitor

It also may be an issue with the cellular network connectivity.

Here's what I think is happening: You are using MQTT to connect to Adafruit IO, and your requests are taking >30 minutes. It's possible that IO's server is disconnecting your client because you are not sending requests within the MQTT KeepAlive interval.

brubell
 
Posts: 1381
Joined: Fri Jul 17, 2015 10:33 pm

Re: Adafruit io not receiving data

by OneH2 on Thu Jan 07, 2021 10:44 am

brubell wrote:
OneH2 wrote:So I publish to adafruit every 30 seconds which is why t he publishing is wrapped around an if statement, I also was thinking this could be an issue with my IO+ account?


You could monitor your device's calls to IO over on this page: http://io.adafruit.com/monitor

It also may be an issue with the cellular network connectivity.

Here's what I think is happening: You are using MQTT to connect to Adafruit IO, and your requests are taking >30 minutes. It's possible that IO's server is disconnecting your client because you are not sending requests within the MQTT KeepAlive interval.


I think you are correct, I think it is losing connectivity because it gets stuck at the networkConnect() function which is what I think is happening.

OneH2
 
Posts: 6
Joined: Wed Dec 04, 2019 12:33 pm

Please be positive and constructive with your questions and comments.