1
如何將數據從Socket.io(NodeJs服務器)發送到arduino? 我有一個ESP8266 Wifi盾,我可以發送和接收數據嗎?如果我可以有任何基本的例子嗎?我如何使用Arduino套接字客戶端? 我覺得像這個例子Arduino Socket.io溝通
我可以這樣使用嗎?
#include <SPI.h>
#include <Ethernet.h>
#include "SocketIOClient.h"
SocketIOClient client;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char hostname[] = "";
// Socket.io "chat_message" event handler
void chat_message(EthernetClient ethclient, char *data){
Serial.print("Message : ");
Serial.println(data);
}
void setup() {
Serial.begin(9600);
Ethernet.begin(mac);
Serial.print("Arduino is on ");
Serial.println(Ethernet.localIP());
if(client.connect(hostname, 3000, "socket.io", "/chat_room")) {
Serial.println("Socket.IO connected !");
} else {
Serial.println("Socket.IO not connected.");
}
//Event hanlders
client.setEventHandler("chat_message", chat_message);
//Say hello! to the server
client.emit("chat_message", "Arduino here, hello!");
}
void loop() {
client.monitor();
}
ABI薩納ulaşabileceğim井KAPI變種mıdıracaba? :( –
解決了你的問題?@Ahmad – cagdas
Yok abiçözümbulamadı[email protected]ım –