mqtt

mqtt between esp8266 and arduino with PubSubclient

社会主义新天地 提交于 2019-12-01 10:56:41
I am using ESP8266 with arduino using WiFiEsp library.I want to make MQTT connection with arduino so I use PubSubclient library.i got error: Attempting MQTT connection...failed, rc=-2 try again in 5 seconds my code is: #include <WiFiEsp.h> #include <WiFiEspClient.h> #include <WiFiEspUdp.h> #include "SoftwareSerial.h" #include <PubSubClient.h> IPAddress server(212, 72, 74, 21); char ssid[] = "atmel"; // your network SSID (name) char pass[] = "bets56789"; // your network password int status = WL_IDLE_STATUS; // the Wifi radio's status // Initialize the Ethernet client object WiFiEspClient

how to use ssl/tls in paho mqtt using python i got certificate verify failed

半世苍凉 提交于 2019-12-01 08:42:32
问题 hi I am working on IOT internet of things I am using paho MQTT I need to use SSL I wrote publish code using python I got an error in "certificate verify failed" please help me thank in advance MY PUBLISHING CODE import time import paho.mqtt.client as paho import ssl import certifi #define callback def on_message(client, userdata, message): time.sleep(1) print("received message =",str(message.payload.decode("utf-8"))) client= paho.Client("client-001") client.on_message=on_message print(

Publishing MQTT messages from a Python script on a Raspberry Pi

我们两清 提交于 2019-12-01 08:17:36
问题 I am trying to configure a Raspberry Pi (Raspbian, Jessie) to send temperature data from a DS18B20 sensor to my MQTT broker. I have installed mosquitto, mosquitto-clients, and python-mosquitto. I have also installed paho-mqtt. Mosquitto seems to be working fine; I can publish from the command line but I can not get ANY python script I've written or found to publish or subscribe. Why does this work from the command line, mosquitto_pub -h 192.168.0.21 -d -t test/test -m "Hello world!" while

SSL certificate verification on ESP8266 Wemos D1 Mini with MQTT broker

一个人想着一个人 提交于 2019-12-01 07:55:43
问题 I have a raspberry pi 3 with raspbian stretch as its operating system. I have installed and fully configured a MQTT broker on the raspberry pi following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04 Everything works fine and well on the broker's side. The certificates get renewed after 60 days and you can only connect to port 1883 via the localhost and the other ports (8883 and 8083) are open but

干货 | 设备快速上云,轻松搞定设备与云端通信

北城余情 提交于 2019-12-01 07:53:16
本文主要讲解如何使用京东云物联网引擎产品,快速创建产品及设备,并通过SDK将设备安全地连接至云端,实现设备的数据上报与订阅,让刚接触该产品的用户能够对京东云物联网平台有个初步的认识。 目前京东云 IoT Device SDK 提供了C语言开发包,访问链接进行下载: jdcloud-iot-device-sdk-c.zip ( https://docs.jdcloud.com/cn/iot-core/device-sdk-download-link ) 京东云IoT Device SDK,是提供给设备厂商,用于集成在设备之上,并通过SDK安全的将设备连接至京东云物联网引擎进行管理。设备必须要支持TCP/IP协议才能使用Device SDK,其他非IP设备或非标准MQTT协议的设备,需要通过网关,边缘节点以及物联网协议适配才能接入物联网引擎。目前SDK面向MQTT C语言开发者,支持Linux系统环境。 SDK架构 应用业务逻辑、SDK、HAL的关系如下图所示: 应用只需关心使用SDK API组合业务逻辑,无需关心通信细节,HAL层需要用户根据自身的OS和设备信息进行适配,SDK提供了Linux的HAL层适配。 快速上手,设备接入操作步骤 登入物联网引擎控制台( https://iot-console.jdcloud.com/core/ ),用户进行开通服务后,即可进入快速接入设备页面

AWS IoT Android application over MQTT throws MqttException (0) - java.io.IOException: Already connected

让人想犯罪 __ 提交于 2019-12-01 06:56:24
I am trying to use 'Authenticate using Cognito-Identity with Cognito user pool' in my Android application. My Cognito user pool authentication works well, when I run that separately and I had seen a JWTToken as well. When I run the the 'PubSub' sample application with Unauthenticated role, it worked as expected. When I integrate these two features in one application, the application threw following error. W/System.err: MqttException (0) - java.io.IOException: Already connected W/System.err: at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)

Processing a received message using paho mqtt in python

时间秒杀一切 提交于 2019-12-01 06:47:42
问题 import paho.mqtt.client as mqtt def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) client.subscribe("/leds/pi") def on_message(client, userdata, msg): if msg.topic == '/leds/pi': print(msg.topic+" "+str(msg.payload)) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect("localhost", 1883, 60) client.loop_start() I use this basic code to subscribe to a topic and receive a message. The on_message function gets

Websocket is not working with SSL

爱⌒轻易说出口 提交于 2019-12-01 02:37:51
https://www.hi-todd.com/websocket/ I have created one demo with MQTT protocol and it is working fine with HTTP connection. But when I tried to change HTTP to https then it is getting a connection error. I have added certificate path in mosquitto.conf file. Let me share with you Mosquitto config path. # WebSockets over TLS/SSL listener 8083 protocol websockets cafile /etc/mosquitto/ca_certificates/ca.crt certfile /etc/mosquitto/ca_certificates/hi-todd_com.crt keyfile /etc/mosquitto/ca_certificates/hi-todd_com.p7b I have used below library code. https://www.cloudmqtt.com/docs-websocket.html Now

How to use a self signed certificate to connect to a Mqtt server in Android (paho client)?

跟風遠走 提交于 2019-12-01 02:00:59
Im having problem connecting to a mqtt server using self signed certificate. im using Paho client and want to connect to a server using a TLSv1.2 . actually i was successful to connect in Android APIs 20+ but no success for below this version. what ive done till now : 1- created a PKCS#12 keystore and put the .crt file and assing a password to it and save it (it will be a .pfx file) 2- added the .pfx file to raw folder of recourse in android project 3- used below code to load self signed certificate: connection = createConnection(mqttCallback); MqttConnectOptions connOpts = optionsFromModel

js使用mqtt请求数据

二次信任 提交于 2019-12-01 01:58:35
1.引入mqtt的js库,地址链接 https://blog.csdn.net/qq_28877125/article/details/78360170 <script src="./static/js/mqttws31.js" type="text/javascript"></script>   出现format报错的话引入如下js,问题是由于ES6中取消了new Date的format()方法,所以要使用此js引入到依赖中。 (function () { // Defining locale Date.shortMonths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] Date.longMonths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] Date.shortDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] Date.longDays = ['Sunday', 'Monday',