433toMQTTto433 Bidirectional Arduino Gateway

Yes it’s all about the - , I think you can also declare only one switch: and then put your list of switch. No need to declare switch 1, switch 2, etc… one is enough.

1 Like

I would like to share my experience with everyone here after using this gateway for few weeks and hopefully to get some suggestions to improve it.

Before that, here is what I have in my setup.

  • 15 magnetic door/windows sensors (5 more on the way)
  • 11 PIR motion sensors
  • 1 door bell
  • 4 misc. sensors
  • 6 occupants who stay in the house most of the time.
  • The gateway is placed strategically in the middle of the house.
  • The furthest sensor from the gateway is around 15 meters with 1 or 2 walls in between.

I would say the success rate is around 90%. The other 10% is when certain automation failed to trigger like it suppose to. Even though the failure rate is only 10%, it is enough for every occupants not to have full confidence on its reliability. However, I am not saying the gateway is to blame for the failures. It could be the sensors signal not strong enough, low battery (very unlikely because they are all new sensors received few weeks ago), HA stability issue, MQTT broker issue, etc…

I am wondering how is the experience of other users. Do you have better success rate than mine or similar? What can be done to improve it?

Is there any correlation between failing sensor and distance to the gateway?
I also have a gateway setup but with much fewer sensor at the moment. It does it’s job and I surely doesn’t have 10% failure, especially on the switch, with which a failure would be pretty obvious.

The first thing to would be to check in the log after a failure to see if mqtt transported the message, if hass received it, or if maybe the gateway itself didn’t catch the rf signal.

Have you chosen some good RF receiver? The cheap one really make a poor job.

As said the lost can be at several point, regarding the gateway what can be done as an upgrade to increase range is to go with superheterodyne receiver and emitter
plus good antennas.

Some tests could enable you to point out where the issue is.

Cheers manage to import the code on to the esp8266 and when I open the serial monitor it connects to the wifi and the mqtt server. But when I press a button on my rf remote(one of these) I don’t seem to get anything appearing in the log. Have I set up something wrong the rx is in D1 and tx in D2

Rx to d1 and tx to d2 is correct, it is probably that rcswitch is not supporting the rf protocol if your remote control. Here is a list of tested compatible devices:

Is there a way to add it so they are supported?

So as to answer to your question I need to ask a question, do you have an arduino?
If you have you could download this library:

put it into the library folder of your IDE and open the example ShowReceivedCode.ino
Upload it, connect your receiver to pin D2, press your remote and see if there is something on your serial monitor.

If it is working we have a compatible library with your remote that need to be ported to esp8266


Thank you for sharing your valuable code. I was able to setup the 433Mhz Tx/Rx using your ESP8266 gateway code. Everything’s working fine except for a minor glitch. I have a PIR motion sensor setup in a room and I want to turn the light on in that room based on any movement. The ESP8266 receives the code from PIR sensor and sends it to HA and receives a response back with the right code to turn the light on. I can see the log saying that the code is being sent by ESP8266, but nothing happens. I see that this works once out of every ten to twelve attempts. I have a feeling that it could be because the ESP8266 is getting overloaded with messages from the PIR sensor and is unable to process them. Is there someway I can track this and add a delay?

I got my door/window sensor today and with a similar automation setup on HA, the lights in my living room turn on. I think it’s because the door sensor sends out the signal only once. Any help to get this working would be greatly appreciated. Thank you!

Hello Veeresh,

Some questions before giving you proposals:
-is your PIR sensor sending signals continuously when you are in the room or only every 5 seconds?
-without triggering the PIR, if you switch on and off the room light do you have 100% success?
-what is the distance between the gateway and the sensor/device?

Thank you for a quick reply. Responses to your questions:

The PIR sensor is sending signals every 5-7 seconds. Here is a link to the sensor I am using:

I think I got this from the other thread with a list of devices.

Yes, if I trigger the switch on and off manually using the HA dashboard, I do get 100% success.

I live in an apartment and the distance between the sensor/switch and the gateway is about 7m (max). Compared to the PIR sensor, my door sensor and the living room switch are farther away, but that’s working reliably.

I have the same PIR sensor as you, i setup a remote socket plug to switch ON a light when the PIR is triggered, I did 10 tests and got 100% switch ON (I’m using OpenHAB)

Here is some track to follow for you and that can help investigate:
-increase the number of RF sending by changing the parameter into the gateway code:
mySwitch.setRepeatTransmit(30); //increase transmit repeat to avoid lost of rf sendings
-put a delay into HA before firing the ON command like 5s to see if it is a problem of RF signal collisions, if it is working try to reduce it
-add the ON command directly at gateway level mySwitch.send(data, 24); when the code expected is received.

if your emitter is an FS1000A power it with more than 5V, like 9V or 12V

just for my information:
why would anyone like a PIR sensor that sends a signal every 5, 6 or 7 seconds?
or is that only if it detects motion? (i would hope so)

I’m clearly doing something wrong but when I follow the instructions from @1technophile on his site to setup the 433toMQTTto433 gateway I can’t get it to work and looking at the code and the test messages don’t match up for me.

When the NodeMCU boots up it’s supposed to say subscription OK to home/MQTTto433
But mine says Subscription OK to home/commands/#

If I try to publish a message to home/MQTTto433/ nothing happens, nohting on the console either.
If I publish a message to home/commands/MQTTto433 then it does look like it is sending:
Hey I got a callback Receiving data by MQTT home/commands/MQTTto433 1315156 Send received data by RF 433 1315156

I never receive anything though but not sure if there’s something wrong my end or something else wrong in the code. I’m confused because no one else has mentioned any discprepancies between the instructions at:
and the code so I must be getting something wrong somewhere but it looks straight forward.

Any help appreciated.


This is the good command, as the gateway subscribed to home/commands/# meaning all the subject below hom/commands it will receive the value coming from home/commands/MQTTto433 and send it by RF as said by the trace. please check your emitter circuit if you don’t receive something coming from the gateway when you see these traces.

I haven’t actually got an antenna plugged in either sender or receiver, but I have used these on a regular arduino and they worked over a few centimeters fine which is all I’m trying to do in my test.

When you say check your emitter circuit, I’m not sure there is much to check I am trying to send with the FS1000A which only has 3 pins. Which are connected to Data - D2, VCC - VIN, GND - G.
On the XY-MK-5V (Receiver) I have VCC - VIN, Data - D1, GND - G.

I have tried both data pins on the receiver.

I am powering the NodeMCU over the computers USB port, so I can view the COM port data.

Anything I’m missing or is it just the lack of the antenna?

@1technophile I started looking at something else for 30 minutes and looked at my serial monitor and it had received a 433Mhz signal. After some investigation I figured out it was home assistant sending a 433Mhz signal via an RM Pro to turn off a socket.

So the receiver works it must be the sender that isn’t, as it happens I only really wanted this as a receiver so I could pick up when my door bell, etc rings.

The amazing thing about this though is that the Rm Pro which sent the signal is about 50 feet away in the house, the 433toMQTTto433 gateway is my office in the garden. This was with no antenna in the receiver.

I will try to get to the bottom of why the sender isn’t working but happy that for my purposes it appears to work.

1 Like

Your wiring seems ok, if you want to have more power with the transmitter you can link its vcc to 9V or to a separate 5V power.

hello i have this problem;

try again in 5 seconds
Attempting MQTT connection…
failed, rc=
try again in 5 seconds

// Update these with values suitable for your network.
#define wifi_ssid “Casa”
#define wifi_password “96xxxxx”
#define mqtt_server “”
#define mqtt_user “xxx” // not compulsory if you set it uncomment line 127 and comment line 129
#define mqtt_password “xxx” // not compulsory if you set it uncomment line 127 and comment line 129

i change all values …how can see if my mqtt broker is running?

Use the one inegrated with home-assistant to begin. Its simpler like that. Dont forget to set your mqtt username and password.
You can also download an mqtt client and try to connect to your mqtt broker.