Skip to main content
Arduino

Timeline for Help with getting Sensor Average using Arrays

Current License: CC BY-SA 3.0

4 events
when toggle format what by license comment
Feb 25, 2020 at 13:35 comment added Christoph Cool! I was wondering exactly that: is it "allowed" to already take a first sensor reading in setup()? So if it is, it sounds like it's the simplest solution (instead of adding a flag-variable or even a class). I realize that "simplest" is not always the same as "most elegant". Thanks!
Feb 25, 2020 at 9:05 comment added Edgar Bonet @Christoph: Initializing tempC[i] the way you suggest would indeed improve the first readings, at the cost of slightly increased complexity. The most elegant implementation would probably be a "filter" class that handles the initialization itself when it gets the first reading. The simplest would be to explicitly initialize the array in setup().
Feb 25, 2020 at 7:43 comment added Christoph I wonder whether this code could be (very slightly) improved by initializing tempC[i] with the first raw_temp reading? Wouldn't this significantly increase the accuracy of the first readings (i.e. tempC[i])? In many use cases, this will not matter practically but in some it might, especially if numReadings and/or printInterval is high. So if you agree, what would be the most elegant way to implement this?
Jun 8, 2016 at 20:13 history answered Edgar Bonet CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /