diff --git a/src/shtc3.rs b/src/shtc3.rs index e7a69c4..50bff86 100644 --- a/src/shtc3.rs +++ b/src/shtc3.rs @@ -81,17 +81,20 @@ pub async fn task( let mut sht = ShtC3Instance::init(spio.reborrow(), sda.reborrow(), scl.reborrow(), ram); - match sht.measure().await { - Ok(measurement) => { - SHTC3_MEASUREMENT.signal(Shtc3Measurement::new(measurement)); - } - Err(e) => { - error!("SHTC3 error: {:?}", e); - - // Attempt to reset the sensor - if let Err(e) = sht.reset().await { - // Give up and try to reset the device through a panic. - panic!("SHTC3 reset error: {:?}", e); + 'measure: loop { + match sht.measure().await { + Ok(measurement) => { + SHTC3_MEASUREMENT.signal(Shtc3Measurement::new(measurement)); + break 'measure; + } + Err(e) => { + error!("SHTC3 error: {:?}", e); + + // Attempt to reset the sensor + if let Err(e) = sht.reset().await { + // Give up and try to reset the device through a panic. + panic!("SHTC3 reset error: {:?}", e); + } } } }