• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

一个WiFi的感情问题

cabi 2017-03-06 浏览量:1336
我正在集成arduino uno wifi,请问有有经验的小伙伴不,我想要把数据通过wifi发到 服务器上,昨天尝试着用ciao 发rest,尝试了一个简单的get,结果总是返回400,
 项目需要。。折腾两天了死活不行啊。。


0 0 收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
最佳答案
  • HTTP的400是请求错误,也就是说你发送的Get参数有误。从串口中把所有发送的socket信息打印出来,和标准的get对照一下就知道了。

    另外用Arduino做产品?建议赶快停止换其他的。

    • 发布于 2017-03-06
    • 举报
    • 评论 3
    • 0
    • 0
cabi 回复了 LiuYang:应该是我的电脑连接上板子的无线网,然后可以设置,让板子连到办公室的无线网,然后电脑在连到同一个无线网就可以了 回复
cabi 回复了 LiuYang:结果现在是电脑连不上板子的无线网 回复
cabi 回复了 LiuYang:所以无法设置 回复

其他答案 数量:3
  • 嗨,您要Ciao的資料和範例可參考以下

    原始碼和說明

    https://github.com/arduino-org/arduino-library-ciao

    使用說明

    http://www.arduino.org/learning/reference/ciao-library

    REST API使用說明

    http://www.arduino.org/learning/reference/ciao-rest

    範例

    設置(json)

    {
     "name" : "rest",
     "description" : "REST connector for the Ciao Core",
     "authors": ["Arduino Team <swdev@arduino.org>;"],
     "repository" : "https://github.com/arduino-org/Ciao",
     "version" : "0.0.1",
     "params" : {
                 }
    }
    啟用(json)

    {
     "name" : "rest",
     "enabled": true,
     "type" : "managed",
     [...]
    }
    Uno程式碼(ino)

    #include <Wire.h>
    #include <Ciao.h>
    #define CONNECTOR     "rest" 
    #define SERVER_ADDR   "192.168.1.1" // change ip address with your server ip address
    int buttonState; //this variable tracks the state of the button, low if not pressed, high if pressed
    int ledState = HIGH; //this variable tracks the state of the LED, negative if off, positive if on
    long lastDebounceTime = 0;  // the last time the output pin was toggled
    long debounceDelay = 50;    // the debounce time; increase if the output flickers
    String command = "/arduino/mode/13/output";
    int previous_value = LOW;
    void setup() {
                   Ciao.begin();
                   Ciao.write(CONNECTOR, SERVER_ADDR, command);
                   pinMode(2, INPUT);
                  }
    void loop() {
                 //sample the state of the button - is it pressed or not?
                 buttonState = digitalRead(2);
                 //filter out any noise by setting a time buffer
                 if ( (buttonState == HIGH) && (previous_value == LOW) && (millis() - lastDebounceTime) > debounceDelay ) {
                                                 if (ledState == HIGH){
                                                                      command = "/arduino/digital/13/0";
                                                                      ledState = LOW;
                                                                      }
                                                else{
                                                     command = "/arduino/digital/13/1";
                                                     ledState = HIGH;
                                                    }
                                                lastDebounceTime = millis(); //set the current time
                                                CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, command);  
                                                if (!data.isEmpty()){
                                                Ciao.println( "State: " + String (data.get(1)) );
                                                Ciao.println( "Response: " + String (data.get(2)) );
                                                }
                                                else{ 
                                                Ciao.println ("Write Error");
                                                }
                 }
                previous_value = buttonState;
    }
    您再對照一下看看哪有問題,可再討論

    • 发布于2017-03-07
    • 举报
    • 评论 0
    • 2
    • 0

aa22 回复了 Eagleson :感觉这个ciao的文档好少啊 回复
aa22 回复了 Eagleson :我之前也遇到过,没学会就放弃了 回复
cabi 回复了 Eagleson :我这几天就遇到了,哎!文档确实好少,谢谢大神的帮助,我根据你发的教程回去在学学 回复
cabi 回复了 Eagleson : 结果我现在板子都连不上网络了。。之前在家里搞得链接的家里的无线网,今天搬到办公室里,直接连不上。。也打不开他的设置页面。。 回复

  • 我知道这个板子,相当于UNO加个wifi模块而已

    引起你这个问题的原因有很多,建议按照如下顺序排查

    1、开发板跟服务器的联系是不是通的,会不会仅仅是连接到服务器的网卡而并未访问到服务器。ping一下确认一下

    2、服务器端的程序有没有问题


    • 发布于2017-03-06
    • 举报
    • 评论 2
    • 0
    • 0
cabi 回复了 chen0000009 :ciao的文档好少的,谢谢大神的支持 回复
chen0000009 回复了 chen0000009 :ciao的文档建议去Arduino官方网站找,网址如下:http://www.arduino.org.cn/blog/arduino-ciao 可以跟你简单介绍一下,这个ciao的英文发音跟中文的“桥”一样,意思就是Arduino可以在wifi端跟MCU端之间弄一条桥这样的意思。有相应的库可以用。我之前发过使用“桥”那个库的文章,你可以看一下 回复

相关问题

问题达人换一批

一个WiFi的感情问题