Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <ArduinoJson.h>
  2. #include <ESP8266WiFi.h>
  3. #include <ESP8266WebServer.h>
  4.  
  5. const char *ssid = "TEST123456789"; // The name of the Wi-Fi network that will be created
  6. const char *password = "Bananya"; // The password required to connect to it, leave blank for an open network
  7.  
  8. ESP8266WebServer server(80);
  9. void setup() {
  10. Serial.begin(115200);
  11. Serial.println('\n');
  12.  
  13. WiFi.softAP(ssid, password); // Start the access point
  14. Serial.print("Access Point \"");
  15. Serial.print(ssid);
  16. Serial.println("\" started");
  17.  
  18. Serial.print("IP address:\t");
  19. Serial.println(WiFi.softAPIP()); // Send the IP address of the ESP8266 to the computer
  20. server.begin();
  21. server.on("/BallOnPlateControll", assignValues);
  22. }
  23.  
  24. void loop() {
  25. server.handleClient(); // Keep the recieving server running
  26. }
  27.  
  28. void assignValues(){
  29. String incomingValues = server.arg("plain"); // Data will come in in a plain text format
  30. StaticJsonBuffer<175> jsonBufferBytes; // A buffer for the entire JSON post in text format
  31. JsonObject& jsonObject = jsonBufferBytes.parseObject(incomingValues); // Turn the entire incoming post into a parsable object to extract data
  32. int contentOfName = jsonObject["Mode"]; // Get the data that is stored under "nameA"
  33. server.send(204,""); // Send a response to the computer so it knows it was recieved
  34. Serial.print(contentOfName);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement