mLink RGBW LED Controller Module (HCMODU0185)

mLink serial I2C modules
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

mLink RGBW LED Controller Module (HCMODU0185)

Post by admin » Fri Oct 15, 2021 10:19 am

Image


The mLink RGBW LED controller is a serial I2C module designed to allow a microcontroller such as an Arduino to control common types of RGB (red-green-blue) and RGBW (red-green-blue-white) LED light strips. The module has screw terminals for connecting the light strips power supply and its +Ve, -red, -green, -blue, and optionally -white connections. It is capable of controlling 5V, 12V, & 24V LED strips that require a +Ve supply with -ve RGB(W) control inputs at up to a total of 2A per channel.

When connected to a microcontrollers I2C interface each LED output can be controlled independently with up two 256 different levels of brightness allowing for a combined RGB colour palette of over 16 million colours. Additionally, either predefined or user defined RGB colour cycling modes can be selected which can run independently of the microcontroller.


For Arduino users you can use the mLink library (see below for library and examples) to control any type of mLink module. Only one single instance of the library is needed to control multiple types of mLink modules resulting in very little resources overhead and therefore making it great for Arduinos with small amounts of memory and pin counts.

For Raspberry Pi users we have a Python module which can be installed via pip or downloaded and installed directly from our forum. Please see the mLink Python forum thread for requirements and download link here: viewtopic.php?f=131&t=3062&p=8592#p8592



Module specifications:
Module code: 					HCMODU0185
Supply Voltage (VDD): 			3V to 5.5V
Module current consumption:		7mA
Interfaces:					I2C, LED power in (+ & -), - red driver (R), -green driver (G), - blue driver (B), - white/aux driver (A)
I2C Interface speed: 				400kbits/s (fast mode)
I2C default address (HEX): 		0h53
LED voltage (max):				28V DC
LED current (max):				6A DC / 2A per RGBW output
Maximum number of modules: 		5 with pullups fitted, 112 with pullups removed*
Module dimensions (inc headers):	47.5mm x 40.5mm x 14mm


*Note the maximum number of connected modules will depend on cable lengths and power requirements of each module. Do not exceed 5 mLink modules connected in series with all fitted to all modules.


Image


Arduino Connection Example:

When used with microcontollers such as Arduino the mLink relay modules can be controlled via a serial I2C interface.

Image

Image


Because the modules use an I2C interface this also means multiple modules can controlled from a single Arduinos I2C interface simply by daisy-chaining them together. Note to control multiple mLink modules of the same type requires changing the default I2C address of the additional modules. See mLink Library Quick Start Guide for how to do this.


Image




Setting A Colour Example

Arduino RGB(W) Colour example:

This sketch demonstrates how to control the brightness of the individual red, green, blue, and white LEDs on an RGB/RGBW LED strip. The sketch will step through each colour in sequence.

  1. #include "mLink.h"                                      // Include the library
  2.  
  3. mLink mLink;                                            // Create an instance of the library
  4.  
  5. #define I2C_ADD 0x53                                    // Default I2C address
  6.  
  7.  
  8. void setup()
  9. {
  10.   mLink.init();                                         // Initialise the library
  11.  
  12.   mLink.write(I2C_ADD, RGBW_BRIGHTNESS, 255);           // Set brightness to maximum
  13. }
  14.  
  15.  
  16. void loop()
  17. {
  18.   mLink.write(I2C_ADD, RGBW_R_LEVEL, 255);              // Turn just the red LEDs on
  19.   mLink.write(I2C_ADD, RGBW_G_LEVEL, 0);
  20.   mLink.write(I2C_ADD, RGBW_B_LEVEL, 0);
  21.   mLink.write(I2C_ADD, RGBW_W_LEVEL, 0);
  22.  
  23.   delay(1000);
  24.  
  25.   mLink.write(I2C_ADD, RGBW_R_LEVEL, 0);                // Turn just the green LEDs on
  26.   mLink.write(I2C_ADD, RGBW_G_LEVEL, 255);
  27.   mLink.write(I2C_ADD, RGBW_B_LEVEL, 0);
  28.   mLink.write(I2C_ADD, RGBW_W_LEVEL, 0);
  29.  
  30.   delay(1000);
  31.  
  32.   mLink.write(I2C_ADD, RGBW_R_LEVEL, 0);                // Turn just the blue LEDs on
  33.   mLink.write(I2C_ADD, RGBW_G_LEVEL, 0);
  34.   mLink.write(I2C_ADD, RGBW_B_LEVEL, 255);
  35.   mLink.write(I2C_ADD, RGBW_W_LEVEL, 0);
  36.  
  37.   delay(1000);
  38.  
  39.   mLink.write(I2C_ADD, RGBW_R_LEVEL, 0);                // Turn just the white LEDs on
  40.   mLink.write(I2C_ADD, RGBW_G_LEVEL, 0);
  41.   mLink.write(I2C_ADD, RGBW_B_LEVEL, 0);
  42.   mLink.write(I2C_ADD, RGBW_W_LEVEL, 255);
  43.  
  44.   delay(1000);
  45. }

Predefined Cycle Mode Example

Selecting One Of The Predefined Cycle Modes Example:

This sketch demonstrates how to put the module into one of the pre-defined patterns. The sketch will constantly step through each pattern allowing the pattern to run for 20 seconds before moving onto the next.

  1. #include "mLink.h"                                      // Include the library
  2.  
  3. mLink mLink;                                            // Create an instance of the library
  4.  
  5. #define I2C_ADD 0x53                                    // Default I2C address
  6.  
  7.  
  8. void setup()
  9. {
  10.   mLink.init();                                         // Initialise the library
  11.  
  12.   Serial.begin(9600);
  13.  
  14.   mLink.write(I2C_ADD, RGBW_BRIGHTNESS, 255);           // Set brightness to maximum
  15. }
  16.  
  17.  
  18. void loop()
  19. {
  20.   Serial.println("FAST RED-GREEN-BLUE CYCLE");
  21.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_FAST_RGB_COLOUR_CYCLE);
  22.   delay(20000);
  23.  
  24.   Serial.println("MEDIUM RED-GREEN-BLUE CYCLE");
  25.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_MED_RGB_COLOUR_CYCLE);
  26.   delay(20000);
  27.  
  28.   Serial.println("SLOW RED-GREEN-BLUE CYCLE");
  29.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_SLOW_RGB_COLOUR_CYCLE);
  30.   delay(20000);
  31.  
  32.   Serial.println("FAST RED-GREEN CYCLE");
  33.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_FAST_RG_CYCLE);
  34.   delay(20000);
  35.  
  36.   Serial.println("INTERMEDIATE RED PULSE ALARM");
  37.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_ALARM_INTER_PULSE);
  38.   delay(20000);
  39.  
  40.   Serial.println("CONSTANT RED PULSE ALARM");
  41.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_ALARM_CONT_PULSE);
  42.   delay(20000);
  43.  
  44.   Serial.println("CONSTANT RED-GREEN-BLUE PULE");
  45.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_RGB_CONT_PULSE);
  46.   delay(20000);
  47.  
  48.   Serial.println("FLAME EFFECT");
  49.   mLink.write(I2C_ADD, RGBW_LOAD_CYCLE, RGBW_CYCLE_FLAME);
  50.   delay(20000);
  51. }
  52.  

User pattern mode

Uploading a user defined pattern:

This sketch demonstrates how to load a user defined pattern into the modules pattern buffer. The sketch will load 3 colours (red, green, & blue) into the buffer and then tells the module to make 255 between each transition with each step taking 10ms.

  1. #include "mLink.h"                                      // Include the library
  2.  
  3. mLink mLink;                                            // Create an instance of the library
  4.  
  5. #define I2C_ADD 0x53                                    // Default I2C address
  6.  
  7.  
  8. // Create an array with 3 colours (maximum is 8) to load into the pattern buffer
  9. byte colours[][3] = {{255,0,0}, // Red
  10.                      {0,255,0}, // Green
  11.                      {0,0,255}  // Blue
  12.                      };
  13.  
  14.  
  15. void setup()
  16. {
  17.   mLink.init();                                         // Initialise the library
  18.  
  19.  
  20.   mLink.write(I2C_ADD, RGBW_CYCLE(colours));            // Load the colours into the buffer
  21.  
  22.   mLink.write(I2C_ADD, RGBW_BRIGHTNESS, 255);           // Set brightness to maximum
  23.   mLink.write(I2C_ADD, RGBW_CYCLE_COLOURS, 3);          // There are 3 colors to cycle though
  24.   mLink.write(I2C_ADD, RGBW_CYCLE_STEPS, 255);          // Make 255 steps between each colour
  25.   mLink.writeInt(I2C_ADD, RGBW_CYCLE_STEP_SPEED, 10);   // Wait 10ms between each step
  26.  
  27.  
  28.   // Uncomment the following to save the above pattern into the module non-volatile memory
  29.   //mLink.write(I2C_ADD, RGBW_SAVE);
  30. }
  31.  
  32.  
  33. void loop()
  34. {
  35. }
  36.  



Raspberry Pi Connection Diagram

Image

Please note: when connecting to a Raspberry Pi the mLink module should either be powered via 3.3V, or the mLink modules I2C pullup resistors should be removed. See the 'Removing the modules I2C pullup resistors' section below for more information.


Setting A Colour Example

Raspberry Pi RGB(W) colour example:
This Python script demonstrates how to control the brightness of the individual red, green, blue, and white LEDs on an RGB/RGBW LED strip. The program will step through each colour in sequence.

This program requires the mLink Python library module to be installed. Please see the following forum thread for more information on how to install the Python module and requirements:

viewtopic.php?f=131&t=3062

  1. from mLink import mLink                     # Import the mLink module
  2. import time
  3.  
  4. ml = mLink.mLink(1)                         # Create an instance of the module
  5.  
  6. I2C_ADD = 0x53                              # Default I2C address is 0x53
  7.  
  8. ml.RGBW_Brightness(0x53, 255)               # Set brightness to maximum
  9.  
  10.  
  11. while 1:
  12.     ml.RGBW_Red_Level(I2C_ADD, 255)         # Turn just the red LEDs on
  13.     ml.RGBW_Green_Level(I2C_ADD, 0)
  14.     ml.RGBW_Blue_Level(I2C_ADD, 0)
  15.     ml.RGBW_White_Level(I2C_ADD, 0)
  16.     time.sleep(1)
  17.    
  18.     ml.RGBW_Red_Level(I2C_ADD, 0)           # Turn just the green LEDs on
  19.     ml.RGBW_Green_Level(I2C_ADD, 255)
  20.     ml.RGBW_Blue_Level(I2C_ADD, 0)
  21.     ml.RGBW_White_Level(I2C_ADD, 0)
  22.     time.sleep(1)
  23.    
  24.     ml.RGBW_Red_Level(I2C_ADD, 0)           # Turn just the blue LEDs on
  25.     ml.RGBW_Green_Level(I2C_ADD, 0)
  26.     ml.RGBW_Blue_Level(I2C_ADD, 255)
  27.     ml.RGBW_White_Level(I2C_ADD, 0)
  28.     time.sleep(1)
  29.    
  30.     ml.RGBW_Red_Level(I2C_ADD, 0)           # Turn just the white LEDs on
  31.     ml.RGBW_Green_Level(I2C_ADD, 0)
  32.     ml.RGBW_Blue_Level(I2C_ADD, 0)
  33.     ml.RGBW_White_Level(I2C_ADD, 255)
  34.     time.sleep(1)

Predefined Cycle Mode Example

Selecting One Of The Predefined Cycle Modes Example:
This Python script demonstrates how to put the module into one of the pre-defined patterns. The program will constantly step through each pattern allowing the pattern to run for 20 seconds before moving onto the next.

This program requires the mLink Python library module to be installed. Please see the following forum thread for more information on how to install the Python module and requirements:

viewtopic.php?f=131&t=3062

  1. from mLink import mLink                     # Import the mLink module
  2. import time
  3.  
  4. ml = mLink.mLink(1)                         # Create an instance of the module
  5.  
  6. I2C_ADD = 0x53                              # Default I2C address is 0x53
  7.  
  8. ml.RGBW_Brightness(0x53, 255)               # Set brightness to maximum
  9.  
  10.  
  11. while 1:
  12.     print("FAST RED-GREEN-BLUE CYCLE")
  13.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_FAST_RGB_COLOUR_CYCLE)
  14.     time.sleep(10)
  15.    
  16.     print("MEDIUM RED-GREEN-BLUE CYCLE")
  17.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_MED_RGB_COLOUR_CYCLE)
  18.     time.sleep(10)
  19.    
  20.     print("SLOW RED-GREEN-BLUE CYCLE")
  21.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_SLOW_RGB_COLOUR_CYCLE)
  22.     time.sleep(10)
  23.  
  24.     print("FAST RED-GREEN CYCLE")
  25.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_FAST_RG_CYCLE)
  26.     time.sleep(10)
  27.  
  28.     print("INTERMEDIATE RED ALARM PULSE")
  29.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_ALARM_INTER_PULSE)
  30.     time.sleep(10)
  31.    
  32.     print("CONSTANT RED ALARM PULSE")
  33.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_ALARM_CONT_PULSE)
  34.     time.sleep(10)
  35.  
  36.     print("CONSTANT RGB (WHITE) PULSE")
  37.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_RGB_CONT_PULSE)
  38.     time.sleep(10)
  39.    
  40.     print("FLAME EFFECT")
  41.     ml.RGBW_Pattern(I2C_ADD, ml.RGBW_CYCLE_FLAME)
  42.     time.sleep(10)

User Pattern Mode

Uploading a user defined pattern:
This Python script demonstrates how to load a user defined pattern into the modules pattern buffer. The program will load 3 colours (red, green, & blue) into the buffer and then tells the module to make 255 between each transition with each step taking 10ms.

This program requires the mLink Python library module to be installed. Please see the following forum thread for more information on how to install the Python module and requirements:

viewtopic.php?f=131&t=3062

  1. from mLink import mLink                     # Import the mLink module
  2.  
  3. ml = mLink.mLink(1)                         # Create an instance of the module
  4.  
  5. I2C_ADD = 0x53                              # Default I2C address is 0x53
  6.  
  7. # Create a list with 3 colours [255,0,0] = red, [0,255,0] = green,
  8. # [0,0,255] = blue. You can create a total of 8 colours.
  9. pattern = [[255,0,0], [0,255,0], [0,0,255]]
  10.  
  11.  
  12. ml.RGBW_User_Pattern(I2C_ADD, pattern)          # Load the pattern into the pattern buffer
  13. ml.RGBW_Brightness(I2C_ADD, 255)                # Set brightness to maximum
  14. ml.RGBW_Cycle_Steps(I2C_ADD, 255)               # 255 steps between each colour
  15. ml.RGBW_Cycle_Speed(I2C_ADD, 10)                # Wait 10ms between each step


Removing the modules I2C pullup resistors

Please note that the modules I2C pullup resistors should be removed if you intend to use it as follows:

1) You wish to connect more than 5 modules to the same I2C bus.

2) You wish to power this module at 5V and you have a 3.3V development board that does not have a 5V tolerant I2C interface.

3) You wish to power this module at 5V and you have a 3.3V development board that has its own I2C pullup resistors.


To disconnect the modules two 10K pullup resistors from the I2C bus, locate the 3 jumper pads labelled ‘END DEV’ and cut the two tracks linking them together as follows:

Image






Image

mLink Arduino library
viewtopic.php?f=58&t=3001


mLink Raspberry Pi Python module
The mLink python module can be installed with the following terminal command:

  1. pip install hc-mlink

Alternatively the library can be manually installed by downloading it from the forum and unzipping it to your project folder. See the Python module forum thread for more information and download link:
viewtopic.php?f=131&t=3062&p=8592#p8592

Please note that in some cases there may be additional configuration required. If you have issues getting your Raspberry Pi to communicate with the mLink module then please see the Python module forum thread here: viewtopic.php?f=131&t=3062


mLink Library Quick Start Guide For Arduino Users
https://hobbycomponents.com/downloads/m ... _Guide.pdf


mLink Library Reference Guide For The RGBW LED controller Module
https://hobbycomponents.com/downloads/m ... _Guide.pdf


mLink Specifications and Register Map For The RGBW LED controller Module
https://hobbycomponents.com/downloads/m ... er_Map.pdf


Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.

Post Reply

Return to “mLink”