Last active
July 26, 2018 10:35
-
-
Save neosarchizo/8bbac85854ccdfce3debad7d4257b29d to your computer and use it in GitHub Desktop.
My home TH logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BLYNK_PRINT Serial | |
#include <Arduino.h> | |
#include <ESP8266WiFi.h> | |
#include <BlynkSimpleEsp8266.h> | |
#include <Wire.h> | |
#include "Adafruit_SHT31.h" | |
char auth[] = "YourToken"; | |
char ssid[] = "YourWiFiName"; | |
char pass[] = "YourWiFiPassword"; | |
BlynkTimer timer; | |
Adafruit_SHT31 sht31 = Adafruit_SHT31(); | |
void setup() | |
{ | |
Wire.begin(); | |
Serial.begin(9600); | |
if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr | |
Serial.println("Couldn't find SHT31"); | |
while (1) delay(1); | |
} | |
Blynk.begin(auth, ssid, pass); | |
timer.setInterval(1000L, readTempHumidity); | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
timer.run(); | |
} | |
void readTempHumidity() { | |
float t = sht31.readTemperature(); | |
float rh = sht31.readHumidity(); | |
if (! isnan(t)) { // check if 'is not a number' | |
Blynk.virtualWrite(V0, t); | |
} | |
if (! isnan(rh)) { // check if 'is not a number' | |
Blynk.virtualWrite(V1, rh); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment