I am having an issue with Node-red and the MQTT broker. I'll let you know, I am very new to Node-red, and my coding is amateur at best. I did not create the flow I am using, or the code. I do fine working with code, just not creating it.
Node-red works fine, except I get the repeating line "Connection failed to broker". I'm connecting my project through an ESP8266-01 to a wifi network, and to my Win 10 PC. I know I am probably missing something simple, but not sure where to look. Here is the NR log, and ESP code below. Let me know if you need any more info. Thanks!
3 Mar 10:02:22 - [info] Node-RED version: v2.0.5
3 Mar 10:02:22 - [info] Node.js version: v14.16.0
3 Mar 10:02:22 - [info] Windows_NT 10.0.19044 x64 LE
3 Mar 10:02:23 - [info] Loading palette nodes
3 Mar 10:02:24 - [info] Dashboard version 2.30.0 started at /ui
3 Mar 10:02:24 - [info] Settings file : C:\Users\mrdog.node-red\settings.js
3 Mar 10:02:24 - [info] Context store : 'default' [module=memory]
3 Mar 10:02:24 - [info] User directory : \Users\mrdog.node-red
3 Mar 10:02:24 - [warn] Projects disabled : editorTheme.projects.enabled=false
3 Mar 10:02:24 - [warn] Flows file name not set. Generating name using hostname.
3 Mar 10:02:24 - [info] Flows file : \Users\mrdog.node-red\flows_DRAGON2.json
3 Mar 10:02:24 - [info] Server now running at http://127.0.0.1:1880/
3 Mar 10:02:24 - [warn]
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
3 Mar 10:02:24 - [info] Starting flows
3 Mar 10:02:24 - [info] Started flows
3 Mar 10:02:24 - [info] [mqtt-broker:288a79fc1071de7a] Connection failed to broker: mqtt://localhost :1883
And here is the code for the ESP in case it makes a difference. I only included the wifi and MQTT code for simplicity. I did set SSID and PW for my home network. The httpPort was just a test.
#include <ESP8266WiFi.h> #include <PubSubClient.h> #include "Arduino.h" const char* ssid = "SSID"; const char* password = "Password"; const IPAddress mqttServerIP(192,168,254,14); // const int httpPort = 1883; const char* deviceID = "ESP8266"; WiFiClient wifiClient; PubSubClient MQTTClient(wifiClient); long lastMsgTime = 0; char msg; char topic; int pulseCount = 0;