Ciao a tutti i membri di questo forum. Ho un urgenza poiché la scuola sta finendo e ho avuto un inceppo con il mio progetto da presentare alla maturità.
Il problema è che arduino non è più in grado di salvare un valore nel Database. Se inserisco il percorso nella barra del browser, il valore viene registrato ma tramite arduino no. Questo è il codice, spero mi aiutate ...
Codice arduino
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "5d2........it"; // name address for Google (using DNS)
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 1, 178);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
}
void loop() {
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /nunci/prova1.php?temp=20 HTTP/1.1");
client.println("Host: 5d2........it");
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
client.stop();
delay(2000);
}
Nel serial monitor di Arduino IDE cosa ti da ? Quali serial.print vedi ?
La butto li, non so se c'entra.
Da browser ci sono tutte le impostazioni, DNS compreso.
Su Arduino fai Ethernet.begin(mac); oppure Ethernet.begin(mac, ip);
e quindi non è indicato il DNS. Magari Arduino non entra con dhcp e non ha dns.
Verifica i msg sul monitor seriale.
Dici: "Il problema è che arduino non è più in grado di salvare un valore nel Database"
quindi prima lo faceva. Cosa hai cambiato ? qualcosa nel software ? sul router ?
nid69ita:
Nel serial monitor di Arduino IDE cosa ti da ? Quali serial.print vedi ?
La butto li, non so se c'entra.
Da browser ci sono tutte le impostazioni, DNS compreso.
Su Arduino fai Ethernet.begin(mac); oppure Ethernet.begin(mac, ip);
e quindi non è indicato il DNS. Magari Arduino non entra con dhcp e non ha dns.
Verifica i msg sul monitor seriale.
Dici: "Il problema è che arduino non è più in grado di salvare un valore nel Database"
quindi prima lo faceva. Cosa hai cambiato ? qualcosa nel software ? sul router ?
Io non ricordo cosa ho cambiato o se ho cambiato qualcosa. Comunque, i Serial.print che vedo sono solamente: "Connecting" e "Connected".
gpb01: No, su altre board la chiamata è semplicemente ignorata, senza alcuna attesa.
Guglielmo
Guglielmo, ricordavo male io ? O forse è stato cambiato qualcosa da qualche anno versione fa ?
Ricordo anche che il Serial Monitor bloccava l'upload di uno sketch, ma ultimamente non ci sono più problemi a fare upload con serial monitor aperto.
nid69ita:
Guglielmo, ricordavo male io ? O forse è stato cambiato qualcosa da qualche anno versione fa ?
Io ricordo sempre la stessa descrizione di ora ... :
On the Leonardo, if (Serial) indicates whether or not the USB CDC serial connection is open. For all other instances, including if (Serial1) on the Leonardo, this will always return true.