Rf component door sensor 433 Mhz

Does somebody have a solution for receiving the 433 Mhz codes??

https://nl.aliexpress.com/item/Hot-Sale-New-White-433-Mhz-Sensors-Alarms-Contact-Wireless-Door-Window-Magnet-Entry-Detector-Sensor/32505569785.html?spm=2114.13010608.0.92.dvBUIe

I want to put on a light when a door opens. Those sensors do sent a 433 Mhz signal.

You can use Rfxtrx: https://home-assistant.io/components/rfxtrx/

Thanks Daniel!. Than i do need a hub? or serial device? I hoped there would be a solution like :

But than receive, instead off sent!

You can use pilight on a rasperry pi with a 433 MHz receiver. Unfortunately you will have to implement the door switch protocol in pilight since it is most likely not supported already. This is relatively easy since pilight gives you a nice debug tool to spy on the receivd data.

Hi,
I was also considering to use the 433Mhz existing sensors but the problem is that the RFXCOM receiver is very expensive.
Then, after discarding this solution, I was considering to use some existing 433Mhz sensors that already have a RF receiver (cheap Kits) and attach the receiver to a cheap ESP8266 module using MySensors ESP8266 Gateway to connect the sensor with HA. That would work pretty well and it is easy to implement.
You might want to use directly the ESP8266 as a sensor but you might need a power supply nearby.

In my case, I decided to use the ESP8266 with a PIR.

Regards,
Alfredo.

hi Alfredo,

You went through the same thoughts as I had. In my opinion the power source is the bottleneck… What i thought is to use an Arduino with a cheap 433 MHz receiver an communicate via usb to the raspberry Pi. I could not find an example for correct comunnicating with the rasp pi.

Another solution might be the ESP-14. and do the scan over the ATM processor and switch on the ESP-wifi when a signal is received, it saves a lot of power. My knowledge of programming is not enough…but there will be/come solutions like this…hopefully.

Grtz,

I have been using cheap RF Receivers $8 connected to an ESP8266 and then publishing to MQTT Server on HASS it works very well as long as you get the right receiver and connect an antenna. Not external power needed besides the power required for the ESP.

1 Like

Here is an example ESP8266 Arduino Code:
Note that this example also flashes a light on a house map that shows which sensor sent data (used for PIR

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <RCSwitch.h>

// Initialize RF
RCSwitch mySwitch = RCSwitch();

// These must be unique:
const char* mqtt_client = "RF1";

// Wifi Connection details
const char* ssid = "xxxxxxxxxx";
const char* password = "xxxxxxxxxxxxx";

// MQTT Server address
const char* mqtt_server = "192.168.0.xxx";


// Initialize MQTT
WiFiClient espClient;
PubSubClient client(espClient);


void setup() {
  Serial.begin(9600);
  pinMode(16, OUTPUT);  
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(1, OUTPUT);

  mySwitch.enableReceive(2);  // Receive on GPIO 2
  setup_wifi();
  client.setServer(mqtt_server, 1883);
}


// Connect to Wifi
void setup_wifi() {
  delay(1);
  // connect to a WiFi network

  WiFi.begin(ssid, password);
  Serial.print("[*] Connecting to Access Point: ");
  Serial.println(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("[*] WiFi connected");
  Serial.println("[* ]IP address: ");
  Serial.println(WiFi.localIP());
}


// Reconnect to MQTT Server
void reconnect() {
  // Loop until we're reconnected
  int state;
  while (!client.connected()) {
    Serial.print("[*] Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect(mqtt_client)) {
      mqtt_state();
    } else {
      mqtt_state();
      Serial.println("[*] try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}


// Main functions
void loop() {
  if (mySwitch.available()) {
    char str[32];
    Serial.println("-------------------");
    Serial.println("[*] Received RF Message from:");
    dtostrf(mySwitch.getReceivedValue(), 0, 1, str);
    Serial.println(str);
    mySwitch.resetAvailable();
    // Send data to MQTT
    if (!client.connected()) {
      reconnect();
    }
    //client.loop();

if (strcmp (str,"9114120.0") == 0) {
beep_led(16);
}
if (strcmp (str,"9970184.0") == 0) {
beep_led(5);
}
if (strcmp (str,"9021960.0") == 0) {
beep_led(4);
}
if (strcmp (str,"2382428.0") == 0) {
beep_led(14);
}
if (strcmp (str,"15848796.0") == 0) {
beep_led(12);
}
if (strcmp (str,"15848796.0") == 0) {
beep_led(13);
}
if (strcmp (str,"39560110.0") == 0) {
beep_led(3);
}
if (strcmp (str,"3952060.0") == 0) {
beep_led(1);
}
    client.publish("/rf", str);
    delay(5000);
  }
}


// Display LEDs
void beep_led(int P){
  Serial.println("[*] Beep LED");
  digitalWrite(P, HIGH);
  delay(2000);
  digitalWrite(P, LOW);
}


// GET MQTT State
void mqtt_state() {
    int state;
    state = client.state();
    Serial.println();
  if (state == -4) {
    Serial.print("The server didn't respond within the keepalive time");
  }
  if (state == -3) {
    Serial.print("The network connection was broken");
  }
  if (state == -2) {
    Serial.print("The network connection failed");
  }
  if (state == -1) {
    Serial.print("The client is disconnected cleanly");
  }
  if (state == 0) {
    Serial.print("The cient is connected");
  }
  if (state == 1) {
    Serial.print("The server doesn't support the requested version of MQTT");
  }
  if (state == 2) {
    Serial.print("The server rejected the client identifier");
  }
  if (state == 3) {
    Serial.print("The server was unable to accept the connection");
  }
  if (state == 4) {
    Serial.print("The username/password were rejected");
  }
  if (state == 5) {
    Serial.print("The client was not authorized to connect");
  }
  Serial.println();
}

In Home Assistant you would setup sensors as follows:

sensor:
  platform: mqtt
  state_topic: "/pir/Kitchen PIR"
  name: "Kitchen"
  qos: 0

You could then use automation to respond to these sensors like trigger lights or an alarm

Thanks Thaijames, i’m going to try this one!!

A bit late, but its working now Thaijames… Next step is to create automations when a door sensor is activated, like for instance switch a security cam to recording, and switch on the light on the same moment.

Hello Ron,
I just tried to load the sample code above on my esp8266 but all I see is garbage in the arduino ide serial monitor, i’ve switched the speed to 9600 and other speeds but I still get weird characters, which board did you use in the Arduino IDE to make yours work?

Hello, the garbage can be 2 things, 1 not a proper digital signal? (test is with a uint() value) or indeed wrong board, i used the esp8266 in the nodemcu 1.0 mode, 9600 baud

1 Like