Calculate temperature from thermistor resistance
This commit is contained in:
21
src/main.c
21
src/main.c
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
// TODO: Convert raw data from ADS1115 to usable values.
|
||||
// TODO: Implement optional CRC8 sensor measurement check.
|
||||
// TODO: Either implement software PWM for the FAN03 timer
|
||||
// (which will be quite complicated) or pick a chip with
|
||||
@@ -97,7 +96,7 @@ static int Init(void)
|
||||
static void Update(void)
|
||||
{
|
||||
float temp[3], rh[3];
|
||||
short adc[4];
|
||||
float adct[3];
|
||||
|
||||
Info("Reading sensor values...");
|
||||
|
||||
@@ -110,16 +109,16 @@ static void Update(void)
|
||||
I2C_SetChannel(AHT03);
|
||||
I2C_AHT20_Read(&temp[2], &rh[2]);
|
||||
|
||||
adc[0] = I2C_ADS1115_Read(ADS01);
|
||||
adc[1] = I2C_ADS1115_Read(ADS02);
|
||||
adc[2] = I2C_ADS1115_Read(ADS03);
|
||||
adc[3] = I2C_ADS1115_Read(ADS04);
|
||||
Sleep(200); // FIXME: Poll config register until BIT(15) == 1
|
||||
adct[0] = I2C_ADS1115_ReadThermistor(ADS01);
|
||||
Sleep(200); // FIXME: Remove me - see above.
|
||||
adct[1] = I2C_ADS1115_ReadThermistor(ADS02);
|
||||
Sleep(200); // FIXME: Remove me - see above.
|
||||
adct[2] = I2C_ADS1115_ReadThermistor(ADS03);
|
||||
|
||||
Info("TEMP0=%.2fC, RH0=%.2f%%", temp[0], rh[0]);
|
||||
Info("TEMP1=%.2fC, RH1=%.2f%%", temp[1], rh[1]);
|
||||
Info("TEMP2=%.2fC, RH2=%.2f%%", temp[2], rh[2]);
|
||||
Info("ADC0=%04X, ADC1=%04X", adc[0], adc[1]);
|
||||
Info("ADC2=%04X, ADC3=%04X", adc[2], adc[3]);
|
||||
Info("TEMP0=%.2fC, TEMP1=%.2fC, TEMP2=%.2fC", temp[0], temp[1], temp[2]);
|
||||
Info("ADCT0=%.2fC, ADCT1=%.2fC, ADCT2=%.2fC", adct[0], adct[1], adct[2]);
|
||||
Info("RH0=%.2f%%, RH1=%.2f%%, RH2=%.2f%%", rh[0], rh[1], rh[2]);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
Reference in New Issue
Block a user