Passing parameters from browser to Arduino Server


I have a project running on a MEGA with a W5500, reading sensors, recording data non an SD card, sending daily status email and showing the sensor data on a simple web server hosted on the Arduino. It also has a TFT touchscreen, where I read basic information and basic controls along with calibrating the sensors. I can also upload the sketches via Ethernet and TelnetPrint (thanks @Juraj !)

Now, I’d like to move to the next step, adding some timer functionality to it (and save it to EEPROM), It involves many timer parameters and many, so trying to do this on the tiny TFT seems tedious.

I have read and researched ways to GET data from a browser to the Arduino web server but, I’ll be darned if I can find a example Example on which to grow. Probably using the wrong search terms

Basically Arduino MEGA with W5500 Ethernet in server mode, accepting data input in fields in a browser…

If someone can put me on the right path, I’ll GET you a beer :rofl:


there is a WebServer library for Ethernet

Thanks Judah,

Are you referring to:
“GitHub - sirleech/Webduino: Arduino WebServer library” GitHub - sirleech/Webduino: Arduino WebServer library

So, I found what seems to be EXACTLY what I’m looking for, a scheduler here:

Except it is written for a Phpoc Shield and I have a basic Ethernet shield (for testing) and a w5500.

I tried to replace all mentions of “Phpoc” with " Ethernet" and updated the timing functions with TimeLib.h…

trying to run the sketch, i do get the serial monitor to report back an IP address, but my browser won’t connect…

here is my modified code:

void loop() {
    scheduleLoop(); // check whether there is any config command from Web or not.

	if(isOnSchedule()) { // check whether current time is on schedule or not
		/* TO DO */
		unsigned long currentMillis = millis();

		if(currentMillis - previousMillis >= interval) {
			previousMillis = currentMillis;

			if (ledState == LOW) 
				ledState = HIGH;
				ledState = LOW;

			digitalWrite(ledPin, ledState);
	else {
		if (ledState == HIGH) {
			ledState = LOW;
			digitalWrite(ledPin, ledState);

void eepromToSchedule(void) {
	String schedule;
	int lineCount = EepromCSV.line();

	if(lineCount > MAX_SCHEDULE)
		lineCount = MAX_SCHEDULE;

	for(int i = 0; i < lineCount; i++) {
		schedule = EepromCSV.readLine(i);

		scheduleArray[i][DAY]			= schedule.substring(0, 1).toInt();
		scheduleArray[i][START_HOUR]	= schedule.substring(2, 4).toInt();
		scheduleArray[i][START_MINUTE]	= schedule.substring(5, 7).toInt();
		scheduleArray[i][END_HOUR]		= schedule.substring(8, 10).toInt();
		scheduleArray[i][END_MINUTE]	= schedule.substring(11, 13).toInt();

	numSchedule = lineCount;
void sendToWeb(String data) {
	char wbuf[18];

    data.toCharArray(wbuf, data.length() + 1);
    configServer.write(wbuf, data.length());
void scheduleLoop(void) {
    EthernetClient client = configServer.available();

    if(client) {
        if(client.available() >= 17) {
			char rbuf[17];
			String data, schedule;
			int cmd;

  , 17);
            data = String(rbuf);
            cmd = data.substring(0, 1).toInt();

           if(cmd == CMD_ARDUINO_GET) {
				int lineCount = EepromCSV.line();

                sendToWeb(String(CMD_WEB_CLR) + ",0,00:00,00:00\r\n"); /* tell web clear to load new schedule */

                for(int i = 0; i < lineCount; i++) {
                    schedule = EepromCSV.readLine(i); /* read schedule from EEPROM one by one */
                    sendToWeb(String(CMD_WEB_UPD) + "," + schedule + "\r\n"); /* send schedule to Web */
			else if(cmd == CMD_ARDUINO_CLR) {
                EepromCSV.clear(); /* clear to update new schedule */
				eepromToSchedule(); /* reload schedule from EEPROM */
            else if(cmd == CMD_ARDUINO_ADD) {
                schedule = data.substring(2, 15);
                EepromCSV.writeLine(schedule); /* write schedule to EEPROM */
                eepromToSchedule(); /* reload schedule from EEPROM */
bool isOnSchedule(void) {
	int day, hour, minute;

	day		= weekday();
	hour	= hour();
	minute	= minute();
	for(int i = 0; i < numSchedule; i++) {
		if(day() == scheduleArray[i][DAY]) {
			int curTime, startTime, endTime;

			curTime		= hour() * 60 + minute();
			startTime	= scheduleArray[i][START_HOUR] * 60 + scheduleArray[i][START_MINUTE];
			endTime		= scheduleArray[i][END_HOUR] * 60 + scheduleArray[i][END_MINUTE];

			if(curTime >= startTime && curTime < endTime)
				return true;

	return false;

void EepromCSV::clear(void) { 
	EEPROM.write(0, EOF);
int EepromCSV::line(void) {
	int lineCount   = 0;
	int address     = 0;
	char value;

	while(1) {
		value =;

		if(value == '\n')
		else if(value == EOF)
			return lineCount;
String EepromCSV::readLine(int line) {
	String retStr   = "";
	char value;
	int lineIndx    = 0;
	int address     = 0;

	while(lineIndx < line) {
		value =;
		if(value == '\n')
		else if (value == EOF) {
			return "";

	while(1) {
		value =;

		if(value == '\n' || value == EOF)
			return retStr;
			retStr += value;
void EepromCSV::writeLine(String lineStr) { /* add new line at the end of CSV file*/
	int address, length;

	address	= 0;
	length	= lineStr.length();

	while((char) != EOF)

	for(int i = 0; i < length; i++)
		EEPROM.write(address++, lineStr.charAt(i));

	EEPROM.write(address++, '\n');
	EEPROM.write(address, EOF);

I suspect the issue might lie where I replace:
probably the Phpoc is more capable than the Ethernet shield.


EthernetWebServer library

Thanks Juraj;

I spent all day on this darn thing and I’m more and more confused.

There seem to be various ways of transferring data to and from server/browser. As of now, I see:

D- …

I may have a total of three webpages displaying from my MEGA/w5500:
1- Time and data from a few sensors (updated every 5 seconds or so)
2- A simple user/passcode page, in order to get to page 3
3- A page, where I can set timer/schedule parameters Start(weekDay, time, Duration), to be saved to the EEPROM.

Given these specs, can someone tell me, which of A,B,C,D… I should try to learn first (or exclusively). Ideally, I’d like to feed my webpage from the SD Card… My C programming skills being beginner/intermediate, my HTML/JavaScript being ZERO!


you could try to copy and modify the simple web server I use in my projects.

content of folder data goes to SD card. this is the web part. modify it for your project.
the server is in WebServer.ino

I have created my own parser that can read full request for instance:
GET /action.html?fname=XYZ&fname2=XXX
Via strtok() C function I can parse these values that are there for key fname (20.50 in this case) or fname2 (0.25 in this case) and use them in my program.

I am using it for storing datas in EEPROM that are used for thermostat (hysteresis, target temperature) so logic is periodically running via millis() each 10 seconds for controlling thermostat. I am using it for Ethernet / Ethernet2 and for UIPEthernet library aswell without changes in code, these libraries are great :slight_smile: Using same functions with another header .h file based on used Ethernet module.

Thanks All;

I’m overwhelmed. I’m going to install the project as is and let it work for a while. I’ll then either start teaching myself the necessary pieces (HTML, CSS, JS etc), or sign up for a Udacity class…

Thanks again, in particular @Juraj , who’s been guiding me along out ever since my project got an ethernet connection a few months ago…

Greetings from rainy, Covidy and rioty Colombia!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.