Skip to content

Commit

Permalink
ac
Browse files Browse the repository at this point in the history
  • Loading branch information
tejaswigowda committed Oct 13, 2022
1 parent 5393a96 commit b1136f1
Show file tree
Hide file tree
Showing 400 changed files with 58,446 additions and 0 deletions.
3 changes: 3 additions & 0 deletions WeatherStation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Install "SimpleDHT" library from "Library Manager".
Arduino -> Sketch -> Include Library -> Manage Libraries -> Search "SimpleDHT"

121 changes: 121 additions & 0 deletions WeatherStation/mC/mC.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#define LILYGO_WATCH_2019_WITH_TOUCH
#include <LilyGoWatch.h>
TTGOClass *ttgo;

#include <SimpleDHT.h>

#include <WiFi.h>
#include <HTTPClient.h>


const char* ssid = "";
const char* password = "";

//Your Domain name with URL path or IP address with path
const char* serverName = "http://192.168.0.195:1234/setValue";

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 300;

String response;

// for DHT11,
// VCC: 5V or 3V
// GND: GND
// DATA: 21 or 25
int pinDHT11 = 21;
SimpleDHT11 dht11(pinDHT11);


String httpGETRequest(const char* serverName) {
HTTPClient http;

// Your IP address with path or Domain name with URL path
http.begin(serverName);

// Send HTTP POST request
int httpResponseCode = http.GET();

String payload = "{}";

if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
payload = http.getString();
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();

return payload;
}

void setup() {
Serial.begin(115200);
ttgo = TTGOClass::getWatch();
ttgo->begin();
ttgo->openBL();

ttgo->tft->fillScreen(TFT_BLACK);
ttgo->tft->setTextColor(TFT_WHITE, TFT_BLACK);
ttgo->tft->setTextFont(4);


WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());

Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");



}

void loop() {
// start working...
Serial.println("=================================");
Serial.println("Sample DHT11...");


// read without samples.
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print("Read DHT11 failed, err="); Serial.println(err); delay(1000);
return;
}

Serial.print("Sample OK: ");
Serial.print(String((float)temperature) + "* C, ");
Serial.println(String((float)humidity) + "% H");

ttgo->tft->drawString(String((int)temperature*1.8 + 32) + " *F", 5, 10);
ttgo->tft->drawString(String(humidity) + " % H", 5, 40);

int t = (int)temperature;
int h = (int)humidity;
String url = String(serverName) + "?t=" + t + "&h=" + h;
Serial.println(url);
response = httpGETRequest(url.c_str());
Serial.println(response);



// DHT11 sampling rate is 1HZ.
delay(5000);
}
1 change: 1 addition & 0 deletions WeatherStation/server/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

218 changes: 218 additions & 0 deletions WeatherStation/server/node_modules/accepts/HISTORY.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions WeatherStation/server/node_modules/accepts/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b1136f1

Please sign in to comment.