hello all,
i'm wokring on my home automation system. my question is.
is it possible to set a pwm output directly over lets say , openhab mqtt?.
only info i could find was over http. thats not what i want to use. i'm using espeasy r20.
so maybe i should get a later one? or should i dive deep in source code to make it possible?.
thanks in advance.
PWM Output over mqtt
Moderators: grovkillen, Stuntteam, TD-er
Re: PWM Output over mqtt
i guess i found the answer.
but i'm not sure.
i tried every way i could see how this should work:(i'm not a pro):
in case of openhab mqtt.
if message recieved the following case statement is run CPLUGIN_PROTOCOL_RECV.
this will split the topic in parts. so i guess in my case:
/woonkamer/pwm/16
/espname/cmd/pin, then payload is value.
after this it will call plugin.write(let this code run).
but then i see in _p001_switch.ino the folowing:
see arrows:
but i'm not sure.
i tried every way i could see how this should work:(i'm not a pro):
in case of openhab mqtt.
if message recieved the following case statement is run CPLUGIN_PROTOCOL_RECV.
this will split the topic in parts. so i guess in my case:
/woonkamer/pwm/16
/espname/cmd/pin, then payload is value.
after this it will call plugin.write(let this code run).
but then i see in _p001_switch.ino the folowing:
see arrows:
Code: Select all
case PLUGIN_WRITE:
{
String tmpString = string;
int argIndex = tmpString.indexOf(','); << ----- why this comma? is this only for http command?
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase("GPIO"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16) <<----- looks correct for gpio output
{
pinMode(event->Par1, OUTPUT); <<----- first parameter pin number
digitalWrite(event->Par1, event->Par2); <<----- same
if (printToWeb)
{
printWebString += F("GPIO ");
printWebString += event->Par1;
printWebString += F(" Set to ");
printWebString += event->Par2;
printWebString += F("<BR>");
}
}
}
if (tmpString.equalsIgnoreCase("PWM")) <<----- command pwm output
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 1023) <<<<<<<<<<--------------- should this be 0 - 16? or am i wrong?
{
pinMode(event->Par1, OUTPUT);
analogWrite(event->Par1, event->Par2); <<<<<<<-------- analogwrite first parameter is pin number second parameter value?
if (printToWeb)
{
[code/]
i once did get output out of my ledstrip true mqtt but i'm not able to replicate that. should i set some flag or something?
i really have no clue. tomorrow i will get further.
maybe someone can help ? or give me advice where to look for th answer?.
thanks guys, keep up the good work.
edit//
i did send value to:
/woonkamer/pwm/16- value
but nothing happens. o and i think i found a bug. sometimes when i'm in device setup i get following error in browser:
ERR_CONTENT_LENGTH_MISMATCH. ?? sometimes it works sometimes not. btw i'm using latest build (39).
i guess it works fine. i'm so stupid sometimes haha. my mqtt client was at fault ;S but i still think the analogwrite function should be different. because you can have 1023 outputs?
thanks
Re: PWM Output over mqtt
does it can be the same way to send analog value to a domoticz mqtt ?
Re: PWM Output over mqtt
No if you use domoticz it would be different.
In topic of domoticz is (sensor data to domoticz )
domoticz/in
Out topic is: (receive data in esp)
Domoticz/out
But in domoticz you use json. So its a whole other way of sending/receiving data. You should take a look inside _c002.ino to look for how it works. (Still in development)I think its not ready yet(i'm not one of the programmers).
Greetings
In topic of domoticz is (sensor data to domoticz )
domoticz/in
Out topic is: (receive data in esp)
Domoticz/out
But in domoticz you use json. So its a whole other way of sending/receiving data. You should take a look inside _c002.ino to look for how it works. (Still in development)I think its not ready yet(i'm not one of the programmers).
Greetings
Who is online
Users browsing this forum: Bing [Bot] and 1 guest