Hi All I have been playing around with the Autonomo for a bit now and am having a hard time understanding how to get the TPH board readings to be close / accurate. I am very very new to Arduino so i’m sure this is a simple you forgot “x” or call it like “y” type of mistake. I also have tried other library for the TPH board. The adafruit library seemed to be more sporadic.
My TPH board seems to have recorded my house between -38C and 100C in two in a half minuets and between 0.27% and 90% humidity in about the same time frame.
The conditions in my house at the time of readings were no more less 16.6C(62F) and no more than 17.8C(64F) also the humidity in my house is between 40 - 45% These readings are from a device that I trust as accurate and also match the Nest thermostat that I have installed as well.
My Code:
#include <SD.h>
#include <Wire.h>
#include <Sodaq_BMP085.h>
#include <Sodaq_SHT2x.h>
#define dS SerialUSB
#define SD_SS_PIN SS_2
#define ADC_AREF 3.3
#define BATVOLTPIN BAT_VOLT
#define BATVOLT_R1 4.7
#define BATVOLT_R2 10
int num = 0;
Sodaq_BMP085 bmp;
void setup() {
// put your setup code here, to run once:
dS.begin(57600);
pinMode(LED_BUILTIN, OUTPUT);
setupTPH();
if(!SD.begin(CS_SD))
{
dS.println("Error: SD card failed to initialise or is missing.");
}
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, HIGH);
String reading = takeTPHReading();
reading += ", Batt " + String(getRealBatteryVoltageMV());
num = num + 1;
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
dataFile.println(reading);
dataFile.close();
// print to the serial port too:
dS.println(reading);
}
// if the file isn't open, pop up an error:
else {
dS.println("error opening datalog.txt");
dS.println(reading);
}
digitalWrite(LED_BUILTIN, LOW);
delay(30000);
}
void setupTPH()
{
//Initialize the wire protocol for the TPH sensors
Wire.begin();
//Initialize the TPH BMP sensor
bmp.begin();
}
String takeTPHReading()
{
//Create a String type data record in csv format
//TempSHT21, TempBMP, PressureBMP, HumiditySHT21
String data = String(num) + ", Temp " + String(SHT2x.GetTemperature()) + ", ";
//BMPTemp is commented out, the data will be to long if you also send batt volt.
data += "Temp " + String(bmp.readTemperature()) + ", ";
data += "Pressure " + String(bmp.readPressure() / 100) + ", ";
data += "Humidity " + String(SHT2x.GetHumidity());
return data;
}
float getRealBatteryVoltageMV()
{
uint16_t batteryVoltage = analogRead(BATVOLTPIN);
return (ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * batteryVoltage;
}
My data output for fourteen minuets.
0, Temp 18.75, Temp 65.80, Pressure 262, Humidity 56.69, Batt 4158.67
1, Temp 105.75, Temp 11.60, Pressure 945, Humidity 69.92, Batt 4163.41
2, Temp 107.17, Temp -33.00, Pressure 631, Humidity 42.18, Batt 4163.41
3, Temp 59.98, Temp 145.19, Pressure 621, Humidity 42.15, Batt 4163.41
4, Temp 20.83, Temp 98.09, Pressure 875, Humidity 88.17, Batt 4158.67
5, Temp 20.80, Temp 17.79, Pressure 1546, Humidity 43.00, Batt 4158.67
6, Temp 71.30, Temp 17.79, Pressure 984, Humidity 46.45, Batt 4158.67
7, Temp 99.60, Temp 93.50, Pressure 538, Humidity 91.47, Batt 4153.93
8, Temp 27.07, Temp -4.80, Pressure 639, Humidity 52.88, Batt 4153.93
9, Temp 93.60, Temp 32.40, Pressure 1099, Humidity 50.82, Batt 4153.93
10, Temp 30.43, Temp 165.60, Pressure 1331, Humidity 40.56, Batt 4153.93
11, Temp 29.59, Temp 35.00, Pressure 895, Humidity 39.60, Batt 4153.93
12, Temp 101.67, Temp 30.20, Pressure 1485, Humidity 78.96, Batt 4149.19
13, Temp 17.21, Temp -19.20, Pressure 577, Humidity 41.08, Batt 4149.19
14, Temp 72.58, Temp 8.89, Pressure 846, Humidity 70.09, Batt 4149.19
15, Temp 85.22, Temp 168.10, Pressure 42, Humidity 42.02, Batt 4149.19
16, Temp 60.12, Temp 61.79, Pressure 721, Humidity 42.02, Batt 4144.45
17, Temp 20.65, Temp 98.30, Pressure 1790, Humidity 21.75, Batt 4144.45
18, Temp 20.65, Temp 17.50, Pressure 1547, Humidity 0.52, Batt 4144.45
19, Temp -13.35, Temp 17.50, Pressure 984, Humidity 47.43, Batt 4144.45
20, Temp 51.55, Temp 37.90, Pressure 536, Humidity 105.20, Batt 4144.45
21, Temp 28.12, Temp 164.10, Pressure 533, Humidity 32.86, Batt 4144.45
22, Temp 109.82, Temp 34.70, Pressure 171, Humidity 34.22, Batt 4144.45
23, Temp 7.78, Temp 194.80, Pressure 2589, Humidity 68.89, Batt 4134.96
24, Temp 8.31, Temp -22.89, Pressure 943, Humidity 39.45, Batt 4139.70
25, Temp 17.24, Temp -20.89, Pressure 1400, Humidity 0.27, Batt 4144.45
26, Temp 17.03, Temp -12.60, Pressure 293, Humidity 87.95, Batt 4144.45
27, Temp -39.56, Temp 8.50, Pressure 330, Humidity 70.12, Batt 4139.70
28, Temp 107.19, Temp -26.79, Pressure 1438, Humidity 41.98, Batt 4139.70