Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <BH1750.h>
- #include <BME280.h>
- #include <CCS811.h>
- #include <ESP8266WiFi.h>
- #include <HTTPSRedirect.h>
- #include <Wire.h>
- IPAddress ip(192, 168, 1, 101);
- IPAddress gateway(192, 168, 1, 1);
- IPAddress subnet(255, 255, 255, 0);
- const char* Nazev_WiFi = "přísně tajné";
- const char* Heslo_WiFi = "přísně tajné";
- const char* Google_Script_ID = "přísně tajné";
- const char* Google_Script_host = "script.google.com";
- const char* Google_Script_host_presmerovani = "script.googleusercontent.com";
- const int HTTPS_port = 443;
- HTTPSRedirect client(HTTPS_port);
- String Google_Script_URL = String("/macros/s/") + Google_Script_ID + "/exec?";
- BME280 teplomer;
- #define ADDR 0x5A
- #define WAKE_PIN 4
- CCS811 CO2senzor;
- BH1750 luxmetr;
- void setup(){
- Serial.begin(115200);
- delay(10);
- teplomer.begin();
- CO2senzor.begin(ADDR, WAKE_PIN);
- luxmetr.begin();
- WiFi.config(ip, gateway, subnet);
- WiFi.begin(Nazev_WiFi, Heslo_WiFi);
- while(WiFi.status() != WL_CONNECTED){
- delay(500);
- Serial.print("▒");
- }
- }
- void OdeslatData(float teplota, float vlhkost, float tlak, float CO2, float svetlo){
- if(!client.connected()){
- client.connect(Google_Script_host, HTTPS_port);
- }
- String Google_Script_URL_finalni = Google_Script_URL + "teplota=" + teplota + "&vlhkost=" + vlhkost + "&tlak=" + tlak + "&CO2=" + CO2 + "&svetlo=" + svetlo;
- client.printRedir(Google_Script_URL_finalni, Google_Script_host, Google_Script_host_presmerovani);
- }
- void loop(){
- CO2senzor.getData();
- float teplota = teplomer.readTemp();
- float vlhkost = teplomer.readHumidity();
- float tlak_pa = teplomer.readPressure();
- float tlak_hpa;
- float CO2 = CO2senzor.readCO2();
- uint16_t svetlo = luxmetr.readLightLevel();
- Serial.println();
- Serial.println("Teplota vzduchu: "+String(teplota)+" st. C");
- Serial.println("Relativní vlhkost vzduchu: "+String(vlhkost)+" %");
- tlak_hpa = tlak_pa/100;
- Serial.println("Atmosférický tlak: "+String(tlak_hpa)+" hPa");
- Serial.println("CO2: "+String(CO2)+" ppm");
- Serial.println("Intenzita světla: "+String(svetlo)+" lx");
- Serial.println();
- OdeslatData(teplota, vlhkost, tlak_hpa, CO2, svetlo);
- delay(10000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement