User Tools

Site Tools


ha:sr201

This is an old revision of the document!


SR201 network controlled module

The SR-201 module is a widely available ethernet connected relay module. It is advertised as being “web controlled” in many outlets, but as I found out, it's not. I have written some python to allow it to be controlled via MQTT, this is available on Git Hub here:-https://github.com/andrewjstringer/sr201-mqtt/tree/dev. The link points to the dev branch which is working, but should probably get a code review before merging to master.

The purpose of this project was to override a bedroom light switch, so when it was “dark hours”, children cannot turn the bedroom light back on.

This code listens for messages from an MQTT topic and sends the appropriate command to the SR-201 module, it also reads the module status and writes it back to an MQTT topic. These are definable in a config file.

Constructed SR201 device

Factory Defaults

  Default IP Address:        192.168.1.100
  Port 6722:                 TCP control
  Port 6723:                 UDP control
  Port 5111:                 TCP Configuration

The device can be reset to these defaults by shorting the CLR pins on the header next to the RJ45 connector. CLR is adjacent to the +5V and P30 pins.

Beolw is a quick play about from BASH to test the relay with raw TCP. nc is Netcat, a really useful utility to communicate with raw TCP/IP, either to send packets as here, but also you can use it to set up a listener on a port. If you're stuck on windows you probably don't have this, yet another reason to upgrade to Linux.

$ printf "11:" | nc 192.168.1.91 6722
10000000
$ printf "12:" | nc 192.168.1.91 6722
11000000
$ printf "02:" | nc 192.168.1.91 6722
11000000
$

This page has been accessed for:-
Today: 2
Yesterday: 1
Until now: 709

ha/sr201.1749852173.txt.gz · Last modified: by andrew

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki