8 votes
Accepted

Arduino webserver: faster alternative to "indexof" for parsing GET requests?

Well, for fast parsing I wouldn't use String for a start. I've written an example (below) which does away with the String class, and also demonstrates parsing the line once. #include <SPI.h> #...
  • 35.4k
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 ...
  • 103k
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 ...
  • 2,147
7 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 "...
  • 16.5k
7 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: ...
  • 103k
6 votes
Accepted

How can I do web hosting having all the code of the site stored in a 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, ...
  • 37.4k
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 ...
  • 6,932
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, ...
  • 51
4 votes
Accepted

NODEMCU vs AT for esp8266

This is quite a huge topic to cover in one answer, but I will do my best. The NodeMCU can be used in three distinctly different ways. First is the AT mode, where you have installed the AT firmware. ...
  • 103k
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 !...
  • 84
4 votes

How to allow cross-domain requests on ESP8266WebServer

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

How to allow cross-domain requests on ESP8266WebServer

server.enableCORS(true); The server will add the response Access-Control-Allow-Origin=* header
3 votes

Getting values from multiple thermistors - one value glitches all over the place

Here's a major problem: void loop() { uint8_t i; float average; float average_two; float average_three; float stuckintime; for (i = 0; i < ...
  • 35.4k
3 votes
Accepted

Using a web server with Arduino

You can use an Arduino Yun: it has a 32u4 microcontroller coupled with a cpu running linux. The linux side already has a webserver: together with the Bridge library, you can use REST-like APIs to ...
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/...
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 );...
  • 35.4k
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 ...
  • 1,254
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 ...
  • 16.5k
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 ...
  • 37.4k
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 ...
  • 103k
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() { ...
  • 1,450
3 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 ...
  • 31
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 ...
  • 14.2k
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 ...
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 ...
  • 4,147
2 votes

Bluetooth Master and Slave to track device's locations

Bluetooth generally support only one to one connection. Atmost 6 bluetooth can be connected to single module in latest bluetooth version(the basic model probably used by you connects only 1 device). ...
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?"); ... ...
  • 1,101
2 votes
Accepted

Is it possible to accept multiple web requests at once?

It can be done. The Arduino is a single tasking environment so you have to make sure your code is non-blocking. BlinkWithoutDelay is a good starting point (thanks @Majenko) but you should also look ...
  • 156
2 votes

Is an Arduino capable of running 24/7?

Is an Arduino capable of running 24/7? This is a reliability question. In reliability, there are a lots of things to consider. The software. There are more robust softwares. There are less robust ...
  • 391
2 votes
Accepted

Is there any way to separate this short code into its own function? (webserver, trying to use client.print outside of main loop)

You can pass client to the function by reference, like this: void displayBullet(EthernetClient & client, int toggle) { if (toggle == 0) //switch is off, so display red bullet client....
  • 35.4k

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