Initial tests and setup.
This commit is contained in:
commit
07597d73c5
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
14
platformio.ini
Normal file
14
platformio.ini
Normal file
@ -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
|
65
src/main.cpp
Normal file
65
src/main.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <WiFiClient.h>
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#include <ESP8266HTTPClient.h>
|
||||||
|
#include <WiFiClient.h>
|
||||||
|
|
||||||
|
#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", "<h1>Soy yo</h1>");
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user