ESP12f.ino 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*************************************************************
  2. Download latest Blynk library here:
  3. https://github.com/blynkkk/blynk-library/releases/latest
  4. Blynk is a platform with iOS and Android apps to control
  5. Arduino, Raspberry Pi and the likes over the Internet.
  6. You can easily build graphic interfaces for all your
  7. projects by simply dragging and dropping widgets.
  8. Downloads, docs, tutorials: http://www.blynk.cc
  9. Sketch generator: http://examples.blynk.cc
  10. Blynk community: http://community.blynk.cc
  11. Follow us: http://www.fb.com/blynkapp
  12. http://twitter.com/blynk_app
  13. Blynk library is licensed under MIT license
  14. This example code is in public domain.
  15. *************************************************************
  16. This example runs directly on ESP8266 chip.
  17. Note: This requires ESP8266 support package:
  18. https://github.com/esp8266/Arduino
  19. Please be sure to select the right ESP8266 module
  20. in the Tools -> Board menu!
  21. Change WiFi ssid, pass, and Blynk auth token to run :)
  22. Feel free to apply it to any other example. It's simple!
  23. *************************************************************/
  24. /* Comment this out to disable prints and save space */
  25. #define BLYNK_PRINT Serial
  26. #include <SPI.h>
  27. #include <ESP8266WiFi.h>
  28. #include <BlynkSimpleEsp8266.h>
  29. // You should get Auth Token in the Blynk App.
  30. // Go to the Project Settings (nut icon).
  31. char auth[] = "qDSPfbEHHMiQxMNFeKZ2_lKwbxD81Yu8";
  32. // Your WiFi credentials.
  33. // Set password to "" for open networks.
  34. char ssid[] = "Livebox-7C2C";
  35. char pass[] = "566C61F61F9C925C9F3D7D79E6";
  36. #define MASK_TB 0x80
  37. #define MASK_TH 0x40
  38. #define MASK_CH 0x20
  39. #define MASK_RB 0x10
  40. #define MASK_A1 0x08
  41. #define MASK_A2 0x04
  42. #define MASK_OS 0x01
  43. BlynkTimer timer;
  44. WidgetLED led1(V11) // Led Tech bas
  45. , led2(V12) // Led Tech Haut
  46. , led3(V13) // Led Cuve Haut
  47. , led4(V14) // Led Reserve Bas
  48. , led5(V15) // Led Autre1
  49. , led6(V16); // Led Autre2
  50. void setup(){
  51. // Debug console
  52. Serial.begin(9600);
  53. Blynk.begin(auth, ssid, pass);
  54. timer.setInterval(1000L, statusOrdi); //Configuration du timer pour que toute les seconde ils appelles la fonction de status.
  55. }
  56. void loop(){
  57. Blynk.run();
  58. timer.run();
  59. }
  60. void statusOrdi(){
  61. uint8_t tab[7];
  62. //SPI_Status(tab); //Lecture du status de l'ordinateur
  63. //Transmission des donnée et notification si probleme
  64. Blynk.virtualWrite(8, tab[1]); //On transmet a blynk sur la broche v8 la valeur de la température de l'air
  65. if (tab[1]<18)
  66. Blynk.notify("Temérature air trop froid");
  67. else (tab[1]>29)
  68. Blynk.notify("Temérature air trop Chaud");
  69. Blynk.virtualWrite(9, tab[2]);
  70. if (tab[1]<23)
  71. Blynk.notify("Temérature Eau trop froid");
  72. else (tab[1]>29)
  73. Blynk.notify("Temérature Eau trop Chaud");
  74. Blynk.virtualWrite(10, tab[3]);
  75. if (tab[1]<7.5)
  76. Blynk.notify("PH trop bas");
  77. else (tab[1]>8.5)
  78. Blynk.notify("PH trop Haut");
  79. if((tab[4] & MASK_TB) = MASK_TB)
  80. led1.on();
  81. else
  82. led1.off();
  83. if((tab[4] & MASK_TH) = MASK_TH)
  84. led2.on();
  85. Blynk.notify("Cuve technique haut");
  86. else
  87. led2.off();
  88. if((tab[4] & MASK_CH) = MASK_CH)
  89. led3.on();
  90. else
  91. led3.off();
  92. if((tab[4] & MASK_RB) = MASK_RB)
  93. led4.on();
  94. Blynk.notify("Reserve bas");
  95. else
  96. led4.off();
  97. if((tab[4] & MASK_A1) = MASK_A1)
  98. led5.on();
  99. else
  100. led5.off();
  101. if((tab[4] & MASK_A2) = MASK_A2)
  102. led6.on();
  103. else
  104. led6.off();
  105. // reste a transmetre la dernoiere osmolation
  106. }
  107. BLYNK_WRITE(V0){ //Bouton Ecumeur
  108. uint8_t data;
  109. Read_actionneur(data);
  110. if (param.asInt())
  111. data = data | MASK_ECU;
  112. else {
  113. data = data & (!MASK_ECU);
  114. Write_actionneur(data);
  115. }
  116. BLYNK_WRITE(V1){ //Bouton Remonter
  117. uint8_t data;
  118. Read_actionneur(data);
  119. if (param.asInt())
  120. data = data | MASK_ECU;
  121. else {
  122. data = data & (!MASK_ECU);
  123. Write_actionneur(data);
  124. }
  125. BLYNK_WRITE(V2){ //Bouton Chauffage
  126. uint8_t data;
  127. Read_actionneur(data);
  128. if (param.asInt())
  129. data = data | MASK_ECU;
  130. else {
  131. data = data & (!MASK_ECU);
  132. Write_actionneur(data);
  133. }
  134. BLYNK_WRITE(V3){ //Bouton Brassage1
  135. uint8_t data;
  136. Read_actionneur(data);
  137. if (param.asInt())
  138. data = data | MASK_ECU;
  139. else {
  140. data = data & (!MASK_ECU);
  141. Write_actionneur(data);
  142. }
  143. BLYNK_WRITE(V4){ //Bouton Brassage2
  144. uint8_t data;
  145. Read_actionneur(data);
  146. if (param.asInt())
  147. data = data | MASK_ECU;
  148. else {
  149. data = data & (!MASK_ECU);
  150. Write_actionneur(data);
  151. }
  152. BLYNK_WRITE(V20){ //Bouton Osmolateur
  153. }
  154. BLYNK_WRITE(V5){ //Ventilateur 1
  155. }
  156. BLYNK_WRITE(V6){ //Ventilateur 3
  157. }
  158. BLYNK_WRITE(V7){ //Ventilateur 3
  159. }