-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNS - Low Pressure Sensor #73
base: main
Are you sure you want to change the base?
SNS - Low Pressure Sensor #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, a few wee things + you need to add hyped_adc
as a dependency for hyped_sensors
. We're still figuring out whether or not we'll have tests for ADC sensors, so feel free to leave that for now
removed no_std and no_main to try and remove the "no #[panic_handler]" error |
…ent-low-pressure-sensor
telemetry jumpscare doesn't look like this is something i can fix? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, main thing is adding sensor bounds and checking with Samuel if you haven't already that you're converting the ADC reading to pressure correctly
let adc_val = self.adc.read_value() as f32; | ||
|
||
// convert to bar unit | ||
let bar_pressure_val: f32 = adc_val * GRADIENT_LOW; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirm with Samuel that this conversion is correct
lib/sensors/src/low_pressure.rs
Outdated
/// 4096 is the maximum ADC reading value. | ||
/// Since LPS has a minimum pressure of 0 bar, c0 is 0 and was did not need to be included in | ||
/// the source code. | ||
pub fn read_pressure(&mut self) -> f32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read_pressure
should return an f32
wrapped in a SensorValueRange
- we want to know whether a value is too high or too low. Have a look at temperature sensor for an example of sensor bounds :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll also need to define a default calculate_bounds
function for this
loop { | ||
info!("{}", low_pressure_sensor.read_pressure()); | ||
Timer::after(Duration::from_millis(100)).await; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're loop here will need to match on the SensorValueRange
to determine whether it's a critical, warning, or safe reading once that's implemented
#[embassy_executor::main] | ||
async fn main(_spawner: Spawner) -> ! { | ||
let p = embassy_stm32::init(Default::default()); | ||
info!("Low pressure sensor"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info!("Low pressure sensor"); |
not really necessary
No description provided.