Hi!
I am using the MQTT simple sample that i have modified to continuously send data after receiving a message.
I also have connected a MS5837 pressure sensor to the nRF9160, and i would like to send the pressure data over LTE-M with the data_publish() function. The MS5837 is a supported by Zephyr, and i implemented the sensor example in the MQTT simple https://github.com/zephyrproject-rtos/zephyr/tree/master/samples/sensor/ms5837.
The publishing loop will look something like this:
while (1) { struct sensor_value temp; struct sensor_value press; sensor_sample_fetch(dev); sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press); printf("Temperature: %d.%06d, Pressure: %d.%06d\n", temp.val1, temp.val2, press.val1, press.val2); k_sleep(1000); data_publish(&client, MQTT_QOS_1_AT_LEAST_ONCE, temp.val1, sizeof(temp.val1)); k_sleep(1000); data_publish2(&client, MQTT_QOS_1_AT_LEAST_ONCE, press.val1, sizeof(press.val1)) }
The problem is that the sensor value is represented into an integer and a fractional part, press.val1 and press.val2. Is there a simple way of using the data_publish() function with the sensor value peripherals? Or must this be represented in a static u8_t char buffer?
Best regards,
Ivar