Lucky Resistor
Menu
  • Home
  • Learn
    • Learn C++
    • Product Photography for Electronics
      • Required Equipment and Software
    • Soldering for Show
  • Projects
  • Libraries
  • Applications
  • Shop
  • About
    • About Me
    • Contact
    • Stay Informed
  •  
Menu

Data Logger Simple – Software Bugfix

Posted on 2015-08-312015-09-01 by Lucky Resistor

After analysing recorded data from the simple version of the data logger, I found a problem I had to fix with a new release v1.1 of the software.

If you look at this chart, which is showing data recorded in 30 second intervals, you can clearly see the values do not really change every 30 seconds.

Data Logger Problem Chart

The values change every 40 minutes and this can not be correct, even the sensor is slow. I found the problem in the DHT library from Adafruit. It is not actually a problem, but the library relies on the function millis() to measure the time between two reads.

From the DHT sensor library:

boolean DHT::read(void) {
  // Check if sensor was read less than two seconds ago and return early
  // to use last reading.
  uint32_t currenttime = millis();
  if (currenttime < _lastreadtime) {
    // ie there was a rollover
    _lastreadtime = 0;
  }
  if (!_firstreading && ((currenttime - _lastreadtime) < 2000)) {
    return _lastresult; // return last correct measurement
  }
  _firstreading = false;
  _lastreadtime = millis();

The function millis() relies on timer1 which is counting the time for this function. To save power, I put the microcontroller into sleep mode, which stops all timers except timer2. Therefore the time is not counted anymore, and millis() returns a wrong value.

I could just make a copy of the library and remove this part, but instead I created a own implementation which is simpler.

My own implementation has some limitations:

  • It only works with the DHT22 chip.
  • It requires a microprocessor with 16MHz or faster.
  • It only supports celsius as returned from the DHT22 chip.
  • It requires the AVR library.

Download the new version 1.1 of the data logger software here:

https://github.com/LuckyResistor/DataLoggerSimple/releases/tag/v1.1

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay Updated

Join me on Mastodon!

Top Posts & Pages

  • Storage Boxes System for 3D Print
  • Use Enum with More Class!
  • Simple Box with Lid for 3D-Print
  • Fan Controller
  • Shop
  • Real Time Counter and Integer Overflow
  • How and Why to use Namespaces
  • The Hinges and its Secrets for Perfect PETG Print
  • Extreme Integers – Doom from Below
  • Build a 3D Printer Enclosure

Latest Posts

  • The Importance of Wall Profiles in 3D Printing2023-02-12
  • The Hinges and its Secrets for Perfect PETG Print2023-02-07
  • Better Bridging with Slicer Guides2023-02-04
  • Stronger 3D Printed Parts with Vertical Perimeter Linking2023-02-02
  • Logic Gates Puzzle 1012023-02-02
  • Candlelight Emulation – Complexity with Layering2023-02-01
  • Three Ways to Integrate LED Light Into the Modular Lantern2023-01-29
  • The 3D Printed Modular Lantern2023-01-17

Categories

  • 3D Printing
  • Build
  • Common
  • Fail
  • Fun
  • Learn
  • Projects
  • Puzzle
  • Recommendations
  • Request for Comments
  • Review
  • Software
Copyright (c)2022 by Lucky Resistor. All rights reserved.
 

Loading Comments...