Skip to content

Commit

Permalink
Average three measurements for analogRead
Browse files Browse the repository at this point in the history
  • Loading branch information
watsaig committed Apr 3, 2018
1 parent 47fe903 commit e3424e7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/things.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ void PressureController::setValue(uint8_t value)

uint8_t PressureController::getValue()
{
int val = analogRead(mMeasurementPin);
long val = analogRead(mMeasurementPin);
val += analogRead(mMeasurementPin);
val += analogRead(mMeasurementPin);
val = round(double(val)/3.0);



/* The result of analogRead doesn't correspond linearly to the voltage applied;
see: https://github.com/espressif/esp-idf/issues/164
Expand Down

0 comments on commit e3424e7

Please sign in to comment.