Lines Matching +full:humidity +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Honeywell HIH-6130/HIH-6131 humidity and temperature sensor driver
9 * Data sheets available (2012-06-22) at
18 #include <linux/hwmon-sysfs.h>
26 * struct hih6130 - HIH-6130 device specific data
32 * @humidity: cached humidity measurement value
41 int humidity; member
46 * hih6130_temp_ticks_to_millicelsius() - convert raw temperature ticks to
48 * @ticks: temperature ticks value received from sensor
55 * Formula T = ( ticks / ( 2^14 - 2 ) ) * 165 -40 in hih6130_temp_ticks_to_millicelsius()
57 return (DIV_ROUND_CLOSEST(ticks * 1650, 16382) - 400) * 100; in hih6130_temp_ticks_to_millicelsius()
61 * hih6130_rh_ticks_to_per_cent_mille() - convert raw humidity ticks to
62 * one-thousandths of a percent relative humidity
63 * @ticks: humidity ticks value received from sensor
70 * Formula RH = ( ticks / ( 2^14 -2 ) ) * 100 in hih6130_rh_ticks_to_per_cent_mille()
76 * hih6130_update_measurements() - get updated measurements from device
84 struct i2c_client *client = hih6130->client; in hih6130_update_measurements()
90 .addr = client->addr, in hih6130_update_measurements()
97 mutex_lock(&hih6130->lock); in hih6130_update_measurements()
100 * While the measurement can be completed in ~40ms the sensor takes in hih6130_update_measurements()
103 * The datasheet specifies maximum 'Response time' for humidity at 8s in hih6130_update_measurements()
105 * We therefore choose to only read the sensor at most once per second. in hih6130_update_measurements()
106 * This trades off pointless activity polling the sensor much faster in hih6130_update_measurements()
110 if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) { in hih6130_update_measurements()
116 * length packets we write one dummy byte to allow sensor in hih6130_update_measurements()
120 ret = i2c_master_send(client, tmp, hih6130->write_length); in hih6130_update_measurements()
127 ret = i2c_transfer(client->adapter, msgs, 1); in hih6130_update_measurements()
132 dev_err(&client->dev, "Error while reading measurement result\n"); in hih6130_update_measurements()
133 ret = -EIO; in hih6130_update_measurements()
138 hih6130->humidity = hih6130_rh_ticks_to_per_cent_mille(t); in hih6130_update_measurements()
141 hih6130->temperature = hih6130_temp_ticks_to_millicelsius(t); in hih6130_update_measurements()
143 hih6130->last_update = jiffies; in hih6130_update_measurements()
144 hih6130->valid = true; in hih6130_update_measurements()
147 mutex_unlock(&hih6130->lock); in hih6130_update_measurements()
153 * hih6130_temperature_show() - show temperature measurement value in sysfs
171 return sprintf(buf, "%d\n", hih6130->temperature); in hih6130_temperature_show()
175 * hih6130_humidity_show() - show humidity measurement value in sysfs
192 return sprintf(buf, "%d\n", hih6130->humidity); in hih6130_humidity_show()
209 struct device *dev = &client->dev; in hih6130_probe()
213 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in hih6130_probe()
214 dev_err(&client->dev, "adapter does not support true I2C\n"); in hih6130_probe()
215 return -ENODEV; in hih6130_probe()
220 return -ENOMEM; in hih6130_probe()
222 hih6130->client = client; in hih6130_probe()
223 mutex_init(&hih6130->lock); in hih6130_probe()
225 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK)) in hih6130_probe()
226 hih6130->write_length = 1; in hih6130_probe()
228 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, in hih6130_probe()
259 MODULE_DESCRIPTION("Honeywell HIH-6130 humidity and temperature sensor driver");