mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
Great work and thank you for taking the time to support these products. I've now added the link for your github page to the first post of this thread and the RGBW thread.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.
-
- Posts: 38
- Joined: Thu Dec 31, 2020 1:22 pm
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
Hi Andrew
I'm glad I read through this thread and found these new features in the library. For me this is a much more convenient way of turning the relays on and off.
Depending on how I chose to code things the less than one second timer may also be useful. I am using them to control model railway points. These require a short pulse of power to throw them. 100ms should do nicely.
Have you considered adding these features to the Reference Guide for these modules. Or adding an Example sketch to the library?
Cheers
Chris
I'm glad I read through this thread and found these new features in the library. For me this is a much more convenient way of turning the relays on and off.
Depending on how I chose to code things the less than one second timer may also be useful. I am using them to control model railway points. These require a short pulse of power to throw them. 100ms should do nicely.
Have you considered adding these features to the Reference Guide for these modules. Or adding an Example sketch to the library?
Cheers
Chris
andrew wrote: ↑Thu Nov 28, 2024 5:04 pmPun intended?That would be perfect, thanks for the distillation!
So.....
I’ve had time to review the firmware and have now added the features discussed. Since the existing registers couldn't support the changes, I’ve introduced 6 new registers:
Register 19 (Relay On):
- Writing a value between 0 and 3 to this register turns on the corresponding relay.
- If the relay’s timer is already running, writing to this register will restart the timer.
Register 20 (Relay Off):
- Writing a value between 0 and 3 to this register turns off the corresponding relay.
- If the relay’s timer is running, writing to this register will cancel the timer and immediately turn off the relay.
Register 21 (Relay 0 Timer Resolution):
- Writing 0 sets the timer resolution for Relay 0 to 1 second (default).
- Writing 1 sets the resolution to 100ms.
Register 22 (Relay 1 Timer Resolution):
- Writing 0 sets the timer resolution for Relay 1 to 1 second (default).
- Writing 1 sets the resolution to 100ms.
Register 23 (Relay 2 Timer Resolution):
- Writing 0 sets the timer resolution for Relay 2 to 1 second (default).
- Writing 1 sets the resolution to 100ms.
Register 24 (Relay 3 Timer Resolution):
- Writing 0 sets the timer resolution for Relay 3 to 1 second (default).
- Writing 1 sets the resolution to 100ms.
Any mLink relay modules purchased after today will include this version of firmware (v1.01).
---
The upcoming version of the mLink library (v2.2.0) will include macros to use these features:
mLink.RLY_ON(add, index) //Turns the specified relay ON.
mLink.RLY_OFF(add, index) //Turns the specified relay OFF.
mLink.RLY0_TIMER_RES(add, res) //Sets the timer resolution for Relay 0.
mLink.RLY1_TIMER_RES(add, res) //Sets the timer resolution for Relay 1.
mLink.RLY2_TIMER_RES(add, res) // Sets the timer resolution for Relay 2.
mLink.RLY3_TIMER_RES(add, res) // Sets the timer resolution for Relay 3.
- Parameters:
- add: I2C address of the module.
- index: Relay index (0 to 3).
- res: Timer resolution (0 = 1 second (default), 1 = 100ms).
---
I need to add a new servo controller to the library before I upload the updated version (V2.2.0) so I’m unsure when it will be available for download. However, I’m aiming for sometime next week or failing that, the following week.
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
Hi Chris, yep, it’s on the list but thanks for reminding me. Just got a new sensor module to get out of the way first. The currently uploaded library does support these new features though so the new commands as quoted in your post will work.Have you considered adding these features to the Reference Guide for these modules? Or adding an Example sketch to the library?
I must say that at the time of creating the original module it did not occur to me that a sub 1 second timer would be useful but I’m clearly wrong! Anyway thanks for the feedback on this.Depending on how I chose to code things the less than one second timer may also be useful. I am using them to control model railway points. These require a short pulse of power to throw them. 100ms should do nicely.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
I'm glad this stuff is useful to others and it's not just my weird requirements
My testing has gone well and everything works as expected! Thanks.

My testing has gone well and everything works as expected! Thanks.
-
- Posts: 38
- Joined: Thu Dec 31, 2020 1:22 pm
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
Somewhat frustrated that I purchased one of my relay models in mid November, just prior to this firmware update. I've found it much easier to code with the new features.
-
- Posts: 4
- Joined: Wed Apr 23, 2025 9:41 am
Re: 2ch (HCMODU0183) Parallel Relay Modules
I have a couple of the 2ch mlink relay modules and they where both working fine. I use them to switch the cutter motors in my ESP8266 robotic lawn mowers. They are an excellent fit for this because unlike directly connected relays they don't flicker when the device is started or restarted. They are driven by simple Micro-Python code and both relays have been working fine since I purchased them from Hobby Components in September 2024. However, one has developed a fault. Each relay can still be turned on, but neither will turn off without killing the power. It is definitely a problem with the module because I swapped my two over, and the other one is working fine. Has anyone come across any similar issues.
Regards
Regards
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
Each relay can still be turned on, but neither will turn off without killing the power. It is definitely a problem with the module because I swapped my two over, and the other one is working fine. Has anyone come across any similar issues.
I can’t explain why you would be able to turn the relay on via software but not off. That’s a weird issue. But a couple of things to check:
Firstly, if you have a multimeter can you check the 5V supply to the relay, just in case it's a bit low. It could be that one module is more tolerant.
Secondly, if it’s also convenient to do, do the relays switch ok if you control them from the header pins?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.
Re: 2ch (HCMODU0183) Parallel Relay Modules
i have the similar issue, i can turn on the relay but have issues trying to turn off:proxymowdev wrote: ↑Wed Apr 23, 2025 10:10 amI have a couple of the 2ch mlink relay modules and they where both working fine. I use them to switch the cutter motors in my ESP8266 robotic lawn mowers. They are an excellent fit for this because unlike directly connected relays they don't flicker when the device is started or restarted. They are driven by simple Micro-Python code and both relays have been working fine since I purchased them from Hobby Components in September 2024. However, one has developed a fault. Each relay can still be turned on, but neither will turn off without killing the power. It is definitely a problem with the module because I swapped my two over, and the other one is working fine. Has anyone come across any similar issues.
Regards
*using i2c via Rpi Gpio
script:
#!/bin/sh
from mLink import mLink # Import the mLink module
ml = mLink.mLink(1) # Create an instance using the Pis I2C port 1
ml.Relay0_off(0x52) # Turns relay 0 off
When script is run:
mdm1981@raspberrypi:~/klipper/scripts $ python mLink_Relay0_off.sh
Traceback (most recent call last):
File "/home/mdm1981/klipper/scripts/mLink_Relay0_off.sh", line 6, in <module>
mLink.Relay0_off(0x52) # Turns relay 0 off
AttributeError: module 'mLink.mLink' has no attribute 'Relay0_off'
Script used to turn on relay is same(with on/off variable changed) and works fine.
relay tested on GPIO works fine
any help would be much appreciated.
Mark
Last edited by Mark M on Mon May 05, 2025 7:09 am, edited 2 times in total.
-
- Posts: 4
- Joined: Wed Apr 23, 2025 9:41 am
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
I have checked the supply and it is healthy, and I can reproduce the same results using the header pins. I am curious about the reset/clear function pins. I remember reading about it somewhere, but can't find the reference now. It implies there is some configuration in nv memory that can be reset? Is this worth trying?Firstly, if you have a multimeter can you check the 5V supply to the relay, just in case it's a bit low. It could be that one module is more tolerant.
Secondly, if it’s also convenient to do, do the relays switch ok if you control them from the header pins?
Re: mLink 1ch (HCMODU00182), 2ch (HCMODU0183), And 4ch (HCMODU0184) I2C / Parallel Relay Modules
@Mark M
The error message seems to suggest a problem with the script. I don’t know why it is complaining about Relay1_off when your script is using Relay0_off. Maybe you have a reference to Relay1_off in your script somewhere. However i do see a problem:
You're creating an instance of the mLink library and assigning it to the name ‘ml’.
However in the error message i can see it is referencing it as ‘mlink’.
The above line needs to be:
If you run the example script in the first post of this thread does it work ok?
i have the similar issue, i can turn on the relay but have issues trying to turn off:
*using i2c via Rpi Gpio
script:
#!/bin/sh
from mLink import mLink # Import the mLink module
ml = mLink.mLink(1) # Create an instance using the Pis I2C port 1
ml.Relay0_off(0x52) # Turns relay 0 off
When script is run:
mdm1981@raspberrypi:~/klipper/scripts $ python mLink_Relay0_off.sh
Traceback (most recent call last):
File "/home/mdm1981/klipper/scripts/mLink_Relay0_off.sh", line 6, in <module>
mLink.Relay0_off(0x52) # Turns relay 0 off
AttributeError: module 'mLink.mLink' has no attribute 'Relay0_off'
Script used to turn on relay is same(with on/off variable changed) and works fine.
The error message seems to suggest a problem with the script. I don’t know why it is complaining about Relay1_off when your script is using Relay0_off. Maybe you have a reference to Relay1_off in your script somewhere. However i do see a problem:
You're creating an instance of the mLink library and assigning it to the name ‘ml’.
- ml = mLink.mLink(1) # Create an instance using the Pis I2C port 1
However in the error message i can see it is referencing it as ‘mlink’.
- mLink.Relay0_off(0x52) # Turns relay 0 off
The above line needs to be:
- ml.Relay0_off(0x52) # Turns relay 0 off
If you run the example script in the first post of this thread does it work ok?
- from mLink import mLink # Import the mLink module
- import time
- ml = mLink.mLink(1) # Create an instance of the module
- I2C_ADD = 0x52 # Default I2C address is 0x52
- while 1:
- ml.Relay0_On(I2C_ADD) # Turn relay 0 on
- time.sleep(1)
- ml.Relay0_Off(I2C_ADD) # Trun relay 0 off
- time.sleep(1)
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.