ciao a tutti di nuovo,
ho trovato uno dei problemi: se nella scrittura della pagina web richiedo ad arduino di stampare una temperatura, il tempo di attesa per visualizzare la pagina html è infinitamente più lungo; come posso risolvere?
questo è un esempio semplice che rende l'idea:
#include <WiServer.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Wireless configuration parameters —————————————-
unsigned char local_ip[] = {192,168,1,120}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"Cisco Home 2,4 gHz"}; // max 32 bytes
unsigned char security_type = 3; // 0 – open; 1 – WEP; 2 – WPA; 3 – WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"xxx"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure – connect to AP
// adhoc – connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters —————————————-
// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
WiServer.print("<html>");
WiServer.print("<br><br>Temperatura: ");
WiServer.print(sensors.getTempCByIndex(0));
WiServer.print("</html>");
// URL was recognized
return true;
//}
// URL not found
return false;
}
void setup() {
WiServer.init(sendMyPage);
sensors.begin();
}
void loop(){
sensors.requestTemperatures();
WiServer.server_task();
// delay(10);
}