# ESP32 YYS sensor component for ESP-IDF providing CO, O2, H2S and CH4
Component for Espressif ESP32 ESP-IDF framework.
This component uses the subcomponent esp32_rmt_uart_v5 for receiving the data from the YYS sensor. Because of this dependency this component only works for ESP-IDF v5.x.
The communication protocol is as follows:

Details about the sensor can be found [here](https://de.aliexpress.com/item/1005010209724834.html?spm=a2g0o.productlist.main.6.4a0b9dBR9dBRrQ&algo_pvid=ff99cfd1-e39e-472e-8c4b-4d8884de2e22&algo_exp_id=ff99cfd1-e39e-472e-8c4b-4d8884de2e22-5&pdp_ext_f=%7B%22order%22%3A%22-1%22%2C%22eval%22%3A%221%22%2C%22fromPage%22%3A%22search%22%7D&pdp_npi=6%40dis%21EUR%21145.73%21145.73%21%21%211177.16%211177.16%21%402103956a17659116410254998eb4f0%2112000051528573107%21sea%21AT%210%21ABX%211%210%21n_tag%3A-29910%3Bd%3A617b50a6%3Bm03_new_user%3A-29895&curPageLogUid=BVERnWH3u9qS&utparam-url=scene%3Asearch%7Cquery_from%3A%7Cx_object_id%3A1005010209724834%7C_p_origin_prod%3A#nav-specification)
## How to Use
Clone this repository to your project components directory.
## Configuration
```c
typedef struct yys_sensor_s {
char *name; /*!< Optional name of this sensor */
uint8_t *buffer; /*!< Buffer for received sensor data */
int baudrate; /*!< baud rate, normally 9600 */
uint8_t rx_pin; /*!< Receive I/O pin */
uint8_t cnt; /*!< Internal bit receive counter */
yys_values_t values; /*!< Latest values */
uint16_t error_cnt; /*!< Receive error counter */
uint8_t data_cnt; /*!< Receive data counter */
bool data_ready; /*!< New data available flag */
uint8_t debug; /*!< Bitmask for debugging */
} yys_sensor_t;
```
Every second an update is sent by the sensor.
idf.py add-dependency "brmmm3/esp32_yys^1.0.6"