HTTP Access on Due is more slowly then on Mega

Hi Guys,

I’m working on a Projekt of a Smart Home System for my study and realized it by Arduino Mega.

I send a HTTP Request to my Arduino and when it comes on there it will be do

…digitalWrite(x, HIGH/LOW);

an sent all states of all pins (22-36) in one datapacket back:

void StatusSendenLedPinHTML()
{
	EthernetClient client = server.available();
	client.println("HTTP/1.1 200 OK");
	client.println("Content-Type: text/html");
	client.println();
	int index = 22;
	client.print("LEDST");
	while (index < 37)
	{
		client.print(digitalRead(index), DEC);
		index++;
	}
	//Serial.println("Status aller LEDPINs zurueck an HTTP Client gesendet");
}

Thís method runs much more slowly with my Due as on Mega! (time difference is round about 500-800ms!)

i try to reduce the client.print() Item to just one Item with text and writing a for-loop with a temporary String value:

	String OutData = "LEDST";
	for (int i = 22; i < 37; i++)
	{
		OutData += digitalRead(i);
	}
	EthernetClient client = server.available();
	client.println("HTTP/1.1 200 OK");
	client.println("Content-Type: text/html");
	client.println();
	client.print(OutData);	
	//Serial.println("Status aller LEDPINs zurueck an HTTP Client gesendet");

…without success it’s same speed as before.

How this is possible? the clock speed of the Due is about 84 MHz and at the Mega it’s 16 Mhz. on theoritical thinking with Due it might be faster, but it isn’t is.

I see it in my smartphone app, the buttons are switching faster, when the Sketch is running on Mega.

Is there a Solution existing to write/read the digital pins faster with Due?

push

I don't have a problem with the due.

I usually pass along the client instance so I don't have to recreate it if I don't have to.

void StatusSendenLedPinHTML(EthernetClient client)

tec_freakz: push

Hi Pushi!

The solution to your problem is to correct the programming mistakes you made in your code.

Especially the programming mistakes you didn't show.

The few lines of excerpt code you posted contain no obvious programming mistakes .