Door sensor with Tasmota + reed switch, free over MQTT
Know from your phone whether the cold-room door or the warehouse gate was left open, with an email alert. Free on EzGYM.
The Tasmota + reed switch reads a magnetic sensor (reed switch) on the door and publishes over MQTT when it opens and closes. EzGYM gives you the server for free, with a username and password for each device.
You set how many minutes it can stay open: if the cold-room door is still open after 5 minutes, we email you, and again when it closes.
Depending on how the sensor is wired, the device may report “on” with the door closed. The sensor page has an “Invert” switch so it says Open and Closed correctly.
How to set it up
- 1 Create your free EzGYM account, go to Sensors and add a “Door or gate”.
- 2 Write down the server, username, password and topic the app gives you.
- 3 In Tasmota, set the magnetic sensor pin as Switch1 (Configuration › Configure Module).
- 4 In the console paste the line below with your data (SwitchMode1 16 keeps the contact from switching the relay).
- 5 Open the door and check that EzGYM says Open; if it says Closed, turn on Invert in the sensor page.
Backlog MqttHost devices.ezdis.net; MqttPort 1883; MqttUser sn4k2p9x7q1m; MqttPassword TheSensorPassword; FullTopic s/sn4k2p9x7q1m/%prefix%/; TelePeriod 60; SwitchMode1 16
In this example, sn4k2p9x7q1m is the sensor username and s/sn4k2p9x7q1m its topic: replace them, and the password, with the ones the app gave you when you added the sensor. They are not your app login.
Frequently asked questions
Which door sensor do I use?
Any two-wire magnetic sensor (reed switch), like the ones used in alarms. It goes between an input of the device and GND.
Which username and password do I enter in the Tasmota + reed switch?
The sensor ones, not your account ones: when you add the door in Sensors, EzGYM shows its username (it starts with “sn”) and its password. The password is shown only once.
Does it warn me if the device disconnects?
Yes, if you turn it on in the sensor page. It works well with ESPHome and Tasmota from this guide, because they send a signal every minute even if the door does not move.
How much does it cost?
Nothing: the broker and the email alerts are free, up to 30 sensors per account.
More guides
- Shelly H&T
- Shelly Plus 1 + Add-on DS18B20
- ESP32 + ESPHome + DS18B20
- ESP32 + ESPHome + DHT22 / SHT31
- Tasmota + DS18B20
- Shelly Plus Plug S
- Shelly Plus 1PM
- Shelly PM Mini Gen3
- Shelly Pro 3EM
- Sonoff POW + Tasmota
- ESP32 + ESPHome + PZEM-004T
- Shelly Plus Uni + reed switch
- ESP32 + ESPHome + reed switch
- Butcher shops
- Ice cream shops
- Pharmacies
- Free MQTT broker vs HiveMQ
- Cold chain temperature log sheet