MQTT Device
Moderator: leecollings
-
- Posts: 3
- Joined: Friday 05 April 2019 21:05
- Target OS: -
- Domoticz version:
- Contact:
MQTT Device
Hi, I have successfully connected ESP32 running BME280 via MQTT to Domoticz. Added the device and in the logs the data is present however the latest information is not displayed on the dashboar device/ticket (like for the 433MHz devices). Any idea what magic is required for the values to be displayed? Gui doesn't allow too many things to be edited once it is created. (History correctly displays Temp and humidity, I am merely missing these from the device...ticket???)
-
- Posts: 601
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: MQTT Device
Hi,
How did you compose your JSON for Domoticz.
I have problems filling in svalue with a composition of float ; float ; int
How did you compose your JSON for Domoticz.
I have problems filling in svalue with a composition of float ; float ; int
Bugs bug me.
- FireWizard
- Posts: 1871
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: MQTT Device
Hi,
@DaniKojnok:
1. Are your devices visible under Setup and then Devices Tab?
2. If so, did you click the green arrow, so that it turns to blue?
@HvdW
Can you give more details of your problem?
Publish more info of what you have done so far and what the results were.
Regards.
@DaniKojnok:
1. Are your devices visible under Setup and then Devices Tab?
2. If so, did you click the green arrow, so that it turns to blue?
@HvdW
Can you give more details of your problem?
Publish more info of what you have done so far and what the results were.
Regards.
-
- Posts: 601
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: MQTT Device
Hi @FireWizzard ,
I am able to publish with fixed data, however importing live data from the sensor is one step beyond my programming skills.
Can you explain how in this topic.
I searched several forums, hackster, instructables and others and wasn't able to find simple coding.
https://www.domoticz.com/forum/viewtop ... t=27756 is what I have found up till now.
I am able to publish with fixed data, however importing live data from the sensor is one step beyond my programming skills.
Can you explain how in this topic.
I searched several forums, hackster, instructables and others and wasn't able to find simple coding.
https://www.domoticz.com/forum/viewtop ... t=27756 is what I have found up till now.
Bugs bug me.
- FireWizard
- Posts: 1871
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: MQTT Device
Hi HvdW
As I understood, you want to convert real data, received from an external source (weather station) to "something" that Domoticz understand.
Basically you have 2 options.
1. Writing a script in Lua, dzVents, Python or anything else. Or use anyone other script.
2. Use Node-Red and publish to Node-Red.
It might look a little bit overkill, but as soon as you have installed it, you can use it for many other tasks as there exist so many nodes.
If you know the program you can achieve result in a couple of minutes.
Is that a way to go for you?
Regards.
As I understood, you want to convert real data, received from an external source (weather station) to "something" that Domoticz understand.
Basically you have 2 options.
1. Writing a script in Lua, dzVents, Python or anything else. Or use anyone other script.
2. Use Node-Red and publish to Node-Red.
It might look a little bit overkill, but as soon as you have installed it, you can use it for many other tasks as there exist so many nodes.
If you know the program you can achieve result in a couple of minutes.
Is that a way to go for you?
Regards.
Last edited by FireWizard on Thursday 10 October 2019 19:44, edited 1 time in total.
-
- Posts: 601
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: MQTT Device
The challenge is to get that programming off the ground.
Your alternative is a very good one.
Your alternative is a very good one.
Bugs bug me.
-
- Posts: 4
- Joined: Sunday 05 May 2019 13:07
- Target OS: Linux
- Domoticz version: BETA
- Contact:
Re: MQTT Device
Not sure if this is something you are looking for, but this is what i am using for my wifi - mqtt - temp sensor

This is what i fiddled together and it is working prefect for me.
Code: Select all
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* SSID = "YOUR SSID";
const char* PSK = "YOUR PASSWORD";
const char* MQTT_BROKER = "192.168.100.99";
const int LM_35 = A0; // Analog PIN where the Temp Sensor Data pin connects
int input_val = 0; // Input Value Storage
float Temperature = 0; // Store final Temperature
long int myclock = 0; // Own clock in 50 mil steps
long int lastMillis = 0; // To compare last mil
char msg[128]; // The msg (mqtt should be max 128)
int tempidx = 32; // The IDX Device in Domoticz
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(MQTT_BROKER, 1883);
}
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(SSID);
WiFi.begin(SSID, PSK);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect() {
while (!client.connected()) {
Serial.print("Reconnecting...");
if (!client.connect("Node_Temperature")) {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" retrying in 5 seconds");
delay(1000);
}
}
}
void myclockupdate()
{
if(millis() - myclock > 50)
{
myclock = (myclock+50);
}
}
void publish_temperature()
{
if (myclock - lastMillis > 60000) { //only sending Temp updates in 60 seconds interval
input_val = analogRead(LM_35); // Reading analog input
Temperature = (3.0 * input_val * 100.0) / 1024; // Some calculation to convert analog value to temperature
lastMillis = myclock;
snprintf (msg, 128," {\"idx\":36,\"navalue\":0,\"svalue\":\"%f\"}", Temperature); // This is where the Domoticz mqtt magic is happening
Serial.print("Publish message: ");
Serial.println(msg); // Just for logging purpose
client.publish("domoticz/in", msg, true); // Final message what goes to Domoticz
}
}
void loop() {
myclockupdate();
if (!client.connected()) {
reconnect();
}
client.loop();
publish_temperature();
}
Re: MQTT Device
Using Python will lead to complexity. You can use the old models of C++FireWizard wrote: ↑Sunday 05 May 2019 14:18 Hi HvdW
As I understood, you want to convert real data, received from an external source (weather station) to "something" that Domoticz understand.
Basically you 2 options.
1. Writing a script in Lua, dzVents, Python or anything else. Or use anyone other script.
2. Use Node-Red and publish to Node-Red.
It might look a little bit overkill, but as soon as you have installed it, you can use it for many other tasks as there exist so many nodes.
If you know the program you can achieve result in a couple of minutes.
Is that a way to go for you?
Regards.
Who is online
Users browsing this forum: No registered users and 1 guest