problem with HTML page creation

Hi All,

I’m new on Arduino platform, I’m developing a system con remote control switches via web interface on an Arduino Wifi board.
I don’t understand what is wrong in my source code, the program must create an HTML page with 10 buttons for digital ports from 4 to 13, to switch them ON/OFF.
Running the program, browser (chrome) displays only the first 4 buttons.

Any ideas?

following the source:

/*
on your borwser, you type http:///arduino/webserver/ or http://.local/arduino/webserver/

/*
supported boards:Yun,Tian.
Possible commands to send from the xmpp client:
*"/arduino/digital/PIN" → to read a digital PIN
*"/arduino/digital/PIN/VALUE"-> to write a digital PIN (VALUE:1/0)
*"/arduino/analog/PIN/VALUE" → to write in a PWM PIN(VALUE rang:0-255);
*"/arduino/analog/PIN" → to read a analog PIN
*"/arduino/servo/PIN/VALUE" → to write angle in a SERVO PIN(VALUE range:0-180);
*"/arduino/mode/PIN/VALUE" → to set the PIN mode (VALUE: input / output)
Example:
“/arduino/mode/13/output”-> pinMode(13, OUTPUT)
“/arduino/digital/13/1” → digitalWrite(13, HIGH)
http://labs.arduino.org/WebServerBlink
*/

#include <Wire.h>
#include <SPI.h>
#include <ArduinoWiFi.h>
#include <dht.h>

dht DHT;

#define Sensore1 2
#define Sensore2 3

void setup()
{
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);

Wifi.begin();
String command = Wifi.readStringUntil(’/’);

}

void loop()
{
while(Wifi.available())
{
// read the command
String command = Wifi.readStringUntil(’/’);
if (command == “digital”)
{
int pin, value;
pin = Wifi.parseInt();
if (Wifi.read() == ‘/’)
{
value = Wifi.parseInt();
digitalWrite(pin, value);
}
}

if (command == “webserver”)
{
// lettura temperature e umiditÃ
int chk = DHT.read11(Sensore1);
long T1=DHT.temperature;
long H1=DHT.humidity;
chk = DHT.read11(Sensore2);
long T2=DHT.temperature;
long H2=DHT.humidity;

// scrivo pagina HTML
Wifi.println(F(“HTTP/1.1 200 OK”));
Wifi.println(F(“Content-Type: text/html”));
Wifi.println(F(“Refresh: 5”)); // refresh the page automatically every 5 sec
Wifi.println();
Wifi.println(F(""));
Wifi.println(F(""));
Wifi.println(F(""));

// temperatura e umidità
Wifi.print(F(“Sala1 Temp: “));
Wifi.print(T1);
Wifi.print(F(” Umid:”));
Wifi.print(H1);
Wifi.println(F("
"));

Wifi.print(F(“Sala2 Temp: “));
Wifi.print(T2);
Wifi.print(F(” Umid:”));
Wifi.print(H2);
Wifi.println(F("
"));
Wifi.println();

String Pulsante1=F("<button onclick=window.open(’/arduino/digital/");
String Pulsante2=F("/1’);w.close();>ON");
String Pulsante3=F("/0’);w.close();>ON");
// porte digitali
for (int NumPorta = 4; NumPorta <= 13; NumPorta++)
{
int StatoPorta = digitalRead(NumPorta);
if (StatoPorta==0)
{
Wifi.print(Pulsante1);
Wifi.print(NumPorta);
Wifi.print(Pulsante2);
Wifi.print(F(""));
}
else
{
Wifi.print(Pulsante1);
Wifi.print(NumPorta);
Wifi.print(Pulsante3);
Wifi.print(F("
"));
}
Wifi.println(F("
“));
}
// chiusura pagina html
Wifi.println();
Wifi.println(F(”"));
Wifi.println(F(""));
Wifi.println();
Wifi.println(DELIMITER); // very important to end the communication !!!
}
}
}

Which WiFi device do you have? The Ethernet shield, and most WiFi shields, are SPI devices. That means that you can NOT use pins 10 through 13 for other purposes.

If your device is using some lind of SoftwareSerial interface, which pins is it actually using?

You seem to assume that you can use all the pins from 0 to 13. That is almost certainly not true.

      String Pulsante2=F("/1');w.close();>ON</button>");
      String Pulsante3=F("/0');w.close();>ON</button>");

Why do /0 and /1 both correspond to ON?

as I wrote at the beginning of my post, I'm using Arduino WiFi, with integrate WiFi interface, that means that all 14 ports are available, anyway I tried to reduce the ""for" loop at 10 ports but it's the same: looking at the source of html into the browser, after the html line of the fourth button, the next line is truncated as if it stopped to trasmit html code to the client.

"Why do /0 and /1 both correspond to ON?"

you are right, it is an error, second line is OFF

tk :-)

anyone can help me?

Suggested tests to isolate the problem. Do one at a time and undo the changes for previous test before continuing with the next:

1: Comment all this out

  digitalWrite(0,HIGH);
  digitalWrite(1,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);
  digitalWrite(10,HIGH);
  digitalWrite(11,HIGH);
  digitalWrite(12,HIGH);
  digitalWrite(13,HIGH);

2: If that brought no change, comment this line out:

Wifi.println(F("Refresh: 5"));  // refresh the page automatically every 5 sec

3: If that brought no change, alter this line:

if (StatoPorta==0)

to:

if ( true )

4: If that brought no change, alter this line:

if (StatoPorta==0)

to:

if ( false )

Do you see anything with the HTML debugger in Chrome ? Have you tried another browser ?

OP’s assumption that all 14 digital pins are available for manipulation is patently false. There are two pins being used to talk to the ESP chip on the board. Whether that is pins 0 and 1, and Serial, or other pins and an instance of SoftwareSerial is not clear from their page, and I can’t find the link to download the library that OP is using to check.

It’s a shame that adafruit couldn’t be bothered pointing out which pins are being used to talk to the ESP chip.