This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wifi signalK display
#9
TEST UPDATE:

I installed and activated MQTT plugin trying to send simulated signalk values (lat, long and deep)
restarted SK

[Image: GetAttachmentThumbnail?id=AQMkADAwATY3Zm...ation=true]
[Image: GetAttachmentThumbnail?id=AQMkADAwATY3Zm...ation=true]

this is the code in the esp8266: (from here)
Code:
#include <ESP8266WiFi.h>
#include <Wire.h>  // Only needed for Arduino 1.6.5 and earlier
//#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
#include <ESP8266mDNS.h>
#include <PubSubClient.h>

////////////////////////wifi///////////////////////
const char* ssid = "MyHomeWiFi";
const char* password = "MyHomeWiFiPassWord";

const char* mqtt_server = "IP assigned to RPI"; // ip


//const char* mqtt_server = "rpi-speak.local";

WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;

//SSD1306  display(0x3c, 4, 5); //d1 mini
//SSD1306 display(0x3c, D1, D2); //ESP8266 w/OLED
//SSD1306 display(0x3c, D2, D1); //NodeMCU

#define D1mini 1 //1 - using D1 mini

void setup() {
 
 Serial.begin(9600);
 setup_wifi();
 client.setServer(mqtt_server, 1883);
 client.setCallback(callback);
//  display.init();

//  display.flipScreenVertically();
//  display.setFont(ArialMT_Plain_10);
   reconnect();
}

void setup_wifi() {

 delay(10);
 // We start by connecting to a WiFi network
 Serial.println();
 Serial.print("Connecting to ");
 Serial.println(ssid);

 WiFi.begin(ssid, password);

 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
 }
Serial.println("");
 Serial.println("WiFi connected");
 Serial.println("IP address: ");
 Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
 Serial.print("Message arrived [");
 Serial.print(topic);
 Serial.print("] ");
//  display.clear();
 String msg;
 for (int i = 0; i < length; i++) {
   Serial.print((char)payload[i]);
   //display.clear();
   msg += (char)payload[i];
 }
  // display.setTextAlignment(TEXT_ALIGN_LEFT);
//    display.setFont(ArialMT_Plain_10);
   if (D1mini) {
//      display.drawStringMaxWidth(35,13,60,msg); //d1 mini
     } else {
//      display.drawStringMaxWidth(0,0,120,msg); //ESP8266 w/OLED   }
     }
//    display.display();
 
 
 Serial.println();

}

void reconnect() {
 // Loop until we're reconnected
 while (!client.connected()) {
   Serial.print("Attempting MQTT connection...");
   // Attempt to connect
   uint32_t chipid=ESP.getChipId();
   char clientid[25];
   snprintf(clientid,25,"WIFI-Display-%08X",chipid); //this adds the mac address to the client for a unique id
   Serial.print("Client ID: ");
   Serial.println(clientid);
   if (client.connect(clientid)) {
     Serial.println("connected");
     // Once connected, publish an announcement...
     //client.publish("Say", "-t 'hello world'");
     // ... and resubscribe
     client.subscribe("display1");
   } else {
     Serial.print("failed, rc=");
     Serial.print(client.state());
     Serial.println(" try again in 5 seconds");
     // Wait 5 seconds before retrying
     delay(5000);
   }
 }
}

void loop() {

// if (!client.connected()) {
 //  reconnect();
// }
 client.loop();
 
}

the esp connect to my home wifi but the serial monitor say:

Code:
Connecting to MyHomeWiFi
............
WiFi connected
IP address:
***.***.*.**
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7
failed, rc=5 try again in 5 seconds
Attempting MQTT connection...Client ID: WIFI-Display-0029DCD7

what's missing?

tnks a lot
Reply


Messages In This Thread
wifi signalK display - by cepicscepics - 2018-11-26, 11:43 AM
RE: wifi signalK display - by PaddyB - 2018-11-26, 01:56 PM
RE: wifi signalK display - by cepicscepics - 2018-11-26, 02:03 PM
wifi signalK display - by tkurki - 2018-11-27, 08:47 AM
RE: wifi signalK display - by cepicscepics - 2018-12-02, 01:53 AM
RE: wifi signalK display - by tkurki - 2018-12-02, 05:56 PM
RE: wifi signalK display - by cepicscepics - 2018-12-02, 07:04 PM
RE: wifi signalK display - by JeroenAdam - 2018-12-08, 09:23 PM
RE: wifi signalK display - by cepicscepics - 2018-12-09, 01:58 AM
RE: wifi signalK display - by tkurki - 2018-12-09, 08:46 AM
RE: wifi signalK display - by cepicscepics - 2018-12-09, 12:04 PM
RE: wifi signalK display - by cepicscepics - 2018-12-09, 06:19 PM
RE: wifi signalK display - by cepicscepics - 2018-12-10, 09:41 AM
RE: wifi signalK display - by cepicscepics - 2018-12-11, 10:48 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)