commit 07597d73c5a1a44901c14ab1949e1a37de4e89e0 Author: gabriel becker Date: Fri Aug 5 01:27:06 2022 -0300 Initial tests and setup. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..6bb127a --- /dev/null +++ b/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:nodemcuv2] +platform = espressif8266 +board = nodemcuv2 +framework = arduino diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0608810 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,65 @@ + +#include +#include +#include +#include +#include + +#ifndef APSSID +#define APSSID "ESPap" +#define APPSK "thereisnospoon" +#endif + +/* Set these to your desired credentials. */ +const char *APssid = APSSID; +const char *APpassword = APPSK; + +const char *ssid = "yourssid"; +const char *password = "yourspassword"; + +ESP8266WebServer web_server(80); +WiFiClient wifiClient; + + +void make_request(){ + HTTPClient http; //Declare object of class HTTPClient + + String ADCData, station, getData, link; + + link = "http://hostname/?m=1&o=1"; + Serial.println("Sent request to:" + link); + http.begin(wifiClient, link); //Specify request destination + + int httpCode = http.GET(); //Send the request + String payload = http.getString(); //Get the response payload + + http.end(); //Close connection +} + +void handleRoot() { + make_request(); + web_server.send(200, "text/html", "

Soy yo

"); +} + +void setup() { + delay(1000); + Serial.begin(9600); + Serial.println(); + Serial.print("Configuring access point..."); + /* You can remove the password parameter if you want the AP to be open. */ + + WiFi.mode(WIFI_AP_STA); + WiFi.softAP(APssid, APpassword); + WiFi.begin(ssid, password); + Serial.println(WiFi.localIP()); + Serial.println(WiFi.softAPIP()); + Serial.println("AP IP address: "); + web_server.on("/", handleRoot); + web_server.begin(); + Serial.println("HTTP server started"); +} + + +void loop() { + web_server.handleClient(); +}