adafruit / adafruit/TinyDHT

output precision up to 1 decimal place

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
45
Forks
19
PR merge metrics
No merged PRs in 30d

Description

It is not bad if the data is output with 1 decimal place.
like in following example:

TinyDHT.h

uint8_t readHumidity(void); -> float readHumidity(void);
int16_t readTemperature(bool S = false); -> float readTemperature(bool S = false);

TinyDHT.cpp

int16_t DHT::readTemperature(bool S) { -> float DHT::readTemperature(bool S) {
int16_t f; -> float f;
f = (int16_t)data[2]; -> f = (float)data[2];
f = (int16_t)(data[2] & 0x7F); -> f = (float)(data[2] & 0x7F);
f += (int16_t)data[3]; -> f += (float)data[3];

int8_t DHT::readHumidity(void) { // 0-100 % -> float DHT::readHumidity(void) { // 0-100 %
uint8_t f; -> float f;
uint16_t f2; // bigger to allow for math operations -> float f2; // bigger to allow for math operations
f2 = (uint16_t)data[0]; -> f2 = (float)data[0];
f = (uint8_t)f2; -> f = (float)f2;

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the declarations in TinyDHT.h with the implementations in TinyDHT.cpp, focusing on readTemperature and readHumidity and their current numeric types. The change is done when these readings support the requested fractional precision consistently in the library API and implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.