xiaoxiang781216 commented on code in PR #9916:
URL: https://github.com/apache/nuttx/pull/9916#discussion_r1277004925
##########
include/nuttx/sensors/sensor.h:
##########
@@ -595,6 +603,15 @@ struct sensor_cap /* Type: Capacitance */
int32_t rawdata[4]; /* in SI units pF */
};
+struct sensor_gas /* Type: Gas */
+{
+ uint64_t timestamp; /* Units is microseconds */
+ float temperature; /* Temperature in degrees Celsius */
+ float pressure; /* Pressure in millibar or hPa */
+ float humidity; /* Relative humidity in rH */
Review Comment:
> I did not know how to do that.
you can expose multiple topics from one sensor driver. For example,
https://github.com/apache/nuttx/blob/master/drivers/sensors/wtgahrs2.c
registers 5 topics.
> I thought there has to be a struct associated with the type of sensor, as
declared in the g_sensor_info array.
Yes, but it's better to make one topic just contain one physical
measurement. For example, IMU should expose three topics(gyro, accel and mag),
instead one topic with all value.
> Also, using 2 structs wouldn t mean having the timestamp twice?
Not necessary, you can get timestamp once, and reuse it for all push_event.
> I would appreciate it if you could give me a hint as to how i could reuse
sensor_baro and sensor_humi.
From
https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme680/,
BME680 can measure.gas, humidity and pressure individually, so it's better to
let driver report three topic(gas, humidity and pressure). Temperature is a
special one, since many measurement requires temperature to calibrate the
result, so it's contained in many sensor topic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]