1310 Trouble Connecting to Arduino Cloud

I am using the arduino cloud to create devices and dashboards for my data. I am having alot of issues with getting the data from the devices to arduino.

I keep getting the following message from the device serial port. "Message ack was not received, the message could not be delivered."

On TTN I can see the data transmission, but I also see the following error message. "Fail to send webhook."

Does anyone know what might be wrong? I have a paid cloud account with Arduino, but they seem to ignore support emails.

Hello @tlampher,

I'm an Arduino employee.

I have seen that you have multiple devices registered in the TTN, so I want to know if you are facing a problem with every device or only with just one.

For example, for your device eui-a8610a3032348d11 the last message that I see is on 2023-09-18 at 19:18:54 UTC. Did you disconnect this device? Eventually, could you reconnect it, please?

Thanks.

Yes, I have 12 devices. I do have problems with all of them from time to time. I find I need to reset them many times to get them to connect. Example, that board you saw with message sent was 1 of 4 boards I had running, I reset the other 3 boards several times trying to get them to connect, they all seemed to connect, but were not able to get a message sent with success. I will be back in office tomorrow and can get all 4 of them powered up again and will just leaving them running.

I have 4 of them powered up now for you.

Hi,

Yes, I see them and in particular one of these has started to forward some uplink messages.

image

I don't know why the other ones don't work, maybe do they have a different sketch or something else?

They are all running the same sketch minus the secret tab info for the device info.

It could be a connection problem to the gateway. Are you using your gateway?

You can try to connect one device at time and check if the uplink message is forwarded correctly.

It is my own gateway. Like I said in first message I keep seeing the Fail to Send Webhook.

You can check if all data come in your gateway in order to understand where the problem is.

Anyway, I saw that another device (eui-a8610a3032398c11) had forwarded some uplink messages.

I just connected to the board and reset it. See attached pictures. Everything looks ok on TTN, but I did see "Message ack was not received, the message could not be delivered" on the serial port of the board.

I did a screen shot of the board serial port, the device and gateway on TTN.



@tlampher
i cannot see any application message in your screenshot. Selecting your end-device on the thing stack portal you should see something like this:

Can you double check if you see any "Forward uplink data message"

Correct. That is what I am seeing. I left that board connected the rest of the day and saw nothing from it and on the serial port of that board I kept seeing that same error message. The 2 other boards I was able to reset and both of those seemed to connect back up without issue. So yesterday 2 of the 4 worked and 2 didn't. I have not found anything different between them.

The 2 boards that were not working yesterday are the 2 that I added this year. I added the devices in the Arduino cloud and when I attached them to my thing, neither one of them filled in the secret tab info, I had to manually add those. I got that info by looking at them on TTN and filled the info in on Arduino from there before I uploaded the sketch to the boards.

Could that be an issue? That was the first time I have ever had to do that though and I have had these issues since I started using them last year. I have not been able to figure out the cause and it seems this issue can be with any boards.

I just connected to the other board that was not connecting yesterday and am seeing the same message on the serial port.

@tlampher th error: "Message ack was not received, the message could not be delivered" is al LoRa level so i suspect something is not working between your board and your gateway.

What happens if you try to connect only one board at time? Do you see any "Forward uplink data message" from your board to your gateway?

Can you share the sketch running on your boards?

Today I am just running the one board that I know is an issue board. The gateway they are connected to is in my office. I have the same results with the other gateway that is in the field.

Here is the code....

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/c3d8c0da-29c2-405e-b87c-d6f96d8662a5 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float co2;
  float humidity;
  float o2;
  float temp;
  int co2base;
  int tvocbase;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Wire.h>
#include "Adafruit_SGP30.h"



Adafruit_SGP30 sgp;



uint32_t getAbsoluteHumidity(float temperature, float humidity) {
    // approximation formula from Sensirion SGP30 Driver Integration chapter 3.15
    const float absoluteHumidity = 216.7f * ((humidity / 100.0f) * 6.112f * exp((17.62f * temperature) / (243.12f + temperature)) / (273.15f + temperature)); // [g/m^3]
    const uint32_t absoluteHumidityScaled = static_cast<uint32_t>(1000.0f * absoluteHumidity); // [mg/m^3]
    return absoluteHumidityScaled;
}

#define DHTPIN 2     // Digital pin connected to the DHT sensor 


#define DHTTYPE    DHT22     // DHT 22 (AM2302)



DHT_Unified dht(DHTPIN, DHTTYPE);


int counter = 0;
int cycles = 27;
const float VRefer = 3.3;       // voltage of adc reference for o2 sensor
const int pinAdc   = A1;  //pin connected for o2 sensor


void setup() {
  pinMode(LED_BUILTIN, OUTPUT); //used for low power mode
  

  
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  

  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();
  

  
  dht.begin();
  sgp.begin();
  //sgp.setIAQBaseline(37336, 36900);  //sets baseline at power up for the co2,tvoc readings
  
  sensor_t sensor;
  dht.temperature().getSensor(&sensor);
  dht.humidity().getSensor(&sensor);

}

void loop() {
ArduinoCloud.update(); //sends data to arduino cloud 
 
  

  
  if(cycles == 30) {
    cycles = 0;
  
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  
  sensors_event_t event;
  dht.temperature().getEvent(&event);
    temp = event.temperature * 1.8 + 32;
  // Get humidity event and print its value.
  dht.humidity().getEvent(&event);
    humidity = event.relative_humidity;
    delay(500);
    
  sgp.setHumidity(getAbsoluteHumidity(event.temperature, humidity)); //used for temp and humidity compensation on co2
  delay(500);
  sgp.IAQmeasure();
  co2 = (sgp.eCO2);
 
  delay(1000);

  counter++;
  if (counter == 10) {
    counter = 0;

    uint16_t TVOC_base, eCO2_base;
    if (! sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) {
      Serial.println("Failed to get baseline readings");
      return;
    }
    Serial.print("****Baseline values: eCO2: "); Serial.print(eCO2_base);
    Serial.print(" & TVOC: "); Serial.println(TVOC_base);
    co2base = eCO2_base;
    tvocbase = TVOC_base;
  }
  //Begin code for o2 sensor reading
  float measureO2V = analogRead(pinAdc) * VRefer/1023;
  float o2concentration = measureO2V * 0.21/2.4;
  o2 = o2concentration * 100;

  Serial.print("cycles; ");
  Serial.println(cycles);
  Serial.print("counter: ");
  Serial.println(counter);
  Serial.println(temp);
  Serial.println(humidity);
  Serial.println(o2);
  Serial.println(co2);


    


  }
  else {
    cycles ++;
  }


delay(2000); 
} //end of loop







/*
  Since Co2Base is READ_WRITE variable, onCo2BaseChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCo2BaseChange()  {
  // Add your code here to act upon Co2Base change
  sgp.setIAQBaseline(co2base, tvocbase);  //sets baseline at power up for the co2,tvoc readings
  Serial.println("Co2 Base Change Received");
}

/*
  Since Tvocbase is READ_WRITE variable, onTvocbaseChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTvocbaseChange()  {
  // Add your code here to act upon Tvocbase change
  sgp.setIAQBaseline(co2base, tvocbase);
  Serial.println("TVOC Base Change Received");
}

@tlampher The boards that aere working are running the same sketch?

You should not use delay in your loop(), you can use a non blocking delay like this if you need to wait in your loop.

I would also suggest you to try a much more simpler sketch to debug your connection issue, one variable, used as a counter should be fine.

Yes, all are running the same sketch. I will try removing the delay.

I removed the both delays that were in my loop and have the same results. Get same message on serial port and see nothing on TTN after the initial connection.

I need to take back what I said. I had a few more delays in the loop that I missed. I now removed those and now that those are removed it will not connect at all. I just keep seeing failed to connect retrying in 500ms on the serial print out now.

can you share your thingProperties.h file also? That print should occur when using WiFi not LoRa ...