<bdo id='TxEJe'></bdo><ul id='TxEJe'></ul>

        <tfoot id='TxEJe'></tfoot>
      1. <i id='TxEJe'><tr id='TxEJe'><dt id='TxEJe'><q id='TxEJe'><span id='TxEJe'><b id='TxEJe'><form id='TxEJe'><ins id='TxEJe'></ins><ul id='TxEJe'></ul><sub id='TxEJe'></sub></form><legend id='TxEJe'></legend><bdo id='TxEJe'><pre id='TxEJe'><center id='TxEJe'></center></pre></bdo></b><th id='TxEJe'></th></span></q></dt></tr></i><div id='TxEJe'><tfoot id='TxEJe'></tfoot><dl id='TxEJe'><fieldset id='TxEJe'></fieldset></dl></div>
        <legend id='TxEJe'><style id='TxEJe'><dir id='TxEJe'><q id='TxEJe'></q></dir></style></legend>

      2. <small id='TxEJe'></small><noframes id='TxEJe'>

      3. 从arduino获取数据并通过ethienet存储在数据库中

        时间:2023-08-21

            <tbody id='vNsng'></tbody>

            <small id='vNsng'></small><noframes id='vNsng'>

          • <tfoot id='vNsng'></tfoot>

                <bdo id='vNsng'></bdo><ul id='vNsng'></ul>
                <legend id='vNsng'><style id='vNsng'><dir id='vNsng'><q id='vNsng'></q></dir></style></legend>
                  <i id='vNsng'><tr id='vNsng'><dt id='vNsng'><q id='vNsng'><span id='vNsng'><b id='vNsng'><form id='vNsng'><ins id='vNsng'></ins><ul id='vNsng'></ul><sub id='vNsng'></sub></form><legend id='vNsng'></legend><bdo id='vNsng'><pre id='vNsng'><center id='vNsng'></center></pre></bdo></b><th id='vNsng'></th></span></q></dt></tr></i><div id='vNsng'><tfoot id='vNsng'></tfoot><dl id='vNsng'><fieldset id='vNsng'></fieldset></dl></div>

                  本文介绍了从arduino获取数据并通过ethienet存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我从 arduino 获取数据并通过 ethienet 存储在数据库中.但是当我从 arduino 获得价值环境时.当我在串行监视器上测试时,它显示了正确的值.但是当我使用 sprintf() 时,我得到了 -3275 或 0 值,这不是正确的值.这是我在草图中的部分代码,请帮助...这是做他的项目的人.Sketch serial montior 的结果是:ambientTemp 23.55 然后 GET/getData/temp.php?t=-3278 我复制了他的一些:获取数据并存入mysql

                  I am getting data from arduino and stored in database through ethienet. But when i got value ambientemp from arduino. it showed correct value when i tested on serial monitor. but when I use sprintf() I got -3275 or 0 value, which it is not correct value. Here is my partial code in sketch, please help...Here is guy doing his project. The result on Sketch serial montior is: ambientTemp 23.55 and then GET /getData/temp.php?t=-3278 I copied some of him: getting data and stored it into mysql

                  void getData() {
                    double ambientTemp=23.55; //to make it easy I assign ambientTemp a value.
                  unsigned long previousMillis = 0;
                  unsigned long currentMillis = 0;
                  long interval = 10000; 
                    char strURL[70];
                  
                  
                     EthernetClient client;
                    // If there's a successful connection, send the HTTP POST request
                     currentMillis = millis();
                    if(currentMillis - previousMillis > interval) {
                      previousMillis = currentMillis;
                  
                    if (client.connect(server, 80)) {
                      Serial.println("get data connecting...");
                  
                      //client.println("GET /getData/temp.php?t=%d,temp HTTP/1.1");
                     // delay(10000);
                       Serial.println("ambientTemp");
                    Serial.println(ambientTemp);
                      sprintf(strURL,"GET /getData/temp.php?t=%d",ambientTemp);
                      delay(50000);
                  
                      client.print(strURL);
                      client.println();
                     // client.print(strURL);
                      Serial.print(strURL);
                  
                  
                  
                    } 
                    else {
                      // If you couldn't make a connection:
                      Serial.println("Connection failed");
                      Serial.println("Disconnecting.");
                      client.stop();
                    }
                  }
                  }
                  

                  推荐答案

                  您需要阅读 C 格式规范.%d" 表示采用相应的变量(在您的情况下为 ambientTemp)并将其解释为整数.所以运行时代码正在做的是查看组成双精度的字节,并解释其中的前 2 个整数.不是你想要的......使用%f"作为格式说明符......

                  You need to read up on C format specifications. "%d" means take the corresponsding variable (ambientTemp in your case) and interpret it as an integer. So what the runtime code is doing is looking at the bytes which make up your double, and interpreting the first 2 of those an in integer. Not what you want.... use "%f" as a format specifier...

                  这篇关于从arduino获取数据并通过ethienet存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Arduino UNO, CC3000: while(client.connected) 下一篇:当多边形的点是经纬度时,如何计算MySQL数据库中

                  相关文章

                  最新文章

                1. <legend id='quXc6'><style id='quXc6'><dir id='quXc6'><q id='quXc6'></q></dir></style></legend>

                  1. <tfoot id='quXc6'></tfoot>

                  2. <small id='quXc6'></small><noframes id='quXc6'>

                      <bdo id='quXc6'></bdo><ul id='quXc6'></ul>
                    <i id='quXc6'><tr id='quXc6'><dt id='quXc6'><q id='quXc6'><span id='quXc6'><b id='quXc6'><form id='quXc6'><ins id='quXc6'></ins><ul id='quXc6'></ul><sub id='quXc6'></sub></form><legend id='quXc6'></legend><bdo id='quXc6'><pre id='quXc6'><center id='quXc6'></center></pre></bdo></b><th id='quXc6'></th></span></q></dt></tr></i><div id='quXc6'><tfoot id='quXc6'></tfoot><dl id='quXc6'><fieldset id='quXc6'></fieldset></dl></div>