Skip to content

Commit

Permalink
Added license & package.json
Browse files Browse the repository at this point in the history
Added LICENSE.md
Added package.json
Harmonized debug output format
  • Loading branch information
beegee-tokyo committed Nov 14, 2017
1 parent 84b6d62 commit f096bc2
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 31 deletions.
117 changes: 117 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions package.json
@@ -0,0 +1,27 @@
{
"name": "ESP32-WeatherStation",
"description": "ESP32 with TFT display as small weather station displaying local and internet weather data",
"author": "Bernd Giesecke",
"homepage": "https://github.com/beegee-tokyo/ESP32-Weatherstation",
"contributors": "Bernd Giesecke",
"version": "0.0.0",
"url": "https://github.com/beegee-tokyo/ESP32-Weatherstation",
"keywords": [ "ESP32", "Weatherstation" ],
"bugs": "beegee@giesecke.tk",
"license": "GNU General Public License v2.0",
"repository":
{ "type" : "git"
, "url" : "https://github.com/beegee-tokyo/ESP32-Weatherstation.git"
},
"dependencies":
{ "ESP32-MyLib" : "https://github.com/beegee-tokyo/ESP32-MyLib.git"
, "WIFIMANAGER-ESP32" : "https://github.com/zhouhan0126/WIFIMANAGER-ESP32.git"
, "WebServer-esp32" : "https://github.com/zhouhan0126/WebServer-esp32.git"
, "DNSServer---esp32" : "https://github.com/zhouhan0126/DNSServer---esp32.git"
},
"devDependencies":
{ "arduino-esp32": "https://github.com/espressif/arduino-esp32.git"
, "PlatformIO_Atom_IDE": "https://github.com/platformio/platformio-atom-ide.git"
},
"cpu" : [ "ESP32" ]
}
4 changes: 2 additions & 2 deletions src/accuweather_time.cpp
Expand Up @@ -74,7 +74,7 @@ void accuWeatherTask(void *pvParameters) {
// Update NTP time
if (!tryGetTime()) {
// Serial.println("Failed to get update from NTP");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + " Failed to get update from NTP", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Failed to get update from NTP", true);
}
// Get weather info
if (getAccuWeather()) {
Expand Down Expand Up @@ -201,7 +201,7 @@ bool getAccuWeather() {
icon = accuIconArray[iconNum];
} else {
Serial.println("Could not find the icon");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + " Could not find weather icon", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Could not find weather icon", true);
}
// drawIcon(icon, (tft.width() - accuIconWidth), 75, accuIconWidth, accuIconHeight);
drawIcon(icon, 5, 88, accuIconWidth, accuIconHeight);
Expand Down
4 changes: 2 additions & 2 deletions src/light.cpp
Expand Up @@ -101,8 +101,8 @@ void lightTask(void *pvParameters) {
newTSLValue = collLight;
} else {
newTSLValue = 0;
Serial.println("[ERROR] " + digitalTimeDisplay() + " Failed to read from TSL2561");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + " Failed to read from TSL2561", true);
Serial.println("[ERROR] " + digitalTimeDisplaySec() + " Failed to read from TSL2561");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Failed to read from TSL2561", true);
hasTSLSensor = false;
}
esp32Wire.reset();
Expand Down
24 changes: 12 additions & 12 deletions src/setup.cpp
Expand Up @@ -141,38 +141,38 @@ void setup(void)
byte lightInitResult = initLight();
switch (lightInitResult) {
case 0:
Serial.println("[INFO] --:-- Light sensors available and initialized");
addMeeoMsg("", "[INFO] --:-- Light sensors available and initialized", true);
Serial.println("[INFO] " + digitalTimeDisplaySec() + " Light sensors available and initialized");
addMeeoMsg("", "[INFO] " + digitalTimeDisplaySec() + " Light sensors available and initialized", true);
break;
case 1:
Serial.println("[ERROR] --:-- Light sensors not available");
addMeeoMsg("", "[ERROR] --:-- Light sensors not available", true);
Serial.println("[ERROR] " + digitalTimeDisplaySec() + " Light sensors not available");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Light sensors not available", true);
break;
case 2:
default:
Serial.println("[ERROR] --:-- Failed to start timer for light measurement");
addMeeoMsg("", "[ERROR] --:-- Failed to start timer for light measurement", true);
Serial.println("[ERROR] " + digitalTimeDisplaySec() + " Failed to start timer for light measurement");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Failed to start timer for light measurement", true);
break;
}

// Initialize temperature measurements
if (!initTemp()) {
Serial.println("[ERROR] --:-- Failed to start temperature measurement");
addMeeoMsg("", "[ERROR] --:-- Failed to start temperature measurement", true);
Serial.println("[ERROR] " + digitalTimeDisplaySec() + " Failed to start temperature measurement");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Failed to start temperature measurement", true);
}

// Initialize Weather and NTP time updates
if (!initUGWeather()) {
Serial.println("[ERROR] --:-- Failed to start weather & time updates");
addMeeoMsg("", "[ERROR] --:-- Failed to start weather & time updates", true);
Serial.println("[ERROR] " + digitalTimeDisplaySec() + " Failed to start weather & time updates");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Failed to start weather & time updates", true);
}
// if (!initAccuWeather()) {
// Serial.println("[ERROR] --:-- Failed to start weather & time updates");
// addMeeoMsg("", "[ERROR] --:-- Failed to start weather & time updates", true);
// }

String resetReason = reset_reason(rtc_get_reset_reason(0));
addMeeoMsg("", "[INFO] --:-- Reset reason CPU0: " + resetReason, true);
addMeeoMsg("", "[INFO] " + digitalTimeDisplaySec() + " Reset reason CPU0: " + resetReason, true);
resetReason = reset_reason(rtc_get_reset_reason(1));
addMeeoMsg("", "[INFO] --:-- Reset reason CPU1: " + resetReason, true);
addMeeoMsg("", "[INFO] " + digitalTimeDisplaySec() + " Reset reason CPU1: " + resetReason, true);
}
4 changes: 2 additions & 2 deletions src/temperature.cpp
Expand Up @@ -102,7 +102,7 @@ bool getTemperature() {
// Check if any reads failed and exit early (to try again).
if (dht.getStatus() != 0) {
Serial.println("DHT11 error status: " + String(dht.getStatusString()));
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + " DHT11 error status: " + String(dht.getStatusString()), true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " DHT11 error status: " + String(dht.getStatusString()), true);
tft.fillRect(0, 32, 128, 8, TFT_RED);
tft.setCursor(0, 33);
tft.setTextColor(TFT_BLACK);
Expand All @@ -115,7 +115,7 @@ bool getTemperature() {
/* Trying to calibrate the humidity values */
/******************************************************* */
// newHumidValue = 10*sqrt(newHumidValue);
newHumidValue = 20+newHumidValue;
newHumidValue = 20.0 + newHumidValue;

String displayTxt = "";

Expand Down
47 changes: 40 additions & 7 deletions src/touch.cpp
Expand Up @@ -6,20 +6,27 @@ bool isTouchedT3 = false;
bool longTouchT3 = false;
/** Time that pad T3 was touched */
long touchTimeT3 = 0;
/** Touch status of T2 pad */
bool isTouchedT2 = false;
/** Long touch status of T2 pad */
bool longTouchT2 = false;
/** Time that pad T2 was touched */
long touchTimeT2 = 0;
/** Ticker for touch pad check */
Ticker touchTicker;

// void touchFunction();
void checkT3Status();
void checkTouchStatus();
void touchT3ISR();
void touchT2ISR();

/**
* initTouch
* Initialize timer to read touch value every 500ms
*/
void initTouch() {
touchTicker.attach_ms(500, checkT3Status);
touchTicker.attach_ms(250, checkTouchStatus);
touchAttachInterrupt(T3, touchT3ISR, 20);
touchAttachInterrupt(T2, touchT2ISR, 20);
}

/**
Expand All @@ -37,18 +44,29 @@ void touchT3ISR() {
}

/**
* checkT3
* Checks if T3 pad is still touched
* touchT2ISR
* Called when touch pin value goes below treshold
*/
void touchT2ISR() {
if (!isTouchedT2) {
touchTimeT2 = millis();
isTouchedT2 = true;
}
}

/**
* checkTouchStatus
* Checks if T2 or T3 pad is still touched
*/
void checkT3Status() {
void checkTouchStatus() {
if (isTouchedT3) {
if (touchRead(T3) > 50) {
isTouchedT3 = false;
longTouchT3 = false;
addMeeoMsg("touch", "0", false);
addMeeoMsg("longtouch", "0", false);
} else {
if ((millis()-touchTimeT3) >= 3000) {
if ((millis()-touchTimeT3) >= 1000) {
if (!longTouchT3) {
addMeeoMsg("longtouch", "1", false);
xTaskResumeFromISR(weatherTaskHandle);
Expand All @@ -57,4 +75,19 @@ void checkT3Status() {
}
}
}
if (isTouchedT2) {
if (touchRead(T2) > 50) {
isTouchedT2 = false;
longTouchT2 = false;
} else {
if ((millis()-touchTimeT2) >= 1000) {
if (!longTouchT2) {
addMeeoMsg("", "[INFO] " + digitalTimeDisplaySec() + " RESET request", true);
delay(2000);
esp_restart();
}
longTouchT3 = true;
}
}
}
}
8 changes: 4 additions & 4 deletions src/udp.cpp
Expand Up @@ -92,7 +92,7 @@ void getUDPbroadcast(int udpMsgLength) {
tft.print(displayText);
}
} else {
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + "Received invalid JSON", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + "Received invalid JSON", true);
}
}

Expand All @@ -119,7 +119,7 @@ bool udpSendMessage(IPAddress ipAddr, String udpMsg, int udpPort) {

if (connOK == 0) {
Serial.println("UDP could not get socket");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + "UDP could not get socket", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + "UDP could not get socket", true);
return false;
}
udpClientServer.begin(udpPort);
Expand All @@ -128,7 +128,7 @@ bool udpSendMessage(IPAddress ipAddr, String udpMsg, int udpPort) {
if (beginOK == 0) { // Problem occured!
udpClientServer.stop();
Serial.println("UDP connection failed");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + "UDP connection failed", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + "UDP connection failed", true);
return false;
}
int bytesSent = udpClientServer.print(udpMsg);
Expand All @@ -139,7 +139,7 @@ bool udpSendMessage(IPAddress ipAddr, String udpMsg, int udpPort) {
return true;
} else {
Serial.println("Failed to send " + udpMsg + ", sent " + String(bytesSent) + " of " + String(udpMsg.length()) + " bytes");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + "Failed to send " + udpMsg + ", sent " + String(bytesSent) + " of " + String(udpMsg.length()) + " bytes", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + "Failed to send " + udpMsg + ", sent " + String(bytesSent) + " of " + String(udpMsg.length()) + " bytes", true);
udpClientServer.endPacket();
udpClientServer.stop();
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/ugweather_time.cpp
Expand Up @@ -68,7 +68,7 @@ void ugWeatherTask(void *pvParameters) {
// Update NTP time
if (!tryGetTime()) {
// Serial.println("Failed to get update from NTP");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + " Failed to get update from NTP", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + " Failed to get update from NTP", true);
}
// Get weather info
if (getUGWeather()) {
Expand Down Expand Up @@ -194,7 +194,7 @@ bool getUGWeather() {
}
} else {
Serial.println("Could not find the icon");
addMeeoMsg("", "[ERROR] " + digitalTimeDisplay() + "Could not find weather icon", true);
addMeeoMsg("", "[ERROR] " + digitalTimeDisplaySec() + "Could not find weather icon", true);
}
// drawIcon(icon, (tft.width() - ugIconWidth)/2, 88, ugIconWidth, ugIconHeight);
drawIcon(icon, 5, 88, ugIconWidth, ugIconHeight);
Expand Down

0 comments on commit f096bc2

Please sign in to comment.