Return Arduino String object because of a wierd bug where the char* wasn't passing properly
This commit is contained in:
parent
2a0b540a4a
commit
520370fb59
3 changed files with 85 additions and 85 deletions
|
@ -32,7 +32,7 @@ float Sensors::readpH() {
|
|||
return pH;
|
||||
}
|
||||
|
||||
const char* Sensors::getTemperature(){
|
||||
const String Sensors::getTemperature(){
|
||||
_ds18b20->requestTemperatures();
|
||||
float temperature = _ds18b20->getTempCByIndex(0);
|
||||
int attemptStart = millis();
|
||||
|
@ -42,8 +42,8 @@ const char* Sensors::getTemperature(){
|
|||
return "Pending...";
|
||||
temperature = _ds18b20->getTempCByIndex(0);
|
||||
}
|
||||
String temperatureString(temperature, 2);
|
||||
return temperatureString.c_str();
|
||||
|
||||
return String(temperature, 2);
|
||||
}
|
||||
|
||||
const char* Sensors::getpH() {
|
||||
|
|
|
@ -23,6 +23,6 @@ class Sensors {
|
|||
void setup();
|
||||
float readpH();
|
||||
const char* getpH();
|
||||
const char *getTemperature();
|
||||
const String getTemperature();
|
||||
};
|
||||
#endif
|
12
monitor.ino
12
monitor.ino
|
@ -23,15 +23,15 @@
|
|||
#define R_PIN D8
|
||||
#define G_PIN D7
|
||||
#define B_PIN D6
|
||||
#define SCL_PIN D1
|
||||
#define SDA_PIN D4
|
||||
#define SCL_PIN D4
|
||||
#define SDA_PIN D1
|
||||
|
||||
/*---------------------------+
|
||||
| Location and time settings |
|
||||
+---------------------------*/
|
||||
#define LATITUDE "20.548103"
|
||||
#define LONGITUDE "96.916835"
|
||||
#define TIMEZONE_OFFSET 30600 // 8.5 hours in seconds
|
||||
#define TIMEZONE_OFFSET 28800 // 8 hours in seconds
|
||||
#define NTP_POOL "uk.pool.ntp.org"
|
||||
|
||||
/*============================================================================================================================*/
|
||||
|
@ -75,7 +75,7 @@ void setup() {
|
|||
#endif
|
||||
|
||||
#ifdef LED_USE_PWM
|
||||
_lighting.setupPWM<R_PIN, R_PIN, G_PIN, WHITE_PIN>();
|
||||
_lighting.setupPWM<R_PIN, G_PIN, B_PIN, WHITE_PIN>();
|
||||
#endif
|
||||
|
||||
_networking.setup();
|
||||
|
@ -113,9 +113,9 @@ void doLighting() {
|
|||
}
|
||||
|
||||
void publishTemperature(){
|
||||
const char *temperature = _sensors.getTemperature();
|
||||
String temperature = _sensors.getTemperature();
|
||||
if (temperature != "Pending...")
|
||||
_networking.publish(TEMPERATURE_TOPIC, temperature, true);
|
||||
_networking.publish(TEMPERATURE_TOPIC, temperature.c_str(), true);
|
||||
}
|
||||
|
||||
void publishReadings(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue