Bonjour , je demande aujourd'hui votre aide car je bloque sur un problème, comme dit dans le titre ma carte arduino (jumelé a une wifishield) n'arrive pas a se connecté ( oú a écrire ) dans la base de donnée.
voici mon code:
#include <SPI.h> // bibliothèque de la liaison série
#include <WiFi.h> //Inclure la bibliothèque wifi ECRIRE AVEC DES STRINGS
char ssid[] = "STI2DSIN"; // your network SSID (name)
char pass[] = "sti2dsin"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
int CAPTEUR_TEMP_PIN = 4; // adressage du capteur de temperature (PIN) //
int temp = 0; //définition de la variable entière (integer) //
float temperature = 0; // variable temperature en flottant //
float const_can = 0.0048828; // constante du convertisseur //
WiFiClient client;
String data;
String stringVal;
WiFiServer server(80); //Initialise le serveur wifi, port 80 par défaut pour http
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600); //Affichage écran du PC
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv != "1.1.0") {
Serial.println("Please upgrade the firmware");
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Tentative de connexion au reseau SSID : ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
server.begin();
// you're connected now, so print out the status:
printWifiStatus();
analogRead(CAPTEUR_TEMP_PIN);
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void boy ()
{
temp = analogRead(CAPTEUR_TEMP_PIN); // lecture du capteur de température //
temperature = (((temp*const_can)*1000)-500)/10; //calcul//
if (client.connect("10.172.2.77",80)) { // remplacer par l'adresse IP de votre serveur-ordi
String printwifiarduino = "GET /projet/add.php?temp1=";
String cdrole = printwifiarduino + temperature ;
client.print (cdrole);
client.println( " HTTP/1.1");
client.println( "Host: 10.172.2.77" );
client.println( "Content-Type: application/x-www-form-urlencoded" );
client.println( "Connection: close" );
client.println();
client.println();
client.stop();
Serial.print("donneeecrite");
Serial.println(temperature);
}
else
{
Serial.println("problème de connection 56");
}
if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
}
delay(30000); // attente en millisecondes
}
void loop()
{
boy();
}
le moniteur me dis ça:
Tentative de connexion au reseau SSID : STI2DSIN
SSID: STI2DSIN
IP Address: 10.172.2.77
signal strength (RSSI):-59 dBm
problème de connection 56
problème de connection 56
problème de connection 56
No Socket available
problème de connection 56
No Socket available
et ça en boucle.
je ne sais vraiment pas quoi faire help !