DA16200MOD MQTT JSON Formate AT Command communication.

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.  

  • Hi AK,

    Thank you for posting your questions online.

        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.

    You can use the JSON format with MQTT protocol.
    The DA16200 SDK supports JSON and we provide a sample code.
    The JSON sample code is located in the below SDK directory:
    [SDK root]/0.DOC/Doxygen/html/json.html


        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.

    Please refer on DA16200 Datasheet (renesas.com), on section 7.4 RTC, page:41


    The RTC GPIOs should be used to control the sleep modes.

    The API names to control the RTC_GPO are the following:

    /**
     ****************************************************************************************
     * @brief This function initializes the RTC_GPO pin.
     * @param[in] mode 0: Auto mode (output high in power on state and output low in sleep state)
     * 			  mode 1: Manual mode
     *
     ****************************************************************************************
     */
    void RTC_GPO_OUT_INIT(UINT8 mode);
    
    /**
     ****************************************************************************************
     * @brief Set RTC_GPO output level.
     * @param[in] value of GPO 0: low, 1: high
      *
     ****************************************************************************************
     */
    void RTC_GPO_OUT_CONTROL(UINT8 value);


    Best Regards,
    OV_Renesas

  • Hello,

    Using MQTT with JSON

    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 mqtt
    import json

    # Define the MQTT settings
    broker_address = "your_broker_address"
    client = mqtt.Client("ClientID")

    # Connect to the broker
    client.connect(broker_address)

    # Prepare your data in JSON format
    data = {
    "temperature": 22.5,
    "humidity": 60
    }
    json_data = json.dumps(data)

    # Publish the JSON data
    client.publish("your/topic", json_data)

    # Disconnect
    client.disconnect()

    You can use any programming language that supports MQTT libraries (like Python, Java, C/C++, JavaScript, etc.) to design your IoT application.

    RTC Connection

    Regarding the RTC (Real-Time Clock) connection:

    • If you're not using an RTC, typically, the RTC sensor should be connected to either GND (ground) or VDD (power), depending on how the sensor is designed.
    • If your RTC is in sleep mode and preventing your SDK from loading, you may need to wake it up. Here are some general approaches:
      • Check Datasheet: Review the RTC's datasheet to understand how to wake it up. Some RTCs have a specific pin or command for waking.
      • Interrupt Pin: If the RTC has an interrupt pin, you may be able to use a microcontroller GPIO to wake it.
      • Power Cycle: Sometimes, simply cycling the power to the RTC can wake it up.

    Next Steps

    • Ensure that your code correctly handles the initialization of the RTC.
    • Double-check the wiring and power supply to the RTC module to ensure it's functioning correctly.
    • If you continue to experience issues, consider reaching out to the manufacturer or looking into their forums for troubleshooting specific to your RTC model.

    Feel free to ask if you have any more questions or need further assistance!

    Best regards,

  • Hello,

                 I successfully load the SDK and i get AT command OK.the problem which i face is in PDF of DA16200MOD has no mention RTC Sensor Pin function so i keep this pin open so that why the SDK is not loading at that time.so i read in one pdf and as you suggest that this PIN should be GND or VDD according sensor design. i make this PIN GND and SDK load.

      

  • 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

    AK.

  • Hi Ak,

    Thank you for the reply.

      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:263


    Best 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

    AK.

  • hello,

                         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;
            }
        }

    You can either turn ON the LED when it enters in that if statement, or directly inside the mqtt_client_send_message API.
    Then after the if statement controlling the rsp_val is being handled you can turn the LED off. Or you can do this on the same file on the following APIs:

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

    This way, when you try to publish a MQTT message you will turn on the LED while the MQTT transmission is in progress, and when you receive the MQTT result (so no Wi-Fi transmission is on going) you will turn the LED OFF.

    If you want to implement this behavior for every AT command:
    On the atcmd.c file you can see that we have multiple functions to control the AT commands based on their features.
    Those are:
    1. help_command 
    2. atcmd_standard
    3. atcmd_uartconf
    4. atcmd_basic
    5. atcmd_dpm
    6. atcmd_wifi
    7. atcmd_network
    8. atcmd_transport
    9. atcmd_transport_ssl
    10. atcmd_testmode
    11. atcmd_rftest
    12. atcmd_rftx
    13. atcmd_tfcwttest
    14. atcmd_rf_per
    15. atcmd_rf_cont
    16. atcmd_chan
    etc. 

    At the start of these functions you can turn on the LED and when these functions return the status (Error Code or OK) you can turn the LED off.
    If you do not want to edit all those functions, you can just directly edit the command_parser API (on the atcmd.c file) and open the LED on there and turn it OFF when you have received the response message.


    Best Regards,
    OV_Renesas


  • hello,

            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,

    AK 

                 

  • 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