433toMQTTto433 Bidirectional Arduino Gateway

Hi

With a rapid search on google I found that it is a known issue of 2.6.0 RCSwitch, which version do you have?

The 2.6.2 seems to have this issue resolved

If it is not working go back to the version I have 2.52:

1 Like

Sorry if I should have made a new thread. Hopefully my question extends this implementation.

@1technophile Thank you so much for developing and sharing this project. Thank you everyone else for paving the ground ahead of me.

Hereā€™s my question. I used @aelg305 and @Partybug 's config code

switch:
  platform: mqtt
  name: "Outlet #2"
  state_topic: "home/commands/433toMQTT"
  command_topic: "home/commands/MQTTto433"
  payload_on: "11163143"
  payload_off: "11163142"
  optimistic: true
  retain: true

This works! But how should I implement the other 4 RF outlets? A script? Or could I extend home/commands/ to some thing like home/commands/rf1/, home/commands/rf2/, etc.? How do the cool cats do this?

UPDATE: I figured it out. Itā€™s all about the dash ā€œ-ā€ in front of platform when you have multiple.

switch:
- platform: mqtt
  name: "Outlet #1 - Xmas Lights"
  state_topic: "home/commands/433toMQTT"
  command_topic: "home/commands/MQTTto433"
  payload_on: "11163151"
  payload_off: "11163150"
  optimistic: true
  retain: true

switch 2:
- platform: mqtt
  name: "Outlet #2 - Office Tester"
  state_topic: "home/commands/433toMQTT"
  command_topic: "home/commands/MQTTto433"
  payload_on: "11163143"
  payload_off: "11163142"
  optimistic: true
  retain: true

switch 3:
- platform: mqtt
  name: "Outlet #3 - Coop Heater"
  state_topic: "home/commands/433toMQTT"
  command_topic: "home/commands/MQTTto433"
  payload_on: "11163147"
  payload_off: "11163146"
  optimistic: true
  retain: true

switch 4:
- platform: mqtt
  name: "Outlet #4 - Sump Pump"
  state_topic: "home/commands/433toMQTT"
  command_topic: "home/commands/MQTTto433"
  payload_on: "11163139"
  payload_off: "11163138"
  optimistic: true
  retain: true

switch 5:
- platform: mqtt
  name: "Outlet #5 - NA"
  state_topic: "home/commands/433toMQTT"
  command_topic: "home/commands/MQTTto433"
  payload_on: "11163141"
  payload_off: "11163140"
  optimistic: true
  retain: true
2 Likes

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
http://www.banggood.com/fr/3400-Radio-Receiver-Module-433RF-Wireless-Transmitter-Module-p-970238.html
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

@1technophile,

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:
http://us.banggood.com/Wholesale-Warehouse-433MHZ-Wireless-PIR-Motion-Detector-for-Home-Alarm-Home-Security-wp-Usa-941723.html

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:
https://1technophile.blogspot.co.uk/2016/09/433tomqttto433-bidirectional-esp8266.html
and the code so I must be getting something wrong somewhere but it looks straight forward.

Any help appreciated.

Hello,

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.