Skip to content

Commit 8be9fdd

Browse files
committed
bugfix: fixes #506
1 parent 8c2eb63 commit 8be9fdd

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

components/si7021/si7021.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ static const char *TAG = "si7021";
5757
#define CMD_READ_USER_REG 0xe7
5858
#define CMD_WRITE_HEATER_REG 0x51
5959
#define CMD_READ_HEATER_REG 0x11
60-
#define CMD_READ_ID_1 0xfa0f
61-
#define CMD_READ_ID_2 0xfcc9
62-
#define CMD_READ_FW_REV_1 0x84b8
60+
#define CMD_READ_ID_1 0x0ffa
61+
#define CMD_READ_ID_2 0xc9fc
62+
#define CMD_READ_FW_REV_1 0xb884
6363

6464
#define BIT_USER_REG_RES0 0
6565
#define BIT_USER_REG_HTRE 2
@@ -316,3 +316,16 @@ esp_err_t si7021_get_device_id(i2c_dev_t *dev, si7021_device_id_t *id)
316316

317317
return ESP_OK;
318318
}
319+
320+
esp_err_t si7021_get_device_revision(i2c_dev_t *dev, uint8_t *rev)
321+
{
322+
CHECK_ARG(dev && rev);
323+
324+
uint16_t cmd = CMD_READ_FW_REV_1;
325+
326+
I2C_DEV_TAKE_MUTEX(dev);
327+
I2C_DEV_CHECK(dev, i2c_dev_read(dev, &cmd, 2, rev, 1));
328+
I2C_DEV_GIVE_MUTEX(dev);
329+
330+
return ESP_OK;
331+
}

components/si7021/si7021.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ esp_err_t si7021_get_serial(i2c_dev_t *dev, uint64_t *serial, bool sht2x_mode);
229229
*/
230230
esp_err_t si7021_get_device_id(i2c_dev_t *dev, si7021_device_id_t *id);
231231

232+
/**
233+
* @brief Get device revision
234+
*
235+
* This function is supported by:
236+
*
237+
* - SI7013
238+
* - SI7020
239+
* - SI7021
240+
*
241+
* @param dev Device descriptor
242+
* @param[out] id Device revision
243+
* @return `ESP_OK` on success
244+
*/
245+
esp_err_t si7021_get_device_revision(i2c_dev_t *dev, uint8_t *rev);
246+
232247
#ifdef __cplusplus
233248
}
234249
#endif

0 commit comments

Comments
 (0)