Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Last active July 26, 2018 10:35
Show Gist options
  • Save neosarchizo/8bbac85854ccdfce3debad7d4257b29d to your computer and use it in GitHub Desktop.
Save neosarchizo/8bbac85854ccdfce3debad7d4257b29d to your computer and use it in GitHub Desktop.
My home TH logger
#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