diff --git a/board/driver/mpx5100.h b/board/driver/mpx5100.h index 017bd68..60f0925 100644 --- a/board/driver/mpx5100.h +++ b/board/driver/mpx5100.h @@ -1,3 +1,10 @@ +#ifndef MPX5100_H +#define MPX5100_H + #include "../driver/adc.h" -// #define SIGNAL_OFFSET // This value corresponds to an air flow of 0 +#define MAX_PRESSURE 120 // Pressure in KPa + +float pascal, adc_val; +void getPascal(void); +#endif // MPX5100_H diff --git a/board/mpx5100/mpx5100.c b/board/mpx5100/mpx5100.c index 6f2ae19..5259818 100644 --- a/board/mpx5100/mpx5100.c +++ b/board/mpx5100/mpx5100.c @@ -1 +1,7 @@ #include "../driver/adc.h" + +void getPascal(void) { + adc_val = adcRead(); + pascal = ((adc_val / 1023) * MAX_PRESSURE) * 1000; + printf("%.2f Pa\n" pascal); +}