Data added through MQTT but graph and export shows none

Jitse el 15 de Mayo de 2023
Actividad más reciente Edición por Christopher Stapels a las el 16 de Mayo de 2023

This is weird to me.
I am connected through a SIM7060 module to mqtt3.thingspeak.com on port 1883
I have an IP address., I am connected to the MQTT server.
I see the number of entries increasing in my channel. However, no data visible in the graph.
This is the AT command to the SIM7080 module : AT+SMPUB="channels/**********/publish",37,1,1
And then I send the payload : field1=1&field2=2&field3=3&field4=400
As said, each time a send a request I see the number of entries increasing, but no real data.
The export shows me this :
created_at,entry_id,field1,field2,field3,field4
2023-05-15 17:33:40 UTC,1,,,,
2023-05-15 17:34:59 UTC,2,,,,
2023-05-15 17:36:16 UTC,3,,,,
2023-05-15 17:37:31 UTC,4,,,,
2023-05-15 17:38:48 UTC,5,,,,
Any idea why the content of the field is empty?
Thanks
Christopher Stapels
Christopher Stapels el 15 de Mayo de 2023 (Editada a las el 15 de Mayo de 2023)
Can you test using a different client, such as MQTTx? I just tested with one of my channels and it seems to be working fine. Ill try your exact publish syntax.
Jitse
Jitse el 15 de Mayo de 2023
Thanks for the attention.
What do you mean with MQTTx.
This is what I use now :Serial2.print("AT+SMCONF=\"URL\",\"mqtt3.thingspeak.com\",\"1883\"\r\n");
And the SIM module confirms the connection.
Thanks
Christopher Stapels
Christopher Stapels el 15 de Mayo de 2023
Its a desktop client. See the doc page on using desktop MQTT client for more info.
There is also a page of troubleshooting. It is possible that you did not enable your MQTT device for both publish and subscribe, or that you have an unexpected or unseen character in your payload. Also, I have seen cases where the MQTT library has a limited buffer that is really small so it cuts off the payload. Generally you can expand the size to fix the problem.
Jitse
Jitse el 16 de Mayo de 2023
Well finally solved this weird problem.
After sending an AT command to the module SIM7080 I weight for a response (normally OK).
But in order to speed things up (it will be battery operated device), i left out the wait command between :
sending the SMPUB command and sending out the payload.
And this lack of delay between commands caused this very weird issue. Ha Ha
Thanks
Mqtt_Message="AT+SMPUB=\"channels/"+ ChannelId+"/publish\","+String(Payload_Length)+",1,1\r\n"; //https://nl.mathworks.com/help/thingspeak/publishtoachannelfeed.html
Serial.println(Mqtt_Message);
Serial2.print(Mqtt_Message);//Serial2.print("AT+SMPUB=\"channels/888617/publish/fields/field1\",1,1,1\r\n"); // lengte moet goed zijn
Read_Response_WaitFor("OK",SIMWaitTime);
Serial.println(Receive_buffer);
Serial2.print(payload);
Read_Response_WaitFor("OK",SIMWaitTime);
Serial.println(Receive_buffer);
Christopher Stapels
Christopher Stapels el 16 de Mayo de 2023 (Editada a las el 16 de Mayo de 2023)
Glad you found the solution and thanks for posting it! I know for the REST API, you need to wait for the server response before disconnecting, im not as clear on the MQTT timing. Still, I'm happy to hear your project is working now!
Jitse
1
Publicación
2
Responder

Etiquetas

Aún no se han introducido etiquetas.