BuiHao96
Published © CC BY-NC-SA

Control LED and SHT3x via Blynk

Turn an LED on/off and control temperature and humidity.

AdvancedWork in progress1,291
Control LED and SHT3x via Blynk

Things used in this project

Hardware components

Grove - I2C High Accuracy Temp&Humi Sensor (SHT35)
Seeed Studio Grove - I2C High Accuracy Temp&Humi Sensor (SHT35)
×1
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
5 mm LED: Red
5 mm LED: Red
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

SHT3x-Led

Code

blynk-sht3x.ino

C/C++
// Robo India Tutorial 
// Digital Output on LED 
// Hardware: NodeMCU Blynk Board


#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
Adafruit_SHT31 sht31 = Adafruit_SHT31();
SimpleTimer timer;
char auth[] = "YourAuthToken";            // You should get Auth Token in the Blynk App.
char ssid[] = "YourNetworkName";    // Your WiFi credentials.
char pass[] = "YourPassword";  // Set password to "" for open networks.
void setup()
{
    Serial.begin(9600);// Debug console
    Blynk.begin(auth, ssid, pass);
      if (! sht31.begin(0x44))
      {   // Set to 0x45 for alternate i2c addr
    Serial.println("Couldn't find SHT31");
    while (1) delay(1);
     }
    timer.setInterval(2000, sendUptime);
}
void sendUptime()
{
    float t = sht31.readTemperature();
    float h = sht31.readHumidity();
     //Serial.print("Temp *C = "); Serial.println(t);
     //Serial.print("Hum. % = "); Serial.println(h);
    Blynk.virtualWrite(V0, t);
    Blynk.virtualWrite(V1, h);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Credits

BuiHao96

BuiHao96

0 projects • 0 followers

Comments