Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ArduinoJson.h>
- #include <ESP8266WiFi.h>
- #include <ESP8266WebServer.h>
- const char *ssid = "TEST123456789"; // The name of the Wi-Fi network that will be created
- const char *password = "Bananya"; // The password required to connect to it, leave blank for an open network
- ESP8266WebServer server(80);
- void setup() {
- Serial.begin(115200);
- Serial.println('\n');
- WiFi.softAP(ssid, password); // Start the access point
- Serial.print("Access Point \"");
- Serial.print(ssid);
- Serial.println("\" started");
- Serial.print("IP address:\t");
- Serial.println(WiFi.softAPIP()); // Send the IP address of the ESP8266 to the computer
- server.begin();
- server.on("/BallOnPlateControll", assignValues);
- }
- void loop() {
- server.handleClient(); // Keep the recieving server running
- }
- void assignValues(){
- String incomingValues = server.arg("plain"); // Data will come in in a plain text format
- StaticJsonBuffer<175> jsonBufferBytes; // A buffer for the entire JSON post in text format
- JsonObject& jsonObject = jsonBufferBytes.parseObject(incomingValues); // Turn the entire incoming post into a parsable object to extract data
- int contentOfName = jsonObject["Mode"]; // Get the data that is stored under "nameA"
- server.send(204,""); // Send a response to the computer so it knows it was recieved
- Serial.print(contentOfName);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement