I'm trying to make both the codes work together to print temperature and air pressure in same code, after I get that to work I'm going to plot in a formula to calculate altitude with air pressure and temperature.
The code compiled without errors, serial monitor doesn't show anything.
Here is the two codes combined:
#include <GY91.h>
double pressure;
GY91 gy91;
void setup() {
Serial.begin(9600);
while(!Serial);
if (!gy91.init())
Serial.println("Can't initiate");
while(1);
analogReadResolution(12);
}
void loop() {
gy91.read_pressure();
Serial.print(gy91.pressure);
Serial.println();
double temp_celsius;
temp_celsius = read_temp_direct();
Serial.print(temp_celsius);
Serial.println();
delay(300);
}
double read_temp_direct() {
double R_NTC, log_NTC;
uint16_t ARead = analogRead(A10);
R_NTC = 4700*ARead/(4095.0-ARead);
log_NTC = log(R_NTC/10000);
return 1/(3.354016E-3 + 2.569850E-4*log_NTC + 2.620131E-6*log_NTC*log_NTC + 6.383091E-8*log_NTC*log_NTC*log_NTC)-273.15;
}
Here is GY91 pressure code.
#include <GY91.h>
double pressure;
GY91 gy91;
void setup() {
Serial.begin(9600);
while(!Serial);
analogReadResolution(12);
if (!gy91.init()) {
Serial.println("Can't initiate");
while(1);
}
}
void loop() {
gy91.read_pressure();
Serial.print(gy91.pressure);
Serial.println();
delay(100);
}
Here is NTC temperature code.
void setup() {
Serial.begin(9600);
while(!Serial);
analogReadResolution(12);
}
void loop() {
double temp_celsius;
temp_celsius = read_temp_direct();
Serial.print(temp_celsius);
Serial.println();
delay(100);
}
double read_temp_direct() {
double R_NTC, log_NTC;
uint16_t ARead = analogRead(A10);
R_NTC = 4700*ARead/(4095.0-ARead);
log_NTC = log(R_NTC/10000);
return 1/(3.354016E-3 + 2.569850E-4*log_NTC + 2.620131E-6*log_NTC*log_NTC + 6.383091E-8*log_NTC*log_NTC*log_NTC)-273.15;
}