|
@@ -7,8 +7,8 @@
|
|
#include "../include/configuration.h" // application configuration
|
|
#include "../include/configuration.h" // application configuration
|
|
///////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
-#include "webserver.h"
|
|
|
|
#include "max7219.h"
|
|
#include "max7219.h"
|
|
|
|
+#include "webserver.h"
|
|
|
|
|
|
DHT dht(DHT_PIN, DHT22);
|
|
DHT dht(DHT_PIN, DHT22);
|
|
|
|
|
|
@@ -18,7 +18,8 @@ Timer displayTimer;
|
|
|
|
|
|
bool state = false;
|
|
bool state = false;
|
|
// Sensors string values
|
|
// Sensors string values
|
|
-String StrT, StrRH, StrHI, StrCR, StrCF, StrTime;
|
|
|
|
|
|
+String StrT, StrRH, StrHI, StrCR, StrCF;
|
|
|
|
+String oldStrTime, StrTime;
|
|
String StrVDD, StrADC;
|
|
String StrVDD, StrADC;
|
|
|
|
|
|
// date and time
|
|
// date and time
|
|
@@ -29,14 +30,14 @@ HttpClient thingSpeak;
|
|
|
|
|
|
/* FTPServer ftp; */
|
|
/* FTPServer ftp; */
|
|
|
|
|
|
-void process(void);
|
|
|
|
-//void showValues(void);
|
|
|
|
-void connectOk(void);
|
|
|
|
-void connectFail(void);
|
|
|
|
|
|
+void process();
|
|
|
|
+//void showValues();
|
|
|
|
+void connectOk();
|
|
|
|
+void connectFail();
|
|
void onDataSent(HttpClient& client, bool successful);
|
|
void onDataSent(HttpClient& client, bool successful);
|
|
-void sendData(void);
|
|
|
|
|
|
+void sendData();
|
|
void onNtpReceive(NtpClient& client, time_t timestamp);
|
|
void onNtpReceive(NtpClient& client, time_t timestamp);
|
|
-void showTime(void);
|
|
|
|
|
|
+void showTime();
|
|
|
|
|
|
NtpClient ntpClient ("ntps1-0.cs.tu-berlin.de", 60, onNtpReceive);
|
|
NtpClient ntpClient ("ntps1-0.cs.tu-berlin.de", 60, onNtpReceive);
|
|
|
|
|
|
@@ -84,9 +85,8 @@ void init()
|
|
displayTimer.initializeMs(500, showTime).start();
|
|
displayTimer.initializeMs(500, showTime).start();
|
|
}
|
|
}
|
|
|
|
|
|
-void showTime(void)
|
|
|
|
|
|
+void showTime()
|
|
{
|
|
{
|
|
- static String oldStrTime;
|
|
|
|
static uint16_t oldHour, oldMinute;
|
|
static uint16_t oldHour, oldMinute;
|
|
|
|
|
|
StrTime = SystemClock.getSystemTimeString();
|
|
StrTime = SystemClock.getSystemTimeString();
|
|
@@ -139,39 +139,6 @@ void showTime(void)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
-void showValues(void)
|
|
|
|
-{
|
|
|
|
- Serial.print("Date & Time: ");
|
|
|
|
- Serial.println(SystemClock.getSystemTimeString());
|
|
|
|
-
|
|
|
|
- Serial.print("Temperature: ");
|
|
|
|
- Serial.print(StrT);
|
|
|
|
- Serial.println("*C");
|
|
|
|
-
|
|
|
|
- Serial.print("Humidity: ");
|
|
|
|
- Serial.print(StrRH);
|
|
|
|
- Serial.println("%");
|
|
|
|
-
|
|
|
|
- Serial.print("Heatindex: ");
|
|
|
|
- Serial.print(StrHI);
|
|
|
|
- Serial.println("*C");
|
|
|
|
-
|
|
|
|
- Serial.print("Comfort: ");
|
|
|
|
- Serial.print(StrCR);
|
|
|
|
- Serial.print("% - ");
|
|
|
|
- Serial.println(StrCF);
|
|
|
|
-
|
|
|
|
- Serial.print("ADC value: ");
|
|
|
|
- Serial.println(StrADC);
|
|
|
|
-
|
|
|
|
- Serial.print("VDD value: ");
|
|
|
|
- Serial.println(StrVDD);
|
|
|
|
-
|
|
|
|
- Serial.println("");
|
|
|
|
-}
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
void process()
|
|
void process()
|
|
{
|
|
{
|
|
float t = dht.readTemperature() + ActiveConfig.AddT;
|
|
float t = dht.readTemperature() + ActiveConfig.AddT;
|
|
@@ -226,19 +193,11 @@ void process()
|
|
|
|
|
|
StrADC = String(system_adc_read());
|
|
StrADC = String(system_adc_read());
|
|
StrVDD = String(system_get_vdd33());
|
|
StrVDD = String(system_get_vdd33());
|
|
-/*
|
|
|
|
- if (!serialTimer.isStarted())
|
|
|
|
- serialTimer.initializeMs(20000, showValues).start();
|
|
|
|
- // îáíîâëåíèå âûâîäà -- ðàç â 20 ñåê. îáíîâëåíèå äàííûõ -- ðàç â ìèíóòó.
|
|
|
|
-*/
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
void startFTP()
|
|
void startFTP()
|
|
{
|
|
{
|
|
- if (!fileExist("index.html"))
|
|
|
|
- fileSetContent("index.html", "<h3>Please connect to FTP and upload files from folder 'web/build' (details in code)</h3>");
|
|
|
|
-
|
|
|
|
// Start FTP server
|
|
// Start FTP server
|
|
ftp.listen(21);
|
|
ftp.listen(21);
|
|
ftp.addUser("user", "resu"); // FTP account
|
|
ftp.addUser("user", "resu"); // FTP account
|
|
@@ -303,7 +262,8 @@ void onDataSent(HttpClient& client, bool successful)
|
|
|
|
|
|
void sendData()
|
|
void sendData()
|
|
{
|
|
{
|
|
- if (thingSpeak.isProcessing()) return; // We need to wait while request processing was completed
|
|
|
|
|
|
+ // We need to wait while request processing was completed
|
|
|
|
+ if (thingSpeak.isProcessing()) return;
|
|
|
|
|
|
thingSpeak.downloadString("http://api.thingspeak.com/update?key=26WYU9LJCBC3AE1X&field1=" + StrT + "&field2=" + StrRH + "&field3=" + StrHI, onDataSent);
|
|
thingSpeak.downloadString("http://api.thingspeak.com/update?key=26WYU9LJCBC3AE1X&field1=" + StrT + "&field2=" + StrRH + "&field3=" + StrHI, onDataSent);
|
|
}
|
|
}
|