-
How to subscribe to a MQTT topic?
ESP sends messages, but does not accept.
code:
var server = "m14.cloudmqtt.com";
var options = {client_id : "random", keep_alive: 60, clean_session: true, port: 15577, username: "ciugiy**", password: "eYV1ivUWk***", protocol_name: "MQTT", protocol_level: 4,
};
var mqtt = require("MQTT").create(server, options);
var wifi = require("Wifi");function onInit() {
wifi.stopAP();wifi.connect("INGRI", {password: "3hotswf3"}, function(err) { // 192.168.83.196// //wifi.connect("AndroidAP", {password: "tssu7350"}, function(err) { // 192.168.83.196// if(err)console.log(err);else console.log("connected!"); console.log(wifi.getIP().ip); wifi.getStatus(function(ap) { if(ap.station === 'connected'){ mqtt.on('connected', function() { print("connect!!!"); var topic = "test/espruino"; var message = "hello, world"; mqtt.publish(topic, message); }); mqtt.on('publish', function (pub) { console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); mqtt.on('disconnected', function() { console.log("MQTT disconnected... reconnecting."); setTimeout(function() { mqtt.connect(); print("mqtt connect"); }, 2000); }); mqtt.connect(); } }); });
}
wifi.save();
save(); -
-
Here is the working code! Whom it is necessary.
var server = "m14.cloudmqtt.com"; var options = { keep_alive: 60, port: 15577, username: "ciug****", password: "eYV1ivU****", protocol_name: "MQTT", protocol_level: 4 }; var mqtt = require("MQTT").create(server, options); var wifi = require("Wifi"); function onInit() { wifi.stopAP(); wifi.connect("AndroidAP", {password: "tssu7350"}, function(err) { if(err)console.log(err);else console.log("connected!"); console.log(wifi.getIP().ip); wifi.getStatus(function(ap) { if(ap.station === 'connected'){ print("START..."); mqtt.on('connected', function() { print("connect!!!"); mqtt.subscribe("test"); }); mqtt.on('publish', function (pub) { console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); mqtt.on('disconnected', function() { print("disconnected!!!"); console.log("MQTT disconnected... reconnecting."); setTimeout(function() { mqtt.connect(); print("mqtt connect"); }, 2000); }); mqtt.connect(); } }); }); } wifi.save(); save();
-
-
This is my code:
var server = "m14.cloudmqtt.com"; var options = { client_id : "random", keep_alive: 60, port: 35577, clean_session: true, username: "ciugi**", password: "eYV1i*****", protocol_name: "MQTT", protocol_level: 4, }; var mqtt = require("MQTT").create(server, options); mqtt.on('connected', function() { mqtt.subscribe("test"); }); mqtt.on('publish', function (pub) { console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); var wifi = require("Wifi"); function onInit() { wifi.stopAP(); wifi.connect("INGRIFAB", {password: "B73vFeX6se2"}, function(err) { if(err)console.log(err);else console.log("connected!"); console.log(wifi.getIP().ip); }); } var server = "m14.cloudmqtt.com"; var options = { client_id : "random", keep_alive: 60, port: 35577, clean_session: true, username: "ciugi**", password: "eYV1i*****", protocol_name: "MQTT", protocol_level: 4, }; var mqtt = require("MQTT").create(server, options); mqtt.on('connected', function() { mqtt.subscribe("test"); }); mqtt.on('publish', function (pub) { console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); var wifi = require("Wifi"); function onInit() { wifi.stopAP(); wifi.connect("INGRIFAB", {password: "B73vFeX6se2"}, function(err) { if(err)console.log(err);else console.log("connected!"); console.log(wifi.getIP().ip); }); } wifi.save(); save();
-
Can't connect to https://api.cloudmqtt.com. What's wrong? Is this even possible?
-
Did not see the MQTT module. More can that where to disable that would work MQTT.
| __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v94 Copyright 2016 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 4MB:512/512, manuf 0xef chip 0x4016 >var server = "m14.cloudmqtt.com"; ="m14.cloudmqtt.com" ={ "client_id": "random", "keep_alive": 60, "port": 15577, "clean_session": true, "username": "", "password": "", "protocol_name": "MQTT", "protocol_level": 4 } >var mqtt = require("MQTT").create(server, options); Uncaught Error: Module "MQTT" not found at line 1 col 26 var mqtt = require("MQTT").create(server, options); ^
-
Want to use just such a charge. Will work?
https://www.aliexpress.com/item-img/Cortex-M3-STM32F103VCT6-core-board-minimum-system-board-STM32-ARM-development-board/32609092448.html# -
-
-
-
-
-
-
-
-
Can be more of where and what to lay down
I have here are modules:
require("ESP8266"),
require("Wifi"),
require("DHT22").connect(D14),
require("http").request(options, function(res)I downloaded the files from http://www.espruino.com/modules/ .If you just put the files in the project folder it does not work.
Prescribed path to the file C:\Users\a_morozov\Documents\M.
Or was not necessary?
It does not work.EspruinoWiFi.min
EspruinoWiFi
ESP8266WiFi_0v25.min
ESP8266WiFi_0v25
ESP8266WiFi.min
ESP8266WiFi
DHT22.min
DHT22What are you doing wrong?
-
-
Today has stopped working DHT22 module. What could be the problem? Yesterday everything worked.
1v93 Copyright 2016 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
Flash map 4MB:512/512, manuf 0xe0 chip 0x4016WARNING: Module "DHT22" not found
Uncaught Error: Field or method "connect" does not already exist, and can't create it on undefined
at line 3 col 27dht = require("DHT22").connect(D14), ^
=undefined
Found the problem:
If you are using the Web IDE as is, the modules will be loaded from http://www.espruino.com/modules/. This URL can be changed in Web IDE settings and There is no problem.
The url was https://. -
The esp8266 has two UARTS. UART0 (Serial1) uses gpio1 for TX and gpio3 for RX and is used by the Espruino JavaScript console. It can be used for other things once the Espruino console is moved to another device. For instance calling LoopbackA.setConsole() will move the console to 'loopback' (where is can be accessed using LoopbackB), and will free up Serial1 for use like any normal Espruino Serial port.
And no problems. -
-
Power not via USB.
I work with Web IDE via wifi and everything works fine. When Disconnected from the Web IDE, ESP12f rebooted and serial1 to communicate with SIM800L not working.
The problem is serial1. How to fix?Here in this place, the module hangs and restarts.
function Start_modem(){
digitalWrite(D5, false);
var connection = setInterval(function(){ Serial1.println("AT+COPS?");},300);
Serial1.on('data', function (data) {print("<Serial1> "+data); if(data.indexOf("+COPS:")>-1){ clearInterval(connection); //print("modem start"); init_modem(); digitalWrite(D5, true); } if(data.indexOf("+CUSD: 0, ")>-1){ list_balanse(data); //print("SMS OK"); digitalWrite(D5, true); }
});
}
This is a subscription to the topic :) Learn English!:)