Difference between revisions of "Blynk"

From Digipool-Wiki
Jump to: navigation, search
(Sparkfun-Blynk-ESP8266 onboard-Temp-Humidity)
(Sparkfun-Blynk-ESP8266 onboard-Temp-Humidity)
Line 117: Line 117:
  
 
[[File:Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg|150px]]
 
[[File:Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg|150px]]
[[File:Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg|150px]]
+
[[File:Sparkfun-Blynk-ESP8266 Onboard Humidity-Sensor.jpg|150px]]
 
[[File:Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg|150px]]
 
[[File:Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg|150px]]
  

Revision as of 22:58, 23 January 2021

Blynk-Pinout.jpg

Sparkfun-Blynk-ESP8266 Simple-Setup a New-Board

Setup

  1. Install the Blynk App on your Phone
  2. Creat an Account and log in
  3. Scann the QR-Code
  4. Follow the steps
  5. If the App is connecting to your Blynk board, open WLAN-Setting and select the boards WLAN by hand

SparkFun-Tutorial


Sparkfun-Blynk-ESP8266 Onboard-NeoPixel

Auf dem Sparkfun-Blynk-ESP8266 Board befindet sich eine RGB LED, die sich sehr gut dazu eignen, um zum Beispiel deinen aktuellen Zustand anzuzeigen. Diese RGB LED vom Type WS2812 ist mit Pin 4 verdrahtet und kann über die Libary Adafruit_NeoPixel.h angesteuert werden.


Onboard-RGB-LED


Sparkfun-Blynk-Onboard-NeoPixel-2.jpg Sparkfun-Blynk-Onboard-NeoPixel-1.jpg Sparkfun-Blynk-Onboard-NeoPixel-3.jpg


// Sparkfun-Blynk-ESP8266 Onboard-NeoPixel Example

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_NeoPixel.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#define PIN 4
int stripR = 0;
int stripG = 0;
int stripB = 0;
int stripL = 0;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

BLYNK_WRITE(V1)
{
  stripR = param[0].asInt();
  stripG = param[1].asInt();
  stripB = param[2].asInt();
  showRGB();
}

BLYNK_WRITE(V2)
{
  stripL = 255 - param.asInt();
  showRGB();
}

void showRGB() {
  int r = stripR - stripL;
  if (r < 0) r = 0;
  int g = stripG - stripL;
  if (g < 0) g = 0;
  int b = stripB - stripL;
  if (b < 0) b = 0;

  strip.setPixelColor(0, strip.Color(r, g, b));
  strip.show();
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);

  strip.begin();
  strip.show();
}

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


Sparkfun-Blynk-ESP8266 onboard-Temp-Humidity

Onboard Temperature and Humidity Sensor


Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg Sparkfun-Blynk-ESP8266 Onboard Humidity-Sensor.jpg Sparkfun-Blynk-ESP8266 Onboard Temperature-Sensor.jpg

// Sparkfun-Blynk-ESP8266_Onboard-TempHumidity_Example

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// #include <DHT.h>
#include "SparkFun_Si7021_Breakout_Library.h"
#include <Wire.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

float humidity = 0;
float tempf = 0;
float tempc = 0;

//Create Instance of HTU21D or SI7021 temp and humidity sensor and MPL3115A2 barrometric sensor
Weather sensor;

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  getWeather();
  printInfo();
  sendValues();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  //Initialize the I2C sensors and ping them
  sensor.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

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

//---------------------------------------------------------------
void getWeather()
{
  // Measure Relative Humidity from the HTU21D or Si7021
  humidity = sensor.getRH();

  // Measure Temperature from the HTU21D or Si7021
  // tempf = sensor.getTempF();
  tempc = sensor.getTemp();
  // Temperature is measured every time RH is requested.
  // It is faster, therefore, to read it from previous RH
  // measurement with getTemp() instead with readTemp()
}
//---------------------------------------------------------------
void printInfo()
{
  //This function prints the weather data out to the default Serial Port

  Serial.print("Temp:");
  Serial.print(tempc);
  Serial.print("°C, ");

  Serial.print("Humidity:");
  Serial.print(humidity);
  Serial.println("%");
}

void sendValues() {
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, humidity);
  Blynk.virtualWrite(V6, tempc);
}


Sparkfun-Blynk-ESP8266 Read Onboard-Button

... comming soon