Replies: 7 comments 1 reply
-
I don't know of any off hand, I havent worked with Mqtt on an ESP32 yet (other than pre-installing OpenMqttGateway) but I think its probably a good example. I'll leave this open and im sure someone will get to it at some stage |
Beta Was this translation helpful? Give feedback.
-
I'm making it now, can I post it here when done?
…On Sat, Nov 18, 2023, 2:23 AM Brian Lough ***@***.***> wrote:
I don't know of any off hand, I havent worked with Mqtt on an ESP32 yet
(other than pre-installing OpenMqttGateway) but I think its probably a good
example. I'll leave this open and im sure someone will get to it at some
stage
—
Reply to this email directly, view it on GitHub
<#60 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABP5YW5CUV767U34KF6HHULYFBPAHAVCNFSM6AAAAAA7QSXGNKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TMMBVGIZDK>
.
You are receiving this because you authored the thread.Message ID:
<witnessmenow/ESP32-Cheap-Yellow-Display/repo-discussions/60/comments/7605225
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
I have it working, currently displaying a mqtt topic on Temp1, could use some help making it look better - like a larger font, and maybe a dial bar graph of some type..... #include <Wire.h> TFT_eSPI tft = TFT_eSPI(); const char *ssid = "YOUR WIFI SSID"; WiFiClient espClient; void setup_wifi() { WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { Serial.println(""); void callback(char* topic, byte* payload, unsigned int length) { void reconnect() { void setup() { } void loop() { |
Beta Was this translation helpful? Give feedback.
-
I need help, im tried using the OpenFontReader lib to prettify my display, but its nut taking my string speed and as input, it works fine if i just type a number in quotes.....I dont get why #include <Wire.h> #define TTF_FONT NotoSans_Bold // The font is referenced with the array name TFT_eSPI tft = TFT_eSPI(); const char *ssid = "YOUR WIFI SSID"; WiFiClient espClient; void setup_wifi() { WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { Serial.println(""); void callback(char* topic, byte* payload, unsigned int length) { // old way of drawing teh numbers on the screen // new way of drawing the number using the OpenFontreader library void reconnect() { void setup() { tft.begin(); // Load the font and check it can be read OK } void loop() { |
Beta Was this translation helpful? Give feedback.
-
edit: deleted original post about trying hex(). misunderstood question and commented before reading code.
edit2:
the code looks like there is a little too much effort to parse out speed value embedded in an MQTT payload. we probably want something like HiveMQ's showing data validation here and show readers of the example how to lock down what the 'payload' must and must not contain.
https://www.hivemq.com/blog/getting-started-mqtt-data-validation-hivemq-data-hub/
@F4u5t I'd be glad to help
…On Sat, Nov 18, 2023 at 1:50 PM F4u5t ***@***.***> wrote:
I need help, im tried using the OpenFontReader lib to prettify my display,
but its nut taking my string speed and as input, it works fine if i just
type a number in quotes.....I dont get why
#include <Wire.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include <TFT_eSPI.h>
#include "NotoSans_Bold.h"
#include "OpenFontRender.h"
#define TTF_FONT NotoSans_Bold // The font is referenced with the array
name
OpenFontRender ofr;
TFT_eSPI tft = TFT_eSPI();
const char *ssid = "YOUR WIFI SSID";
const char *password = "YOUR WIFI PASSWORD";
const char *mqtt_server = "YOUR MQTT HOST";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
void setup_wifi() {
delay(10);
// Connect to 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) {
String speed;
for (int i = 0; i < length; i++) {
speed += (char)payload[i];
}
// old way of drawing teh numbers on the screen
// tft.drawNumber(speed.toInt(), 100, 100, 7); // Draw the speed value
// new way of drawing the number using the OpenFontreader library
// doesnt work with my string "speed"
ofr.printf("70");
//ofr.printf(speed);
}
void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
if (client.connect("ESP32Client")) {
Serial.println("connected");
client.subscribe("Temp1");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
delay(5000);
}
}
}
void setup() {
Serial.begin(115200);
setup_wifi();
tft.begin();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
ofr.setDrawer(tft); // Link drawing object to tft instance (so font will
be rendered on TFT)
ofr.setFontColor(TFT_WHITE, TFT_BLUE);
ofr.setCursor(0, -80);
ofr.setFontSize(550);
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
// Load the font and check it can be read OK
if (ofr.loadFont(TTF_FONT, sizeof(TTF_FONT))) {
Serial.println("Initialise error");
return;
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
}
—
Reply to this email directly, view it on GitHub
<#60 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAF7SEOOQME6POWTUPX7EITYFD7RFAVCNFSM6AAAAAA7QSXGNKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TMMBXHA2DG>
.
You are receiving this because you are subscribed to this thread.Message
ID:
<witnessmenow/ESP32-Cheap-Yellow-Display/repo-discussions/60/comments/7607843
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
giving up on the OpenFonts, when it does work, it appends the value rather that updating the original display, eventually overwriting the whole screen |
Beta Was this translation helpful? Give feedback.
-
Just getting started with the CYD, is there something similar to mqtt dash for android? (i.e. something not only to display mqtt values but also to change/publish them). |
Beta Was this translation helpful? Give feedback.
-
I'd like to turn this thing into a wireless display for a Mqtt value, just one large 2 digit number...any decent examples out there to get started with?
Beta Was this translation helpful? Give feedback.
All reactions