Hi, I'm currently trying to send real time analog sensor data to hivemq broker using nrf9160 DK, is it possible to provide source code for this kind of project? I've attached my current code below as well. Thanks
Hi, I'm currently trying to send real time analog sensor data to hivemq broker using nrf9160 DK, is it possible to provide source code for this kind of project? I've attached my current code below as well. Thanks
Hi,
is it possible to provide source code for this kind of project?
What do you mean by this? Could you explain some more?
We are currently connecting a sensor to nrf9160_dk and we have successfully gotten the data and print them on serial monitor. We have also succesully connected lte link to print simple string on mqtt broker(hivemq) by using the mqtt_simple sample source code. So we are trying to send the data from the sensors to the mqtt broker but we are unable to do that. Do you have any example that sends the sensor data to mqtt broker?
chow said:Do you have any example that sends the sensor data to mqtt broker?
We have, as you have likely already seen, the mqtt_simple sample. https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.0/nrf/samples/nrf9160/mqtt_simple/README.html
Use the function data_publish() to send/publish the data to the MQTT broker.
Hi, mqtt_simple example to publish my data out. I am including data_publish function to sent out the string "test" if my data is being collected and shown in the terminal. However, I am not able to publish the data to the broker. I am including the data_publish function in adc_sample_event and I am using a timer to call the function. The modification can be seen from line 614 onwards. Can i get some advise from this?
Hi, mqtt_simple example to publish my data out. I am including data_publish function to sent out the string "test" if my data is being collected and shown in the terminal. However, I am not able to publish the data to the broker. I am including the data_publish function in adc_sample_event and I am using a timer to call the function. The modification can be seen from line 614 onwards. Can i get some advise from this?
I see you have this line in adc_sample_event().
data_publish(&client, MQTT_QOS_1_AT_LEAST_ONCE, "test!", 14);
You should check the return code of the function, see the snippet below. (and also 14 is not the correct length of the string you are sending)
Snippet:
int ret;
ret = data_publish(&client,
MQTT_QOS_1_AT_LEAST_ONCE,
your_data,
length_of_your_data);
if (ret) {
LOG_ERR("Publish failed: %d", ret);
}Hi, I have added the code above in my function and I am still having the same issue.
Also, the data I am currently getting is in integer form, but the data_publich function require char form, may I know how to convert integer to char?
yeo said:I have added the code above in my function and I am still having the same issue.
And did you get any errors returned?
yeo said:but the data_publich function require char form
No, it's just a uint8_t buffer
it does not publish anything after u added the code.