Advertisement
Guest User

działający chart

a guest
Jan 28th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #include <ESPAsyncWebServer.h>
  2. #include <SPIFFS.h>
  3.  
  4. float LUMIX_float;
  5. int LUMIX_int;
  6.  
  7. //***dla wyświetlacza U8G2_SH1106_128X64***
  8. //Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  9. //jak zainstalować bibliotekę U8g2 https://github.com/olikraus/u8g2/wiki/u8g2install
  10.  
  11. #include <Wire.h>
  12.  
  13. //*****************************************
  14.  
  15. //***APDS9301 sensor światła****
  16. #include <Sparkfun_APDS9301_Library.h>
  17. APDS9301 apds;
  18. #define INT_PIN 15 // przerwanie z wyjścia INT sensora APDS9301 podłaczone do GPIO 15
  19. //******************************
  20. #include <WiFi.h>
  21. #include "time.h"
  22. const char* ssid = "luzycka9_plus";
  23. const char* password = "aabbaacc44";
  24. //const char* ntpServer = "pool.ntp.org";
  25. IPAddress ip;
  26. String IP_string; //zmienna do wyświetlenia IP na U8g2
  27.  
  28. AsyncWebServer server(80);
  29. String readAPDSTemperature()
  30. {
  31. float t=apds.readLuxLevel();
  32. if(isnan(t))
  33. {
  34. Serial.println("Failed to read from APDS sensor!");
  35. return "";
  36. }
  37. else
  38. {
  39. Serial.println(t);
  40. Serial.println("ok");
  41. return String(t);
  42.  
  43. }
  44. }
  45.  
  46. void setup()
  47. {
  48. Serial.begin(115200);
  49. //***sensor światła***
  50. delay(5); // The CCS811 wants a brief delay after startup.
  51. Wire.begin();
  52. // APDS9301 sensor setup.
  53. apds.begin(0x39); //I2C address default
  54. if(!SPIFFS.begin()){
  55. Serial.println("An Error has occurred while mounting SPIFFS");
  56. return;
  57. }
  58.  
  59. WiFi.begin(ssid, password);
  60. while (WiFi.status() != WL_CONNECTED) {
  61. delay(1000);
  62. Serial.println("Connecting to WiFi..");
  63. }
  64. Serial.println(WiFi.localIP());
  65.  
  66. server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
  67. request->send(SPIFFS, "/index.html");
  68. });
  69. //String temp=readAPDSTemperature;
  70. server.on("/intensity", HTTP_GET, [](AsyncWebServerRequest *request){
  71. request->send(200, "text/plain", readAPDSTemperature().c_str());
  72. });
  73. server.begin();
  74. }
  75. // Interrupt setup
  76.  
  77. //***connect to WiFi***
  78.  
  79.  
  80.  
  81.  
  82. void loop(void)
  83. {
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement