Continuing my work on MQTT gateway with cheap component you can find below a tutorial to build a bidirectional one with IR transmitter, IR receiver, 433mhz emitter and 433mhz receiver.
You can integrate it with HA by using MQTT, more information on this topic
This is amazing. Well done!
Iâve been looking for ways to integrate IR and 433 into HASS. Quick question if you donât mind, is it possible to state pulse length when transmitting 433, or the frequency burst of IR?
There is several ways to handle this:
-the best for me should have a sensor stop included into the projector screen directly, but as you are asking for this I suppose it is not the case
-a second way could be to handle it into HA, by setting up a timer when the switch pass to ON, and at the end of the timer pass the switch to OFF, as Iâm not an HA expert I prefer to let the other answer
-a third way but the worst I think would be to handle it into the gateway source code by adding a condition and a timer when an ON signal is received
Only the first one is working with one single command at home automation level
Hi, thanks for doing this. I built this following your guide and is working very well at receiving commands and sending messages to HASS via MQTT but I have a problem which may be to do with pulse length and frequency burst but Iâm not 100% certain. I originally follwed Bruh automations guide https://www.youtube.com/watch?v=5UUazFbK-Hg&t=132s to run this on the pi itself but changed over to your MQTT solution and I canât get the plugs to switch on. I know its all working fine as I also have my wireless rf doorbell connected and this works via the mosquitto_pub command, the doorbell rings but the switches do not switch at all - do you have any ideas? The only things I can think of is the pulse length all the switches were at 186 and the doorbell is 321 using Bens guide.
Hi 1technophile it was the pulse length. I added mySwitch.setPulseLength(186);
to the line above mySwitch.send(data, 24); in your code and its working great and the doorbell works too. Loving your work, thanks!
Iâm using just the IR parts (have RF running nice on pi). I have captured all the codes for remotes but Iâm not sure on my next step.
I have a mosquitto broker running fine but not sure about topics. I want to take these codes and have them in HA as switches and have them controllable through my Echo. Is this possible?
I already have 5 rf sockets working with Hue emulation, will I be able to to the same with mqtt commands as switches?
Once you captured your code you can try to emit them by publishing the following MQTT topic into mosquitto: mosquitto_pub -t home/commands/sendNEC -m 99999999
99999999 = the captured code value
If it is working the next step is the HA integration.
Here are some example that you have to adapt to the IR topic
while already having a MQTT broker running on HA (simple DHT22 on a nodemcu dev board), I liked your solution and tried it on a similar module as the geekcreit (doit.am with 12F) to get 433 MHz sockets into HA.
The RF RX/Tx modules are standard ones: MX-RM-5V (MX-05V)/FS1000A, but I couldnât get it to work.
When I publish a command â1315156â on topic âhome/commands/rfâ through MQTT Spy, I get a callback (reproducable).
Do you have any idea what I might be doing wrong here?
.
WiFi connected
client mqtt not connected, trying to connect
Attempting MQTT connectionâŚ
connected
subscription OK to
home/commands/#
Hey I got a callback
Is it a nodemcu board? If yes could you indicate me the version? I had a similar bug with 0.9 version of nodemcu.
Maybe you have a link that refer your board.
Please check also that you are running the latest library versions.
I just checked back at the order (Oct-2016), itâs the geekcreit as well:
It says âESP12E DEVKIT V2â on the back but has an 12F already installed.
The nodemcu FW is from today:
NodeMCU custom build by frightanic.com
branch: dev
commit: 7c9fdef77a89be76d4dfc1a15c4c94ad17a34f7c
SSL: false
modules: dht,file,gpio,mqtt,net,node,rfswitch,tmr,uart,wifi
build built on: 2016-12-25 20:41
powered by Lua 5.1.4 on SDK 2.0.0(656edbf)
RCSwitch.h - 2.6.0 was installed and didnât update yesterday, so I removed it to make sure 2.6.2 is used and compiled/uploaded the ino again (on IDE 1.6.12), same result (callback) after a submitted rf command via mqtt.
What is the exact requirement of the Nodemcu 1.0 board? How can i obtain the version (I thought itâs a 1.0 but I donât know how to check it)?
I think we have the same board, this doesnât seem to be a board compatibility issue, i ordered it also from banggood.
Some other questions:
-did you used the same pins as described
-could you add some trace to the code after the âhey i got a callbackâ to see exactly where it stop.
Pins are exactly the same used.
I also connected an IR Rx to check the IR-to-MQTT reception, beside the garbage codes posted, this works as expected.
Back to the traces, I added the following:
// Callback function, when the gateway receive an MQTT value on the topics subscribed this function is called
void callback(char* topic, byte* payload, unsigned int length) {
// In order to republish this payload, a copy must be made
// as the orignal payload buffer will be overwritten whilst
// constructing the PUBLISH packet.
trc("Hey I got a callback ");
// Allocate the correct amount of memory for the payload copy
byte* p = (byte*)malloc(length);
trc("malloc");
// Copy the payload to the new buffer
memcpy(p,payload,length);
trc("memcpy");
// Conversion to a printable string
p[length] = '\0';
trc("conv");
String callbackstring = String((char *) p);
String topicNameRec = String((char*) topic);
//launch the function to treat received data
receivingMQTT(topicNameRec,callbackstring);
// Free the memory
free(p);
}
Could you try:
-to add this piece of code before p[length] = â\0â; trc(String(length));
-to put a value of signal shorter like 99, or 6666
-try with mosquitto instead of MQTT Spy
hello, the board from banggood with the link provided by prefectionist is working, nevertheless as it is written on the spec esp 12E and in reality it is a 12F it is difficult to be sure that you will receive the same as us.
Message payloads of â99â or â6666â produce the same result, just the string length changes to 2 and 4.
The only âcustomâ setup in my mosquitto broker is the âallow_anonymous falseâ along with a password file.
I am running out of ideas what might be so specific to my setup.
I also changed the FS1000A with the second one I ordered, same result.