diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c index f8861214f64..87f48245835 100644 --- a/drivers/sensors/sensor.c +++ b/drivers/sensors/sensor.c @@ -227,6 +227,10 @@ static const struct sensor_meta_s g_sensor_meta[] = {sizeof(struct sensor_voltage), "voltage"}, {sizeof(struct sensor_current), "current"}, {sizeof(struct sensor_power), "power"}, + {sizeof(struct sensor_resistance), "resistance"}, + {sizeof(struct sensor_conductivity), "conductivity"}, + {sizeof(struct sensor_energy), "energy"}, + {sizeof(struct sensor_charge), "charge"}, }; static const struct file_operations g_sensor_fops = diff --git a/include/nuttx/uorb.h b/include/nuttx/uorb.h index 72e2e1ab636..fc102fb782e 100644 --- a/include/nuttx/uorb.h +++ b/include/nuttx/uorb.h @@ -607,18 +607,52 @@ /* Power * A sensor of this type returns the measured instantaneous active power. - * The value is in SI units watt(W). The accumulated energy and the AC - * power components (reactive, apparent and power factor) are not covered - * by this type. + * The value is in SI units watt(W). The accumulated energy is reported by + * SENSOR_TYPE_ENERGY. The AC power components (reactive, apparent and + * power factor) are not covered by this type. */ #define SENSOR_TYPE_POWER 61 +/* Resistance + * A sensor of this type returns the measured DC resistance. The value is + * in SI units Ohm(Ω). Use SENSOR_TYPE_IMPEDANCE instead when the reactance + * is also needed. + */ + +#define SENSOR_TYPE_RESISTANCE 62 + +/* Electrical conductivity + * A sensor of this type returns the measured electrical conductivity of a + * medium. The value is in SI units siemens per metre(S/m), where 1 S/m + * equals 1e4 uS/cm. + */ + +#define SENSOR_TYPE_CONDUCTIVITY 63 + +/* Energy + * A sensor of this type returns the electrical energy accumulated since + * the accumulator was last reset. The value is in uJ, where 1 Wh equals + * 3.6e9 uJ. The value is signed: a negative value indicates that the + * energy flows in the direction opposite to the reference direction. + */ + +#define SENSOR_TYPE_ENERGY 64 + +/* Charge + * A sensor of this type returns the electrical charge accumulated since + * the accumulator was last reset, that is the time integral of the + * current. The value is in uC, where 1 Ah equals 3.6e9 uC. The value is + * signed and uses the same direction convention as SENSOR_TYPE_CURRENT. + */ + +#define SENSOR_TYPE_CHARGE 65 + /* The total number of sensor * please increase it if you added a new sensor type! */ -#define SENSOR_TYPE_COUNT 62 +#define SENSOR_TYPE_COUNT 66 /* The additional sensor open flags */ @@ -1075,6 +1109,30 @@ struct sensor_power /* Type: Power */ float power; /* Instantaneous active power in SI units W */ }; +struct sensor_resistance /* Type: Resistance */ +{ + uint64_t timestamp; /* Unit is microseconds */ + float resistance; /* in SI units Ohm(Ω) */ +}; + +struct sensor_conductivity /* Type: Electrical conductivity */ +{ + uint64_t timestamp; /* Unit is microseconds */ + float conductivity; /* in SI units S/m, 1 S/m = 1e4 uS/cm */ +}; + +struct sensor_energy /* Type: Energy */ +{ + uint64_t timestamp; /* Unit is microseconds */ + int64_t energy; /* Accumulated energy. Unit is uJ. */ +}; + +struct sensor_charge /* Type: Charge */ +{ + uint64_t timestamp; /* Unit is microseconds */ + int64_t charge; /* Accumulated charge. Unit is uC. */ +}; + struct sensor_gnss /* Type: GNSS */ { uint64_t timestamp; /* Time since system start, Units is microseconds */