This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sending Sensor data from nRF9160dk to the server

Hello,

I am working on nRF9160dk. I have interfaced a GNSS sensor with nRF9160 using UART and receive the data continuously. When there is an interrupt, this data is send to the user via SMS. Now I want to update this sensor data continously on the server. So what is the starting point for this? Which example I should start to connect to the server and send the data continuously?

Thank you

Parents
  • Hi,

     

    Now I want to update this sensor data continously on the server. So what is the starting point for this? Which example I should start to connect to the server and send the data continuously?

    What protocol are you using? UDP or TCP based? MQTT, CoAP? Do you have a server already up-and-running, or are you planning to set up one?

     

    Kind regards,

    Håkon

  • I tried using mqtt_simple example. I have never worked on mqtt, so I don't know much about it. Is it correct to use mqtt to send data continuously to server or is there any other way for nRF9160dk? Right now I am using mqtt.eclipse.org as MQTT Broker, which is already configured for mqtt_simple sample.

  • The nRF9160 can do TCP / UDP, so you are free to choose which ever implementation that fits your application best.

    If MQTT is the best approach for your application, you can choose that. However; I would strongly recommend that you do not use a public mqtt broker, as everyone can then listen in to your device's messages.

     

    Kind regards,

    Håkon

Reply
  • The nRF9160 can do TCP / UDP, so you are free to choose which ever implementation that fits your application best.

    If MQTT is the best approach for your application, you can choose that. However; I would strongly recommend that you do not use a public mqtt broker, as everyone can then listen in to your device's messages.

     

    Kind regards,

    Håkon

Children
  • Hello,

    I tried the MQTT example. It is working properly. When I publish the data on some topic, I can receive the data on the subscribed topic. So my question is how to access this published data on the server anytime? It means I am sending the GNSS data on my server and I want to check this data anytime even if the board is off. I want to access the data on the server at any given time. So how this is done?I used MQTT.fx to publish and subscribe with the mqtt example. It is very confusing, please help me with this.

    Thanks

  • Hi,

     

    MQTT has a feature called retained message, which you can use for this purpose.

    The mqtt library in zephyr supports setting this bit field: https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/master/include/net/mqtt.h#L242

    Kind regards,

    Håkon

  • It is working. Thank you so much.

    I still have a MQTT related question. Can I publish a text file to MQTT broker? My SD card is interfaced to nRF52840 using SPI. I will take this text file on nRF9160dk using SPI. So is it possible to publish this text file to MQTT broker? If yes, how to do this?

    Now I am using test.mosquitto.org for testing purpose. But later I am planning to set a Virtual Private Server for this.

  • Hi,

     

    MQTT is the transport layer, so I suspect you can send files as well, but I haven't tried this myself.

    According to this thread on stack overflow, it seems to be possible: https://stackoverflow.com/a/55811751

     

    Kind regards,

    Håkon

  • Hello,

    Now by using MQTT protocol I can send the data to mqtt server through nrf91. I read other articles, from that it is clear that data is not stored on the mqtt server. I should store this data in a database to access it later. So how this can be done on nrf91? I read that MySQL database or MongoDB are used to store the data. So can this be done through nrf91? Is there any way to store the server data in a database when using nrf91 as a publisher for the server data?