Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESPAsyncWebServer.h>
- #include <SPIFFS.h>
- float LUMIX_float;
- int LUMIX_int;
- //***dla wyświetlacza U8G2_SH1106_128X64***
- //Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
- //jak zainstalować bibliotekę U8g2 https://github.com/olikraus/u8g2/wiki/u8g2install
- #include <Wire.h>
- //*****************************************
- //***APDS9301 sensor światła****
- #include <Sparkfun_APDS9301_Library.h>
- APDS9301 apds;
- #define INT_PIN 15 // przerwanie z wyjścia INT sensora APDS9301 podłaczone do GPIO 15
- //******************************
- #include <WiFi.h>
- #include "time.h"
- const char* ssid = "luzycka9_plus";
- const char* password = "aabbaacc44";
- //const char* ntpServer = "pool.ntp.org";
- IPAddress ip;
- String IP_string; //zmienna do wyświetlenia IP na U8g2
- AsyncWebServer server(80);
- String readAPDSTemperature()
- {
- float t=apds.readLuxLevel();
- if(isnan(t))
- {
- Serial.println("Failed to read from APDS sensor!");
- return "";
- }
- else
- {
- Serial.println(t);
- Serial.println("ok");
- return String(t);
- }
- }
- void setup()
- {
- Serial.begin(115200);
- //***sensor światła***
- delay(5); // The CCS811 wants a brief delay after startup.
- Wire.begin();
- // APDS9301 sensor setup.
- apds.begin(0x39); //I2C address default
- if(!SPIFFS.begin()){
- Serial.println("An Error has occurred while mounting SPIFFS");
- return;
- }
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(1000);
- Serial.println("Connecting to WiFi..");
- }
- Serial.println(WiFi.localIP());
- server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
- request->send(SPIFFS, "/index.html");
- });
- //String temp=readAPDSTemperature;
- server.on("/intensity", HTTP_GET, [](AsyncWebServerRequest *request){
- request->send(200, "text/plain", readAPDSTemperature().c_str());
- });
- server.begin();
- }
- // Interrupt setup
- //***connect to WiFi***
- void loop(void)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement