Hello Team,
I am going to use the MQTT Protocol, and i want to send data on JSON format is this possible. Because this i read your documents in that JSON formate AT command is only for HTTP and HTTPS protocol. if i want to use MQTT protocol then which language should we use to design the IOT page.
and another information required i am not using RTC then RTC sensor should give ground or VDD.
because my SDK is not load in module they stuck in middle i think this is because of RTC is goes in SLEEP mode so what should we do to WAKE UP this RTC.
Best Regard's
AK.
Hello,
Yes, you can definitely send data in JSON format over MQTT. While you mentioned that the AT commands you read only reference JSON for HTTP and HTTPS, MQTT can also handle JSON payloads. You just need to format your data as a JSON string before publishing it to the MQTT broker. Here's a basic example in Python:
import paho.mqtt.client as mqttimport json
# Define the MQTT settingsbroker_address = "your_broker_address"client = mqtt.Client("ClientID")
# Connect to the brokerclient.connect(broker_address)
# Prepare your data in JSON formatdata = { "temperature": 22.5, "humidity": 60}json_data = json.dumps(data)
# Publish the JSON dataclient.publish("your/topic", json_data)
# Disconnectclient.disconnect()
You can use any programming language that supports MQTT libraries (like Python, Java, C/C++, JavaScript, etc.) to design your IoT application.
Regarding the RTC (Real-Time Clock) connection:
Feel free to ask if you have any more questions or need further assistance!
Best regards,
Hello, i want make connection of two LED to this DA16200MOD for when transmission will happen that red will glow and receive time blue will glow so tell what to do in SDK file to this operation.thanks and regard's
Hi Ak,Thank you for the reply.
ak said: i want make connection of two LED to this DA16200MOD for when transmission will happen that red will glow and receive time blue will glow so tell what to do in SDK file to this operation.
Are you talking about Wi-Fi transmission or AT cmd transmissions?Generally for controlling LED, please refer on UM-WI-046 DA16200 DA16600 FreeRTOS SDK Programmer Guide (renesas.com) , on section 17.2 GPIO page:263Best Regards,OV_Renesas
hello,
Tell me for both wifi transmission and AT command transmission what to do in SDK.i read for GPIO just tell me for wifi transmission and AT command transmission.
i want to say when AT Command is send that time led glow same for receive side also. means we can get clarification of our data transmission not lost that the reason i am applying this. just like take example of HC05 Bluetooth LED function before connection state and after connection state and during transmission.
best regard's
kindly answer the question as soon as possible i am waiting your replay.
i read the GPIO API example but where to call in this function means in which file main.c,user.c or system start.c i am bit confuse.
thanks and regard's
AK
Hi AK,Thank you for the replies.It is not exactly clear what you are trying to achieve.However, for MQTT AT Commands you should use the following:When you send this AT command the following part will be executed in the atcmd.c file:
// AT+NWMQMSG else if (strcasecmp(argv[0] + 5, "MQMSG") == 0) { char *top; if (argc == 2 || argc == 3) { int rsp_val; /* AT+NWMQMSG=<msg>(,<topic>) (set only) */ if (strlen(argv[1]) > MQTT_MSG_MAX_LEN) { err_code = AT_CMD_ERR_NW_MQTT_PUB_MESSAGE_LEN; goto atcmd_network_end; } if (argc == 2) { top = NULL; } else if (argc == 3) { if (strlen(argv[2]) > MQTT_TOPIC_MAX_LEN) { err_code = AT_CMD_ERR_NW_MQTT_PUB_TOPIC_LEN; goto atcmd_network_end; } else { top = argv[2]; } } rsp_val = mqtt_client_send_message(top, argv[1]); if (rsp_val == -1) { err_code = AT_CMD_ERR_NW_MQTT_NOT_CONNECTED; } else if (rsp_val == -2) { // in-flight message is in progress err_code = AT_CMD_ERR_NW_MQTT_PUB_TX_IN_PROGRESS; } else if (rsp_val == -3) { // no topic in mqtt configuration err_code = AT_CMD_ERR_NW_MQTT_PUB_TOPIC_NOT_EXIST; } else if (rsp_val == 9 /* MOSQ_ERR_PAYLOAD_SIZE */) { // paylod too long err_code = AT_CMD_ERR_NW_MQTT_PUB_MESSAGE_LEN; } else { // pre-check passed ... if (dpm_mode_is_enabled() == pdTRUE) { if (mqtt_client_get_qos() > 0) { // qos 1 or 2 if (rsp_val != 0) { mqtt_client_convert_to_atcmd_err_code(&rsp_val, &err_code); } } else { // qos 0 if (rsp_val != 0) { mqtt_client_convert_to_atcmd_err_code(&rsp_val, &err_code); } else { // make async +NWMQMSGSND:1 to sync print atcmd_mqtt_qos0_msg_send_done_in_dpm = TRUE; atcmd_mqtt_qos0_msg_send_rc = 0; } } } } } else { err_code = AT_CMD_ERR_INSUFFICENT_ARGS; } }
void mqtt_client_convert_to_atcmd_err_code(int* err_code, int* atcmd_err_code) { int mosq_err_code = *err_code; if (mosq_err_code == MOSQ_ERR_INVAL || mosq_err_code == MOSQ_ERR_PAYLOAD_SIZE) { *atcmd_err_code = AT_CMD_ERR_WRONG_ARGUMENTS; } else if (mosq_err_code == MOSQ_ERR_NO_CONN || mosq_err_code == MOSQ_ERR_CONN_LOST) { *atcmd_err_code = AT_CMD_ERR_NOT_CONNECTED; } else { *atcmd_err_code = AT_CMD_ERR_UNKNOWN; } } void atcmd_asynchony_event_for_mqttmsgpub(int result, int err_code) { int atcmd_err; if (result == 1) { PRINTF_ATCMD("\r\n+NWMQMSGSND:1\r\n"); } else if (result == 0) { mqtt_client_convert_to_atcmd_err_code(&err_code, &atcmd_err); PRINTF_ATCMD("\r\n+NWMQMSGSND:0,%d\r\n", atcmd_err); } }
I understand.
now i am take one example of DA16200MOD for GPIO and i did build project it gives me error in wifi stack i am attaching the image just give me the solution.
Best Regards,
Hi AK,Thank you for the reply.Apologies for the delay but I was OOO.You are getting this kind of error on one of our default example projects?If yes, could you please shorten the path of your workspace? If you have modified the example, could you please share the modifications you have made?Best Regards,OV_Renesa
Hello , I have created IOT page on thingboard and try your command to send data it works but when i want to send my project data but it not work,send_command("AT+NWMQMSG={temperature:86},v1/devices/me/telemetry\r\n",53); <--->this command is working when i directly put value "temperature:86" like that, but in below code i idid using sprintf but it not working.
just check and give me solution which data type this command support.snprintf is not support to RX71 so i used sprintf.and one more question how much delay will be required while send and get response of command because it gives me error most of the time. i also try for long delay but issue i get remain. gives me this error :-1 which is
-1
AT_CMD_ERR_UNKNOWN_CMD
Unknown command
ERROR:-1....+NWMQCL:1..:-1...52.153....OK..K-CCMP][ESS].IOT.c0:c1:c0:a6:7f:2a.2462.-80.[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS].Cisco-D.f8:c4:f3:94:eb:01.2457.-90.[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS].Foro.dc:ef:09:0d:70:70.2472.-91."this is my MQTT thingboard link :- mosquitto_pub -d -q 1 -h mqtt.thingsboard.cloud -p 1883 -t v1/devices/me/telemetry -i "clientid" -u "username" -P "password" -m "{temperature:25}"this red part is JSON formate data.
#include "r_cg_macrodriver.h"#include "r_cg_cgc.h"#include "r_cg_sci.h"#include "r_cg_s12ad.h"/* Start user code for include. Do not edit comment generated here */#include <stdbool.h>#include <stddef.h>#include <string.h>
#include <stdio.h>
/* End user code. Do not edit comment generated here */#include "r_cg_userdefine.h"#include "r_cg_s12ad.h"
/***********************************************************************************************************************Global variables and functions***********************************************************************************************************************//* Start user code for global. Do not edit comment generated here */void send_command(uint8_t * const tx_buf, uint16_t tx_num);void delay(int t);void wifi_init();void wifi_scan();void LED_status();void LED_status_blinking();void LED_status_off();void LED_status_on();void LED_status_blinking_infinite();void mqtt_publish();bool check_for_string(const char* scan_result);void mqtt_setup();void LED_status_on_off();void wifi_status();void delay1(int t);
#define size 1000char receive_buffer[size];//bool flag=0;//uint8_t length=0;MD_STATUS responsStatus;int i=0;uint16_t ADC=0;uint8_t j=0;uint16_t g_data00=0;//uint16_t temperature=0;uint16_t min_value=1500;uint16_t max_value=2153;char *scan_result;char mqtt_message[100];uint8_t INC=0;char array2[300];char array3[600];char command[10];
#define BUFFER_SIZE 512 // Define an appropriate buffer size
static uint8_t buffer[BUFFER_SIZE]; // Buffer to store received datastatic uint16_t var = 0; uint16_t temperature=0;uint16_t g_data0=0;int attempt = 0;
/////Response///bool flag1=0;bool flag2=0;
void main(void){ R_MAIN_UserInit(); /* Start user code. Do not edit comment generated here */ R_SCI0_Start(); R_S12AD0_Start(); wifi_scan(); mqtt_setup(); while(1) {
sprintf(store,"%d",temperature); sprintf(command, "AT+NWMQMSG={temperature:%d},v1/devices/me/telemetry\r\n", store); send_command(command, strlen(command)); //delay(6000); // wifi_status(); // g_data0 = (uint16_t)(S12AD.ADDR0); // temperature = (g_data0 - 1973)*0.179; // sprintf(store,"%d",temperature); // Correct sprintf usage
//sprintf(command, "%d",temperature); send_command("AT+NWMQMSG={temperature:63},v1/devices/me/telemetry\r\n",53); delay(100); // if(0x45==receive_buffer[2] &&0x52==receive_buffer[3]&&0x52==receive_buffer[4]&&// 0x4F==receive_buffer[5]&&0x52==receive_buffer[6]&&0x3A==receive_buffer[7]// &&0x2D==receive_buffer[8]&&0x36==receive_buffer[9]&&0x33==receive_buffer[10]// &&0x34==receive_buffer[11])// {// send_command("AT+LEDCTRL=1,off\r\n",18); // delay(50);// }// sprintf(command, "AT+NWMQMSG={temperature:%s},v1/devices/me/telemetry\r\n", command);// send_command(command, strlen(command));// delay(100); //mqtt_publish();
} /* End user code. Do not edit comment generated here */}
Hi AK,Thank you for the reply.IF you are trying to connect to AWS Server via MQTT, please refer here: DA16200 DA16600 Getting Started with AWS IoT Core (renesas.com)You will need the AWS IoT Reference for FreeRTOS SDK or the AWS IoT ATCMD Image for FreeRTOS SDK which can be found on the DA16200/DA16200MOD/DA16600MOD product pages under Software Downloads;Please follow the ReadMe files on how to integrate the AWS features into the FreeRTOS SDK.If you are still facing issues, please attach a logic analyzer on the UART/SPI lines being used for AT command transport and share the capture with us.We would also like the full UART0 log files.Best Regards,OV_Renesas
hello, Yes i will try with this SDK images.
Best Regard'sAK