IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Arduino Discussion :

Enregistrer donnée sur Mysql Server


Sujet :

Arduino

  1. #21
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    En prenant le code de base de https://www.arduino.cc/en/Tutorial/WebClient : oui cela fonctionne.
    Mon arduino se connecte bien à internet

    En modifiant le code et faisant en sorte qu'il se connecte à mon serveur voilà ce que ca me donne sachant que j'envoie en GET deux variable :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    connecting...
    connected
    HTTP/1.1 200 OK
    Date: Fri, 08 Jan 2016 07:28:49 GMT
    Server: Apache
    X-Powered-By: PHP/5.5.30
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: text/html
     
    41
    Connection to MySQL server xxxxxxx.db.1and1.com successful!
     
     
    2b
    Database xxxxxxxxxxx successfully selected!
    9a
     
    <!doctype html>
    <html lang="fr">
    <head>
      <meta charset="utf-8">
      <title>Arduino</title>
      <link rel="stylesheet" href="style.css">
    </head>
    <body>
     
    11111
    15
     
     test</body>
    </html>
     
    0
     
     
    disconnecting.

  2. #22
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Cependant en modifiant le code officiel en ajoutant les données de teleinfo, ca ne fonctionne plus bien sur !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
     
    #include <SoftwareSerial.h>
    #include <SPI.h>
    #include <Ethernet.h>
     
    byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF9, 0x81 };
     
    char server[] = "www.martin-valentin.fr";    // name address for Google (using DNS)
    IPAddress ip(192, 168, 0, 177);
    EthernetClient client;
     
    SoftwareSerial cptSerial(2, 3);
    #define startFrame 0x02
    #define endFrame 0x03
    #define startLine 0x0A
    #define endLine 0x0D
     
    void setup() {
      cptSerial.begin(1200);
      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...");
    }
     
    String GetTeleInfo()
    {
        String TeleInfo = "";
        char charIn = 0;
        while (charIn != startLine)
        {
            charIn = cptSerial.read() & 0x7F;
        }
        while (charIn != endLine)
        {
            if (cptSerial.available() > 0)
            {
                charIn = cptSerial.read() & 0x7F;
                TeleInfo += charIn;
            }
        }
        return TeleInfo;
    }
     
    String ShowTeleInfo(String keyword, String unit, int length)
    {
        int essai = 0;
        // Nombre d'étiquettes maximum, cf documentation ERDF
        int max_essais = 33;
        String data = "";
        String msg = "";
        while(data.substring(0,keyword.length()) != keyword && essai != max_essais)
        {
            data = GetTeleInfo();
            essai++;
        }
        msg = "\t<";
        msg += keyword;
        msg += " unit=\"";
        msg += unit;
        msg += "\">";
        if (essai != max_essais)
        {
            msg += data.substring((keyword.length() + 1),(length + (keyword.length() + 1)));
        }
        else
        {
            msg += "NA";
        }
        msg += "</";
        msg += keyword;
        msg += ">";
        return msg;
    }
     
    void loop() {
      if (client.connect(server, 80)) {
        boolean current_line_is_blank = true;
        Serial.println("connected");
        // if there are incoming bytes available
        // from the server, read them and print them:
        if (client.available()) {
          char c = client.read();
          Serial.print(c);
          if (c == '\n' && current_line_is_blank)
          {
            // Make a HTTP request:
            client.println("GET /teleinfo/add_data.php?");
     
            client.print(" HTTP/1.1");
            client.println("Host: www.martin-valentin.fr");
            client.println("Connection: close");
            client.println();
          }
          if (c == '\n')
          {
              current_line_is_blank = true;
          }
          else if (c != '\r')
          {
              current_line_is_blank = false;
          }
        }  
      } else {
        // if you didn't get a connection to the server:
        Serial.println("connection failed");
      }
     
      // if the server's disconnected, stop the client:
      if (!client.connected()) {
        Serial.println();
        Serial.println("disconnecting.");
        client.stop();
     
        // do nothing forevermore:
        while (true);
      }
      delay(5000);
    }

  3. #23
    Expert confirmé
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 660
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 660
    Par défaut
    Il y a aussi un point qui m'intrigue dans ton code. Ce sont tes if :
    Code c : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    if (c == '\n' && current_line_is_blank)
    (...)
    if (c == '\n')
    (...)
    else if (c != '\r')
    qui ne servent à rien à mes yeux.

    D'ailleurs, est-ce que la première condition est vraie pour que les données puissent effectivement partir ?

    Et cette variable :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    boolean current_line_is_blank = true;
    qui n'est "visible" que dans le if en question et est réinitialisée à chaque tour de boucle et par conséquent vaut toujours true.

  4. #24
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Ce code certes en anglais reprends la même structure que moi et explique bien à quoi sert currentLineIsBlank = true; et mes différents if

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
     
    void loop()
    {
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            Serial.print(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println("HTTP/1.1 200 OK");
              client.println("Content-Type: text/html");
              client.println();
     
              // output 
              client.println("connection OK");
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } 
            else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
      }
    }

  5. #25
    Modérateur

    Avatar de Bktero
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2009
    Messages
    4 493
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2009
    Messages : 4 493
    Billets dans le blog
    1
    Par défaut
    Ne serait-il pas mieux (plus robuste, plus pratique, mieux testé) d'utiliser un client HTTP plutôt que d'écrire les requêtes manuellement ? https://www.arduino.cc/en/Tutorial/HttpClient

  6. #26
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Le HTTPclient ne permet il pas seulement de récupérer des informations du net? Dans mon cas je veux les envoyer sur un serveur distant

  7. #27
    Modérateur

    Avatar de Bktero
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2009
    Messages
    4 493
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2009
    Messages : 4 493
    Billets dans le blog
    1
    Par défaut
    En regardant le source https://github.com/amcewen/HttpClient, je vois GET, PUT, POST DELETE. HTTP quoi. HTTP, ce n'est pas que récupérer le contenu d'une page web

  8. #28
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    En soi, c'est exactement ce que je fais ^^ ou du moins je ne vois pas du tout la différence avec mon code actuel

  9. #29
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    A partir du code en anglais ci-dessus, j'ai réécrit mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
     
    #include <SoftwareSerial.h>
    #include <SPI.h>
    #include <Ethernet.h>
     
    byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF9, 0x81 };
     
    char server[] = "www.martin-valentin.fr";    // name address for Google (using DNS)
    IPAddress ip(192, 168, 0, 177);
    EthernetClient client;
     
    SoftwareSerial cptSerial(2, 3);
    #define startFrame 0x02
    #define endFrame 0x03
    #define startLine 0x0A
    #define endLine 0x0D
     
    void setup() {
      cptSerial.begin(1200);
      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...");
    }
     
    String GetTeleInfo()
    {
        String TeleInfo = "";
        char charIn = 0;
        while (charIn != startLine)
        {
            charIn = cptSerial.read() & 0x7F;
        }
        while (charIn != endLine)
        {
            if (cptSerial.available() > 0)
            {
                charIn = cptSerial.read() & 0x7F;
                TeleInfo += charIn;
            }
        }
        return TeleInfo;
    }
     
    String ShowTeleInfo(String keyword, String unit, int length)
    {
        int essai = 0;
        // Nombre d'étiquettes maximum, cf documentation ERDF
        int max_essais = 33;
        String data = "";
        String msg = "";
        while(data.substring(0,keyword.length()) != keyword && essai != max_essais)
        {
            data = GetTeleInfo();
            essai++;
        }
        msg = "\t<";
        msg += keyword;
        msg += " unit=\"";
        msg += unit;
        msg += "\">";
        if (essai != max_essais)
        {
            msg += data.substring((keyword.length() + 1),(length + (keyword.length() + 1)));
        }
        else
        {
            msg += "NA";
        }
        msg += "</";
        msg += keyword;
        msg += ">";
        return msg;
    }
     
    void loop()
    {
      client = server.available();
      if (client.connect(server, 80)) 
      {
        boolean currentLineIsBlank = true;
        while (client.connected()) 
        {
          if (client.available()) 
          {
            char c = client.read();
            Serial.print(c);
            if (c == '\n' && currentLineIsBlank) 
            {
              client.println("GET /teleinfo/add_data.php?");
              client.print("ADCO=");
              client.print(ShowTeleInfo("ADCO","",12));
              client.print("&&");
              client.print("OPTARIF=");
              client.print(ShowTeleInfo("OPTARIF","",4));
              client.print("&&");
              client.print("ISOUSC=");
              client.print(ShowTeleInfo("ISOUSC","A",2));
              client.print("&&");
              client.print("BASE=");
              client.print(ShowTeleInfo("BASE","Wh",9));
              client.print("&&");
              client.print("HCHC=");
              client.print(ShowTeleInfo("HCHC","Wh",9));
              client.print("&&");
              client.print("HCHP=");
              client.print(ShowTeleInfo("HCHP","Wh",9));
              client.print("&&");
              client.print("EJPHN=");
              client.print(ShowTeleInfo("EJPHN","Wh",9));
              client.print("&&");
              client.print("EJPHPM=");
              client.print(ShowTeleInfo("EJPHPM","Wh",9));
              client.print("&&");
              client.print("BBRHCJB=");
              client.print(ShowTeleInfo("BBRHCJB","Wh",9));
              client.print("&&");
              client.print("BBRHPJB=");
              client.print(ShowTeleInfo("BBRHPJB","Wh",9));
              client.print("&&");
              client.print("BBRHCJW=");
              client.print(ShowTeleInfo("BBRHCJW","Wh",9));
              client.print("&&");
              client.print("BBRHPJW=");
              client.print(ShowTeleInfo("BBRHPJW","Wh",9));
              client.print("&&");
              client.print("BBRHCJR=");
              client.print(ShowTeleInfo("BBRHCJR","Wh",9));
              client.print("&&");
              client.print("BBRHPJR=");
              client.print(ShowTeleInfo("BBRHPJR","Wh",9));
              client.print("&&");
              client.print("PEJP=");
              client.print(ShowTeleInfo("PEJP","min",2));
              client.print("&&");
              client.print("PTEC=");
              client.print(ShowTeleInfo("PTEC","",4));
              client.print("&&");
              client.print("DEMAIN=");
              client.print(ShowTeleInfo("DEMAIN","",4));
              client.print("&&");
              client.print("IINST=");
              client.print(ShowTeleInfo("IINST","A",3));
              client.print("&&");
              client.print("IINST1=");
              client.print(ShowTeleInfo("IINST1","A",3));
              client.print("&&");
              client.print("IINST2=");
              client.print(ShowTeleInfo("IINST2","A",3));
              client.print("&&");
              client.print("IINST3=");
              client.print(ShowTeleInfo("IINST3","A",3));
              client.print("&&");
              client.print("IMAX=");
              client.print(ShowTeleInfo("IMAX","A",3));
              client.print("&&");
              client.print("IMAX1=");
              client.print(ShowTeleInfo("IMAX1","A",3));
              client.print("&&");
              client.print("IMAX2=");
              client.print(ShowTeleInfo("IMAX2","A",3));
              client.print("&&");
              client.print("IMAX3=");
              client.print(ShowTeleInfo("IMAX3","A",3));
              client.print("&&");
              client.print("PMAX=");
              client.print(ShowTeleInfo("PMAX","W",5));
              client.print("&&");
              client.print("PAPP=");
              client.print(ShowTeleInfo("PAPP","VA",5));
              client.print("&&");
              client.print("HHPHC=");
              client.print(ShowTeleInfo("HHPHC","",1));
              client.print("&&");
              client.print("MOTDETAT=");
              client.print(ShowTeleInfo("MOTDETAT","",6));
              client.print("&&");
              client.print("PPOT=");
              client.print(ShowTeleInfo("PPOT","",2));
              client.print(" HTTP/1.1");
              client.println("Host: www.martin-valentin.fr");
              client.println("Connection: close");
              client.println();
     
     
              client.println("connection OK");
              break;
            }
            if (c == '\n') 
            {
              currentLineIsBlank = true;
            } 
            else if (c != '\r') 
            {
              currentLineIsBlank = false;
            }
          } else {
            Serial.println("connection failed");
          }
          if (!client.connected()) 
          {
            Serial.println();
            Serial.println("disconnecting.");
            client.stop();
     
            // do nothing forevermore:
            //while (true);
          }
        }
        delay(5000);
        client.stop();
      }
    }
    et voici le code coté serveur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
     
    <?php
        // Connect to MySQL
        include('dbconnect.php');
     
        /*http://martin-valentin.fr/teleinfo/add_data.php?ADCO=040422168851&OPTARIF=BASE&ISOUSC=30&HCHC=0&HCHP=0*/
        $_ADPS  = null;
     
        $_ADCO = $_GET['ADCO'];
        $_OPTARIF = $_GET['OPTARIF'];
        $_ISOUSC = $_GET['ISOUSC'];
        $_BASE = $_GET['BASE'];
        $_HCHC = $_GET['HCHC'];
        $_HCHP = $_GET['HCHP'];
     
    ?>
     
    <!doctype html>
    <html lang="fr">
    <head>
      <meta charset="utf-8">
      <title>Arduino</title>
      <link rel="stylesheet" href="style.css">
    </head>
    <body>
    <?php
    	echo $_HCHC;
    	echo $_BASE;
    	echo " ";
    	echo "test";
    ?>
    </body>
    </html>
    J'ai une erreur au niveau de la ligne client = server.available();

    sketch_jan08b:87: error: request for member 'available' in 'server', which is of non-class type 'char [23]'
    request for member 'available' in 'server', which is of non-class type 'char [23]'

    Que je comprends pas...

  10. #30
    Expert confirmé
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 660
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 660
    Par défaut
    Citation Envoyé par tintin02100 Voir le message
    A partir du code en anglais ci-dessus, j'ai réécrit mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    char server[] = "www.martin-valentin.fr";    // name address for Google (using DNS)
    J'ai une erreur au niveau de la ligne client = server.available();

    sketch_jan08b:87: error: request for member 'available' in 'server', which is of non-class type 'char [23]'
    request for member 'available' in 'server', which is of non-class type 'char [23]'

    Que je comprends pas...
    Normal, server est de type char[]. Il n'y a pas de méthode avaible().
    Tu as dû confondre avec l'objet Server.

  11. #31
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Citation Envoyé par Auteur Voir le message
    Normal, server est de type char[]. Il n'y a pas de méthode avaible().
    Tu as dû confondre avec l'objet Server.
    D'accord Auteur, de ce fait je peux le retirer de mon code?
    Même sans, le code me renvoie "connection failed"

    Aaaaaah :calmi:

    Quelqu'un pourrait il essayait d'écrire un code en reprenant les elements utiles à la teleinfo et et faire comme un envoie sur serveur distant?
    Ou du moins transformer le miens? Parce que là, je ne vois vraiment pas...

  12. #32
    Expert confirmé
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 660
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 660
    Par défaut
    Malheureusement, je ne possède pas ce genre de shield. Je ne peux pas t'aider d'avantage.

    Mais à partir de ton mini-pc peux-tu réaliser les opérations que tu veux ? Par exemple, avec un programme C++ (en utilisant d'éditeur Code::Blocks) tu peux essayer de te connecter à ton serveur puis d'envoyer tes données. Cela te permettra de voir où cela bloque. Ensuite, (le plus dur c'est vrai), tu peux retranscrire le programme réalisé pour ton PC vers Arduino.

  13. #33
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Bon je vais y regarder... peut-être que quelqu'un d'autre aura la solution à mon problème.
    En tout cas merci beaucoup pour ton aide

  14. #34
    Expert confirmé
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 660
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 660
    Par défaut
    Bonjour,

    je viens de penser à quelques chose : tu as indiqué que tu arrivais à te connecter sur un site tel que google. Du coup essaye d'envoyer une requête à Google puis de récupérer les résultats (que tu enverras à ton mini-pc via le port série par exemple). Cela te permettra peut-être de comprendre la source des problèmes, non ?

  15. #35
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Je ne comprends pas...
    Je vais essayer sur un autre serveur.
    Voir si c'est mon code ou 1&1 qui bug...

  16. #36
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Bon même sur un autre serveur, ca ne fonctionne pas... je vais donc comme tu dis Auteur prendre les infos du port com puis récupérer les informations en local et les envoyer ensuite sur mon serveur par PHP.

  17. #37
    Expert confirmé
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 660
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 660
    Par défaut
    Bonjour,

    je vais donc comme tu dis Auteur prendre les infos du port com puis récupérer les informations en local et les envoyer ensuite sur mon serveur par PHP
    non, non tu n'as pas compris (ou alors je n'ai pas compris ce que tu as écrit ) : tu utilises Arduino pour interroger un serveur connu (j'ai pris Google), puis tu récupères les résultats obtenus, toujours avec ton Arduino et son shield. L'envoi des données sur port série sert seulement à vérifier, puisqu'Arduino n'a pas d'écran, les résultats sur une console en l'occurrence celle de l'IDE Arduino.
    A partir de là, je pense et j'espère que cela te permettra de trouver la solution à ton problème.

  18. #38
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Ben en réalité c'est déjà ce que je fais
    Et sur la console, j'ai vraiment l'impression que tout est bon xD

  19. #39
    Membre averti
    Homme Profil pro
    Aucune
    Inscrit en
    Mai 2014
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Aisne (Picardie)

    Informations professionnelles :
    Activité : Aucune

    Informations forums :
    Inscription : Mai 2014
    Messages : 28
    Par défaut
    Problème résolu

    Erreur mais c*nne mais vraiment de ******
    client.println("GET /teleinfo/add_data.php?"); -> client.print("GET /teleinfo/add_data.php?");

    Je sautais une ligne donc les données ne pouvaient pas passer

  20. #40
    Expert confirmé
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 660
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 660
    Par défaut


    surtout que tu n'as utilisé que des print() dans ton code. Un println et plus rien ne marche.
    Par contre, tu as bien des println() à la fin. A quoi servent-t-ils ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    client.println("Host: www.martin-valentin.fr");
              client.println("Connection: close");
              client.println()

Discussions similaires

  1. pb de connexion sur mysql-server
    Par nora2311 dans le forum Administration
    Réponses: 10
    Dernier message: 06/01/2009, 17h16
  2. Chargement des données sur mysql
    Par ecom_adil dans le forum SQL Procédural
    Réponses: 0
    Dernier message: 25/02/2008, 17h08
  3. limitation de données sur SQL server / Access / MySQL
    Par alexfrei04 dans le forum Décisions SGBD
    Réponses: 4
    Dernier message: 06/02/2007, 15h43
  4. modéliser une base de données sur SQL Server ..
    Par Alexy3171 dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 19/11/2006, 15h57
  5. Réponses: 3
    Dernier message: 27/04/2006, 10h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo