Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*************************************************************
  2.   Download latest Blynk library here:
  3.     https://github.com/blynkkk/blynk-library/releases/latest
  4.  
  5.   Blynk is a platform with iOS and Android apps to control
  6.   Arduino, Raspberry Pi and the likes over the Internet.
  7.   You can easily build graphic interfaces for all your
  8.   projects by simply dragging and dropping widgets.
  9.  
  10.     Downloads, docs, tutorials: http://www.blynk.cc
  11.     Sketch generator:           http://examples.blynk.cc
  12.     Blynk community:            http://community.blynk.cc
  13.     Follow us:                  http://www.fb.com/blynkapp
  14.                                 http://twitter.com/blynk_app
  15.  
  16.   Blynk library is licensed under MIT license
  17.   This example code is in public domain.
  18.  
  19.  *************************************************************
  20.   This example runs directly on NodeMCU.
  21.  
  22.   Note: This requires ESP8266 support package:
  23.     https://github.com/esp8266/Arduino
  24.  
  25.   Please be sure to select the right NodeMCU module
  26.   in the Tools -> Board menu!
  27.  
  28.   For advanced settings please follow ESP examples :
  29.    - ESP8266_Standalone_Manual_IP.ino
  30.    - ESP8266_Standalone_SmartConfig.ino
  31.    - ESP8266_Standalone_SSL.ino
  32.  
  33.   Change WiFi ssid, pass, and Blynk auth token to run :)
  34.   Feel free to apply it to any other example. It's simple!
  35.  *************************************************************/
  36.  
  37. /* Comment this out to disable prints and save space */
  38. #define BLYNK_PRINT Serial
  39.  
  40.  
  41. #include <ESP8266WiFi.h>
  42. #include <BlynkSimpleEsp8266.h>
  43. #include <OneWire.h>
  44. #include <DallasTemperature.h>
  45.  
  46. OneWire oneWire(D4); // digital D2 pin
  47. DallasTemperature sensors(&oneWire);
  48. BlynkTimer timer;
  49.  
  50. // You should get Auth Token in the Blynk App.
  51. // Go to the Project Settings (nut icon).
  52. char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  53.  
  54. // Your WiFi credentials.
  55. // Set password to "" for open networks.
  56. char ssid[] = "Ubiquiti WiFi";
  57. char pass[] = "mia password";
  58.  
  59. float  temp = 0;
  60.  
  61. void setup()
  62. {
  63.   // Debug console
  64.  
  65.  
  66.   Blynk.begin(auth, ssid, pass);
  67.   // You can also specify server:
  68.   //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  69.   //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  70.    sensors.begin();
  71.    pinMode(14, INPUT);
  72.   pinMode(12, INPUT);
  73.   pinMode(13, INPUT);
  74.   Serial.begin(9600);
  75.  
  76.    timer.setInterval(300L, leggibt );
  77. // Setup a function to be called every second  
  78.    timer.setInterval(1000L, sendTemps);
  79. }
  80. void leggibt() {
  81.   if (digitalRead(14)) {
  82.     Blynk.virtualWrite(V10, 255);
  83.     Serial.println("BT");
  84.   } else {
  85.     Blynk.virtualWrite(V10, 0);}
  86.  
  87.   if (digitalRead(12)) {
  88.     Blynk.virtualWrite(V11, 255);
  89.     Serial.println("BT");
  90.   } else {
  91.     Blynk.virtualWrite(V11, 0);}
  92.    
  93.     if (digitalRead(13)) {
  94.     Blynk.virtualWrite(V12, 255);
  95.     Serial.println("BT");
  96.   } else {
  97.     Blynk.virtualWrite(V12, 0);}
  98.   }  
  99. void sendTemps()
  100. {
  101.  sensors.requestTemperatures();
  102.  temp = sensors.getTempCByIndex(0);
  103.  Serial.println(String("Sıcaklik=")+temp+ String(" C"));
  104.  Blynk.virtualWrite(V1, temp);
  105. }
  106.  
  107. void loop()
  108. {
  109.   Blynk.run();
  110.   timer.run();
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement