10 votes
Accepted

How to allow cross-domain requests on ESP8266WebServer

Add the CORS header to every response, not only for 'preflight' OPTIONS request. The OPTIONS support is optional, but the response returning the 'shared resource' must contain the CORS header "...
Juraj's user avatar
  • 18.1k
7 votes
Accepted

Serving binary file with ESP8266WebServer

It looks like you can use the send_P function to send raw PROGMEM data: void send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength); I.e., (from what I can gather): PGM_P favicon ...
Majenko's user avatar
  • 105k
7 votes

Multiple client server over wifi

You need to keep track of multiple WiFiClients - declare an array of them, for example, and each time server.available() gives you a new one, store it in the array. Then you need to make sure your ...
Mark Smith's user avatar
  • 2,181
6 votes
Accepted

How can I do web hosting having all the code of the site stored on an SD?

You wrote: the site does not have to be static but constantly updated with new temperature data. A good option is to use Ajax. The basic idea is to split the site in two parts: a static part, ...
Edgar Bonet's user avatar
  • 43.1k
5 votes
Accepted

if two arduinos are connected by I2C and one of them is using an ethernet shield, does that grant both of them access to the internet?

I2C does not automatically share resources between two connected devices. You would not be able to share an Internet connection from a Mega connected via I2C to another Mega which has an Ethernet ...
jose can u c's user avatar
  • 6,974
5 votes

How to assign text stored in a local file to a string at compile time

I found another way to include a literal file (html, css, or other) and assign it to a constant string without resorting to make files: Add one line of code on top of your html (css, js, etc) file, ...
marc's user avatar
  • 51
5 votes
Accepted

What does []() argument in function mean?

That is called a lambda expression and it's a way of including the content of a function as a parameter anonymously instead of writing an actual function and using the name of it. It's shorthand for: ...
Majenko's user avatar
  • 105k
4 votes
Accepted

ESP8266 sends webpage to client, but html codes appears in browser instead of webpage?

It looks like you did not send the HTTP headers. Before sending any of the HTML content send following lines: "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\n\r\n" Make sure you send all the \r\n !...
haya's user avatar
  • 84
4 votes

How to allow cross-domain requests on ESP8266WebServer

just add this line before every response: server.sendHeader("Access-Control-Allow-Origin", "*");
Ahmad Asmndr's user avatar
4 votes

How to allow cross-domain requests on ESP8266WebServer

server.enableCORS(true); The server will add the response Access-Control-Allow-Origin=* header
Barney Flint's user avatar
4 votes
Accepted

ESP32 AP Automatic Web Page

Of course, as soon as I linked that WiFi Manager library in my question, I figured it out. The term I was missing was "captive portal" and I was able to figure it out from there. But I ...
Fromen's user avatar
  • 51
4 votes
Accepted

ERROR: return reinterpret_cast<T>(pgm_read_ptr(p));

With the info from the link Fahad provided in the comments, I can only offer a guess: Your ESP8266 board definitions are outdated and the old version of the ESP8266 board definitions contains a bug. ...
orithena's user avatar
  • 499
3 votes

A simple login page on Arduino Uno

I have a page about a tiny web server for the Arduino Uno or similar boards. It simply isn't true that you can't make one, or that a much more powerful processor would be better. There are some ...
Nick Gammon's user avatar
  • 38.2k
3 votes
Accepted

Sending binary data to HTTP server

You should forget about MIME, that is only needed if you are sending multiple files to the server. Your best bet is to just send these headers, then a blank line, then your data: POST /api/users HTTP/...
BraveNewCurrency's user avatar
3 votes
Accepted

'content' is not captured

Let's look at a simpler example: void setup () { String content = "Basic"; attachInterrupt (digitalPinToInterrupt (2), []() { Serial.println(content); }, FALLING );...
Nick Gammon's user avatar
  • 38.2k
3 votes
Accepted

How do I get the request params from a ESPAsyncWebServer?

For POST request the hasParam needs to know if you want to test the url parameters or x-www-form-urlencoded parameters in body of the POST request. The second parameter of the hasParam is boolean post ...
Juraj's user avatar
  • 18.1k
3 votes

esp8266 WiFi Cannot Connect to a PHP Server

This line: if (client.connect(server,80 && LED == HIGH)) { is definitely not going to do anything useful. Nor is this line: else if(client.connect(server,80 && LED == LOW)) { In ...
romkey's user avatar
  • 1,554
3 votes
Accepted

Mega <> esp8266 comms sending baffling data

The esptool auto-reset feature by default sets io 0 LOW over the RST line and then makes a reset over the DTR line to put the esp8266 into flashing mode. After the upload the esptool resets the board ...
Juraj's user avatar
  • 18.1k
3 votes
Accepted

Webpage values wont update

When the client sends you a request, you should answer only once. Your root() function attempts to answer twice whenever the request contains the argument “duty”. The client will not handle a ...
Edgar Bonet's user avatar
  • 43.1k
3 votes
Accepted

Connecting Web Server in GoDaddy Hosting

I have a domain. Congratulations. It is hosted by GoDaddy. You have my deepest sympathies. I need to connect that server and receive some data by executing PHP files. I am not sure about the ...
Majenko's user avatar
  • 105k
3 votes
Accepted

How do I make two (or more) pins available on my server url?

It looks like you forgot to initialize switchPin1 to be an output. Add the following to your setup() (for example, right after the corresponding initialization commands for switchPin0): void setup() { ...
StarCat's user avatar
  • 1,641
3 votes
Accepted

Generalize webserver routing

You can tell the webserver to serve the static content from a specific folder: server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.html"); In this case it serves ...
chrisl's user avatar
  • 16.3k
3 votes

ESP32 AsyncWebServer with softAP does not serve pages

I don't have enough rep to make a comment on your post, but is it possible that when you give the parameter for the function setDefaultFile() that the forward slash on /index.html is causing the path ...
christopolise's user avatar
3 votes
Accepted

ESP32 AsyncWebServer with softAP does not serve pages

The usage of serveStatic() is wrong. It's not intended to be used inside a callback. Just place the call in the setup of the webserver, i.e.: void WebApp::Begin() { _server.serveStatic("/",...
Mark's user avatar
  • 393
3 votes
Accepted

Why does the data I send to the server get rounded off and how do I send the entire float instead?

The constructor for the String object from float is this: String(double, unsigned char decimalPlaces=2); So if you don't want to have 2 decimal digits, you have to use String(someFloat, 3). Also you ...
KIIV's user avatar
  • 4,752
2 votes

ESP8266 sends webpage to client, but html codes appears in browser instead of webpage?

Slightly off-topic, as this is not the source of your problem, but as jBot42 says, you need a proper regulator. When you use a voltage divider, your load (the ESP8266) is connected in parallel with ...
Alphonsos_Pangas's user avatar
2 votes

ESP8266 sends webpage to client, but html codes appears in browser instead of webpage?

See the text from "'HTTP/1.1 200 OK'" until "'DOCTYPE html'" in the following couple of links which say the same, and you might like to read the rest of those pages: https://www.arduino.cc/en/...
Geoff's user avatar
  • 186
2 votes

Is it possible to use AWS and Arduino Uno to upload data from Arduino to a website running on my localhost?

I realize that this probably two years too late for the OP; however, I'd like to provide insight to anyone else who might be interested. It is possible to do what you're asking. What you are looking ...
Brandon Avant's user avatar
2 votes

Is it possible to use AWS and Arduino Uno to upload data from Arduino to a website running on my localhost?

No, it is not (easily) possible. AWS has no access to your localhost - you are (most likely) behind a NAT router. You could possibly open up port forwarding on your router and then ensure that AWS ...
Majenko's user avatar
  • 105k
2 votes

How to receive data from my server database to a variable in my Arduino?

After you send the GET request, you read the response to fill the char result [20] variable you declared: int i=0; ... if (client.connect(server, port)) { client.print("GET /locator.php?"); ... ...
Mazaryk's user avatar
  • 1,149

Only top scored, non community-wiki answers of a minimum length are eligible