发 帖  
原厂入驻New
如何把数据通过wifi发到服务器上?
190 WIFI
分享
我正在集成arduino uno wIFi,请问有有经验的小伙伴不,我想要把数据通过wifi发到 服务器上,昨天尝试着用ciao 发rest,尝试了一个简单的get,结果总是返回400, 项目需要。。折腾两天了死活不行啊。。
0
2020-6-17 09:06:16   评论 分享淘帖 邀请回答
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; } 您再對照一下看看哪有問題,可再討論
2020-6-17 14:14:45 评论

举报

云汉达人 邀请回答

http://www.arduino.cn/thread-41339-1-1.html
Arduino UNO WIFI资料集合:

  • 代码自动生成工具支持ArduinoUnoWiFi http://club.gizwits.com/thread-4689-1-1.html


  • Arduino UNO WIFI 套件简介,以及联网说明http://club.gizwits.com/thread-4631-1-1.html
  • ArduinoUNOWiFi接入机智云介绍  http://club.gizwits.com/thread-4677-1-1.html
  • ArduinoUnoWiFi 之ESP8266固件烧写教程 http://club.gizwits.com/thread-4630-1-1.html
  • ArduinoUnoWiFi SDK之API介绍http://club.gizwits.com/thread-4629-1-1.html
2020-6-17 14:27:44 评论

举报

我知道这个板子,相当于UNO加个wifi模块而已
引起你这个问题的原因有很多,建议按照如下顺序排查
1、开发板跟服务器的联系是不是通的,会不会仅仅是连接到服务器的网卡而并未访问到服务器。ping一下确认一下
2、服务器端的程序有没有问题
2020-6-17 14:41:29 评论

举报

只有小组成员才能发言,加入小组>>

275个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /7 下一条

快速回复 返回顶部 返回列表