Tag: esp8266

MQTT.js订阅接收来自代理的相同消息的倍数

我在CloudMQTT运行,我的JS代码是这样的: var mqtt_url = URL.parse('mqtt://m10.cloudmqtt.com:15272' || 'mqtt://localhost:1883'); var auth = (mqtt_url.auth || ':').split(':'); var url = "mqtt://" + mqtt_url.host; var options = { port: mqtt_url.port, clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8), username: USERNAME, password: PASSWORD, }; // Create a client connection var client = mqtt.connect(url, options); client.on('connect', function() { // When connected // subscribe to a […]

Arduino + ESP8266 WebClient

我需要将我的ESP8266与Arduino Mega连接起来,但是我没有任何库将它连接成Serial1中的ESP8266 WebClient。 我尝试使用Arduino的WifiLibrary 。 我尝试使用ESP8266WiFi.h作为Serial1,但我找不到改变串行端口的方法。 所以我无法切换到Serial1 WiFiClient客户端。 我在这里需要一些帮助,伙计们。 谢谢!

将NodeMCU Lua套接字客户端连接到node.js socket.io服务器

我想连接一个NodeMCU Lua套接字客户端到node.js socket.io服务器。 NodeMCU Lua代码: sk = net.createConnection(net.TCP, 0) sk:on("receive", function ( sck,c ) print (c) end) sk:on("connection", function ( sck,c ) print("Connected") sk:send("Helloooo…") end) sk:connect(12346,"192.168.1.100") Node.js服务器代码: var express = require('express'); var app = express(); var server = require('http').Server(app); var io = require('socket.io')(server); io.on('connection', function(socket){ console.log('someone is connected'); }); server.listen(12346); 问题: Lua客户端的on连接事件被触发并打印“Connected”,但是node.js socket.io服务器中的on连接事件未被触发。 我尝试了一个Python套接字服务器的Lua客户端,它工作得很好! 而且我还尝试了一个使用Javascript套接字客户端的node.js套接字服务器,它运行良好! […]

NodeMCU node.jsencryption

我试图build立node.js和NodeMCU之间的encryption通信。 经过一番努力之后,我可以使用node.js进行encryption,并在NodeMCU上进行解密。 反过来不起作用。 mscdex的答复工作。 因此,我修改了node.js代码以利于他人。 谢谢。 NodeMCU代码: crypto = require('crypto'); cipher = crypto.encrypt("AES-CBC", "0123456789abcdef", "some clear text data",'0000000000000000') print(crypto.toHex(cipher)) //95f27285ba29aeae1e48cfc6e821b0a15a0dd6c5a1e636e10c5497c460ed057b print(crypto.toBase64(cipher)) //lfJyhboprq4eSM/G6CGwoVoN1sWh5jbhDFSXxGDtBXs= Node.js工作代码: var crypto=require('crypto'); //crypto module is required algorithm = 'aes-128-cbc'; //define algorithm password = '0123456789abcdef'; //define key iv='0000000000000000'; // define vector for cbc.. Must be 16 char length function encrypt(text,opts) { if(typeof opts […]