mLink WS2812 RGB LED Controller (HCMODU0197)

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

mLink WS2812 RGB LED Controller (HCMODU0197)

Post by admin » Tue Mar 26, 2024 4:26 pm

[IMAGE TBA]

Image

The mLink WS2812 LED driver is a serial (I2C) module intended for driving WS2812 5V RGB LEDs. It is capable of independently controlling up to 200 LEDs via the WS2812s serial interface.

The module is capable of generating the precise timings required by these LEDs and its 200 LED buffer can store the individual RGB state of each LED in full 24 bit colour. This removes the memory and processing requirements of the host microcontroller which is especially useful for low power 8-bit microcontrollers with limited amounts of RAM and processing power.

Compatible with microcontrollers equipped with an I2C interface, including popular Arduino models, wireless ESP devices, and Raspberry Pi, this module offers versatile control options. As part of the mLink series, it seamlessly integrates with other mLink modules. This means you can easily daisy-chain multiple mLink modules, enabling centralised control through a single serial interface.

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 module, resulting in very little resource 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



Image

Module code: 						HCMODU0197
Supply voltage (VDD): 				4.5V to 5.5V
Current consumption (idle):			6.5mA
LED type:							WS2812 5V RGB LEDs
Maximum number of LEDs per module:	200*
Number of colours:					Full 24bit (16,777,215) colours
Brightness:						255 levels with separate on/off control
Interfaces:						4 pin male mLink header, Large WS2812 solderable pads with option 0.1” pin header
I2C Interface speed:					400kbits/s (fast mode)
I2C default address (HEX):				0h5E
Maximum number of modules:			5 with pullups fitted, 112 with pullups removed**
Module dimensions ex headers (LxWxH):	40.5mm x 11mm x 5mm



*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 I2C pullups fitted to all modules. For disconnecting pullups see forum post.




Image


Image

Important note: If your LED strip has more than 24 LEDs then the LED strip MUST be powered via an external 5V power supply


Image



  1. /*This sketch uses the mLink library to cycle a single LED through
  2. the red, green, and blue colours.*/
  3.  
  4.  
  5. #include "mLink.h"                                    // Include the library
  6.  
  7. mLink mLink;                                          // Create an instance of the library
  8.  
  9. #define I2C_ADD 0x5E                                  // Default I2C address
  10.  
  11. #define NUMBEROFLEDS 16                               // Sets the number of LEDs in your strip
  12.  
  13.  
  14. void setup()
  15. {
  16.   mLink.init();                                       // Initialise the library
  17.  
  18.   mLink.WS2812_Max(I2C_ADD, NUMBEROFLEDS);            // Tell the module how many LEDs are connected to the module (max 200)
  19.  
  20.   //mLink.WS2812_Order(I2C_ADD, WS2812_ORDER_GRB);       // Uncomment if your LED order is GRB
  21. }
  22.  
  23.  
  24. void loop()
  25. {
  26.   mLink.WS2812_RGB(I2C_ADD, 0, 255, 0, 0);            // Set LED at index 0 to red
  27.   mLink.WS2812_Refresh(I2C_ADD);
  28.   delay(1000);
  29.  
  30.   mLink.WS2812_RGB(I2C_ADD, 0, 0x00, 255, 0);         // Set LED at index 0 to green
  31.   mLink.WS2812_Refresh(I2C_ADD);
  32.   delay(1000);
  33.  
  34.   mLink.WS2812_RGB(I2C_ADD, 0, 0, 0, 255);            // Set LED at index 0 to blue
  35.   mLink.WS2812_Refresh(I2C_ADD);
  36.   delay(1000);
  37. }
  38. }




Image


Image

Important notes:

If your LED strip has more than 24 LEDs then the LED strip MUST be powered via an external 5V power supply. The maximum number of LEDs that can be driven from the Raspberry Pi / mLink module may also be limited by your Raspberry Pis PSU

When connecting to a Raspberry Pi the mLink modules I2C pullup resistors should be removed. See the 'Removing the modules I2C pullup resistors' section below for more information.



  1. # mLink WS2812 RGB LED controller example
  2. # This example requires the mLink module to be installed. Please see
  3. # library forum thread for more information
  4.  
  5.  
  6.  
  7. from mLink import mLink                     # Import the mLink module
  8. import time
  9.  
  10. ml = mLink.mLink(1)                         # Create an instance of the module
  11.  
  12. I2C_ADD = 0x5E                              # Default I2C address is 0x5E
  13.  
  14. ml.WS2812_Max(I2C_ADD, 16)                  # Sets the number of LEDs in your strip (max = 200)
  15.  
  16. ml.WS2812_Brightness(I2C_ADD, 255)          # Sets the maximum brightness level (max = 255)
  17.  
  18. ml.WS2812_Clear(I2C_ADD)                    # Clears the LED buffer
  19.  
  20. ml.WS2812_RGB(I2C_ADD, 0, 255, 0, 0)        # Set LED 0 to red
  21. ml.WS2812_RGB(I2C_ADD, 1, 0, 255, 0)        # Set LED 1 to green
  22. ml.WS2812_RGB(I2C_ADD, 2, 0, 0, 255)        # Set LED 1 to blue
  23.  
  24. ml.WS2812_Refresh(I2C_ADD)                  # Update the LEDs




Image


Factory Reset:

Should you wish to restore the module back to its factory default configuration, this can be done by manually forcing a factory reset. All mLink modules include a set of pads labelled clear:

Image

To perform a factory reset carefully link the two pads together with a piece of wire or with something conductive such as a paperclip. Whilst linked, connect power to the module via the VCC and GND connections. Wait a few seconds and then remove the short from the pads. The module's settings, including its I2C address, should now be restored back to factory defaults.



Removing I2C pullups:

If your development board already has pullups for its I2C interface fitted, or you wish to connect more than 5 mLink boards to the same I2C interface, then you can remove the pullups for the additional boards by cutting the tracks between the solder pads shown below.

Image





Image

mLink Arduino library

viewtopic.php?f=58&t=3001

Please note you will need at least V2.0.0 (22 Mar 2024) of the library to support this module. If you have an older version already installed please update it to the latest version.


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 Specifications and Register Map
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 not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Post Reply

Return to “mLink”