Difference between revisions of "RGB LED HAT"
(24 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{Infobox item| | + | <div class="wiki-pages jet-green-color"> |
− | |img=[[File:rgb-led-hat-intro_1.jpg|400px|link=http://www.waveshare.com/rgb-led-hat.htm]] | + | {{Infobox item| |
+ | |img=[[File:rgb-led-hat-intro_1.jpg|400px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=http://www.waveshare.com/rgb-led-hat.htm}}]] | ||
|brief=True color RGB LED HAT for Raspberry Pi, colorful display | |brief=True color RGB LED HAT for Raspberry Pi, colorful display | ||
|caption=True color RGB LED HAT for Raspberry Pi, colorful display | |caption=True color RGB LED HAT for Raspberry Pi, colorful display | ||
|category=[[:Category:Expansions|Expansions]], [[:Category:Raspberry Pi|Raspberry Pi]] | |category=[[:Category:Expansions|Expansions]], [[:Category:Raspberry Pi|Raspberry Pi]] | ||
|brand=Waveshare | |brand=Waveshare | ||
− | |{{#urlget:amazon|default}}=display | + | |{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display |
|website_cn=[http://www.waveshare.net/shop/usb-hub-hat.htm 官网] | |website_cn=[http://www.waveshare.net/shop/usb-hub-hat.htm 官网] | ||
|website_en=[http://www.waveshare.com/usb-hub-hat.htm Website] | |website_en=[http://www.waveshare.com/usb-hub-hat.htm Website] | ||
|interface1=RPi | |interface1=RPi | ||
}} | }} | ||
− | + | = Introduction = | |
True color RGB LED HAT for Raspberry Pi, colorful display | True color RGB LED HAT for Raspberry Pi, colorful display | ||
− | {{Amazon|{{#urlget:amazon|default}}=display | + | {{Amazon|{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display |
|More = [http://www.waveshare.com/usb-hub-hat.htm More]}} | |More = [http://www.waveshare.com/usb-hub-hat.htm More]}} | ||
== Interfaces == | == Interfaces == | ||
− | # For Raspberry Pi, you only need to insert the product | + | # For Raspberry Pi, you only need to insert the product into the corresponding interface on the Pi; |
− | # For other devices, you'd better | + | # For other devices, you'd better solder the pin headers to the pads of 5V, GND, DIN, and DOUT for wiring. |
{|class="wikitable" | {|class="wikitable" | ||
! Symbols !! Pin descriptions | ! Symbols !! Pin descriptions | ||
Line 30: | Line 31: | ||
|} | |} | ||
== Description == | == Description == | ||
− | WS2812B is an intelligent LED controller | + | WS2812B is an intelligent LED controller in which the control circuit and the RGB chip are integrated into a package of 5050 components. It internally includes an intelligent digital port, a data latch, and a signal-reshaping amplification drive circuit. To ensure the color brightness consistent with the pixel light, it also contains a precision internal oscillator and a 12V voltage programmable constant current control part. |
− | Its data transfer protocol uses single NZR communication mode. After the pixel is | + | Its data transfer protocol uses a single NZR communication mode. After the pixel is powered on and reset, the DIN port receives the data from the controller. The first 24-bit data is collected by the first pixel and then sent to the internal data latch. The other data are reshaped by the internal signal reshaping amplification circuit and sent to the next cascade pixel through the DO port. After the transmission for all pixels, the signal may be reduced to 24 bits. The pixel adopts auto-reshaping transmit technology, which allows the pixel cascade number to be up to the speed of the signal transmission but not bound by the signal transmission restriction. For more information about auto reshaping transmits technology, please refer to the section on data transfer protocol. |
=== Sequence chart === | === Sequence chart === | ||
: [[File:rgb-led-hat-user-manual-1.png|200px|thumb|Sequence chart]] | : [[File:rgb-led-hat-user-manual-1.png|200px|thumb|Sequence chart]] | ||
Line 50: | Line 51: | ||
=== Data transmission method === | === Data transmission method === | ||
− | + | [[File:rgb-led-hat-user-manual-2.png]]<br/> | |
− | + | Note: The data of D1 is sent by MCU, and D2, D3, and D4 are transmitted through pixel internal reshaping amplification. | |
− | + | ===Color Formats=== | |
− | + | The color formats are divided into many kinds, the common ones are RGB888, RGB565, etc.; the | |
− | {| | + | RGB888 means: R:Red(Red), G:Green(Green), B:Blue(Blue). It indicates that it accounts for 8 bits of data. Therefore transmitting complete color data takes 24 bits.<br/> |
− | |- | + | For WS2812B, he uses this format, but the color data he sends is G-R-B, so we need to convert our RGB to GRB when we send it again.<br/> |
− | | G7 || G6 || G5 || G4 || G3 || G2 || G1 || G0 || R7 || R6 || R5 || R4 || R3 || R2 || R1 || R0 || B7 || B6 || B5 || B4 || B3 || B2 || B1 || B0 | + | |
+ | {|border=1; style="width:700px;" align="center" | ||
+ | |-style="background:#00ff00; color:white;" align="center" | ||
+ | |G7||G6||G5||G4||G3||G2||G1||G0 | ||
+ | |-style="background:#FF0000; color:white;" align="center" | ||
+ | |R7||R6||R5||R4||R3||R2||R1||R0 | ||
+ | |-style="background:#0000ff; color:white;" align="center" | ||
+ | |B7||B6||B5||B4||B3||B2||B1||B0 | ||
|} | |} | ||
− | + | ||
+ | Note: High first, send data in the order of GRB.<br /> | ||
== How to use == | == How to use == | ||
− | |||
=== Libraries installation === | === Libraries installation === | ||
− | + | Install the libraries with the following commands: | |
− | + | <pre> | |
+ | sudo apt-get install python3-pip -y | ||
+ | sudo pip3 install rpi_ws281x -y | ||
+ | </pre> | ||
+ | |||
For the latest libraries, you can visit the website: https://github.com/jgarff/rpi_ws281x | For the latest libraries, you can visit the website: https://github.com/jgarff/rpi_ws281x | ||
− | + | Download the examples and run them for a try | |
− | + | <pre> | |
− | + | wget https://files.waveshare.com/upload/b/b2/RGB_LED_HAT.zip | |
− | + | unzip RGB_LED_HAT.zip | |
− | + | sudo chmod 777 -R RGB_LED_HAT | |
− | : | + | cd RGB_LED_HAT |
− | + | sudo python3 ws2812.py | |
− | + | </pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
* If the library is installed successfully, you can see the RGB LED flickering. | * If the library is installed successfully, you can see the RGB LED flickering. | ||
+ | |||
+ | [[File:RGB LED HAT RPI1.png]] | ||
<font color=red> | <font color=red> | ||
− | * If the LED displays the wrong color, please add the lines below into the file /boot/config.txt, and restart the Pi to take | + | * If the LED displays the wrong color, please add the lines below into the file /boot/config.txt, and restart the Pi to take the effect. |
− | * RGB LED adopts DMA control, which may occupy the video output DMA channel on the Raspberry Pi. Therefore, adding these lines may | + | * RGB LED adopts DMA control, which may occupy the video output DMA channel on the Raspberry Pi. Therefore, adding these lines may make the earphone connector unusable. |
</font> | </font> | ||
hdmi_force_hotplug=1 | hdmi_force_hotplug=1 | ||
hdmi_force_edid_audio=1 | hdmi_force_edid_audio=1 | ||
+ | |||
+ | <!-- | ||
=== Demo descriptions === | === Demo descriptions === | ||
Running the demo ws2812.py, you can see the RGB LED display the gradient color. | Running the demo ws2812.py, you can see the RGB LED display the gradient color. | ||
cd RGB_LED_HAT | cd RGB_LED_HAT | ||
− | sudo | + | sudo python3 ws2812.py |
: [[File:rgb-led-hat-user-manual-4.png]] | : [[File:rgb-led-hat-user-manual-4.png]] | ||
# <code>from neopixel import *</code> import the library rpi-ws281x | # <code>from neopixel import *</code> import the library rpi-ws281x | ||
# <code>Adafruit_NeoPixel</code> creates an object strip, sets the number of the LEDs to 32, the pin to 18, and the frequency to 800000. The parameter <code>LED_BRIGHTNESS</code> is the brightness of the LED. | # <code>Adafruit_NeoPixel</code> creates an object strip, sets the number of the LEDs to 32, the pin to 18, and the frequency to 800000. The parameter <code>LED_BRIGHTNESS</code> is the brightness of the LED. | ||
# <code>begin()</code> RGB LED initialization function. | # <code>begin()</code> RGB LED initialization function. | ||
− | # <code>setPixelColor(pos, color)</code> This sets the pixel, of which pos is the LED position, and color is the RGB color | + | # <code>setPixelColor(pos, color)</code> This sets the pixel, of which pos is the LED position, and the color is the RGB color |
− | # <code>color(r, g, b)</code> This converts the RGB value to a 24 bit color. | + | # <code>color(r, g, b)</code> This converts the RGB value to a 24-bit color. |
# <code>show()</code> This transfers data, showing the set LED color. | # <code>show()</code> This transfers data, showing the set LED color. | ||
# For more information about the functions, please see rpi_ws281x-master/python/neopixel.py | # For more information about the functions, please see rpi_ws281x-master/python/neopixel.py | ||
+ | --> | ||
=== Web control with Bottle === | === Web control with Bottle === | ||
: [[File:rgb-led-hat-user-manual-5.jpg|thumb|200px|controlled by browser]] | : [[File:rgb-led-hat-user-manual-5.jpg|thumb|200px|controlled by browser]] | ||
− | + | Make sure that the basic use is possible, then execute the following command: | |
+ | <pre> | ||
+ | sudo apt-get install python3-bottle | ||
+ | cd RGB_LED_HAT/web/ | ||
+ | sudo python3 main.py | ||
+ | </pre> | ||
+ | If you are using RGB LED HAT (B), you need to modify main.py to change the LED_COUNT to 64.<br/> | ||
+ | As shown above, enter the Raspberry Pi IP address and port number 8000 in the address bar of your mobile browser, and the RGB LED will display different colors by clicking different positions of the color palette. "static", "breath" and "flash" correspond to three display modes respectively.<br/> | ||
− | + | Take RGB LED HAT as an example, and the actual demonstration effect:<br/> | |
− | + | [[File: RGB-LED-HAT-SDISPLAY.gif]] | |
− | |||
− | |||
− | |||
− | + | ===Problem=== | |
− | + | 1: If there is an error RuntimeError: "ws2811_init failed with code -3 (Hardware revision is not supported)" <div class="tabbertab" title="resources" id="myresources"<br/> | |
+ | A: Uninstall rpi_ws281x, download the source code manually, and compile and install. | ||
+ | <pre> | ||
+ | sudo pip uninstall rpi_ws281x | ||
+ | git clone --recurse-submodules https://github.com/rpi-ws281x/rpi-ws281x-python | ||
+ | cd rpi-ws281x-python/library/, | ||
+ | sudo python setup.py install | ||
+ | If it is python3, change pip to pip3 and python to python3. | ||
+ | If you still get this error after updating, you can refer https://github.com/jgarff/rpi_ws281x/issues/483 | ||
+ | </pre> | ||
− | + | = Resources = | |
− | + | == Documentation == | |
− | * [ | + | * [https://files.waveshare.com/upload/b/bf/RGB_LED_HAT_Schematic_.pdf Schematic] |
− | * [ | + | * [https://files.waveshare.com/upload/9/94/WS2812B_datasheet_EN.pdf Datasheet] |
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | + | == Software == |
− | + | * [https://files.waveshare.com/upload/a/ae/RGB_LED_HAT.tar.gz Demo Code] | |
+ | == Others == | ||
+ | * [[Raspberry Pi Tutorial Series]] | ||
+ | =Support= | ||
+ | {{Servicebox1}} | ||
[[Category:Expansions|Expansions]], [[Category:Raspberry Pi|Raspberry Pi]] | [[Category:Expansions|Expansions]], [[Category:Raspberry Pi|Raspberry Pi]] |
Latest revision as of 09:41, 22 March 2024
| ||
Introduction
True color RGB LED HAT for Raspberry Pi, colorful display
More |
Interfaces
- For Raspberry Pi, you only need to insert the product into the corresponding interface on the Pi;
- For other devices, you'd better solder the pin headers to the pads of 5V, GND, DIN, and DOUT for wiring.
Symbols | Pin descriptions |
---|---|
5V | 5V power supply |
GND | Ground |
DIN | Control signal input |
DOUT | Control signal output |
Description
WS2812B is an intelligent LED controller in which the control circuit and the RGB chip are integrated into a package of 5050 components. It internally includes an intelligent digital port, a data latch, and a signal-reshaping amplification drive circuit. To ensure the color brightness consistent with the pixel light, it also contains a precision internal oscillator and a 12V voltage programmable constant current control part.
Its data transfer protocol uses a single NZR communication mode. After the pixel is powered on and reset, the DIN port receives the data from the controller. The first 24-bit data is collected by the first pixel and then sent to the internal data latch. The other data are reshaped by the internal signal reshaping amplification circuit and sent to the next cascade pixel through the DO port. After the transmission for all pixels, the signal may be reduced to 24 bits. The pixel adopts auto-reshaping transmit technology, which allows the pixel cascade number to be up to the speed of the signal transmission but not bound by the signal transmission restriction. For more information about auto reshaping transmits technology, please refer to the section on data transfer protocol.
Sequence chart
- Data transfer time( TH+TL=1.25µs±600ns)
T0H | 0 code, high voltage time | 0.4µs | ±150ns |
T1H | 1 code, high voltage time | 0.8µs | ±150ns |
T0L | 0 code, low voltage time | 0.85µs | ±150ns |
T1L | 1 code, low voltage time | 0.45 µs | ±150ns |
RES | The unit of frame, low voltage time | Above 50µs |
Data transmission method
Note: The data of D1 is sent by MCU, and D2, D3, and D4 are transmitted through pixel internal reshaping amplification.
Color Formats
The color formats are divided into many kinds, the common ones are RGB888, RGB565, etc.; the
RGB888 means: R:Red(Red), G:Green(Green), B:Blue(Blue). It indicates that it accounts for 8 bits of data. Therefore transmitting complete color data takes 24 bits.
For WS2812B, he uses this format, but the color data he sends is G-R-B, so we need to convert our RGB to GRB when we send it again.
G7 | G6 | G5 | G4 | G3 | G2 | G1 | G0 |
R7 | R6 | R5 | R4 | R3 | R2 | R1 | R0 |
B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 |
Note: High first, send data in the order of GRB.
How to use
Libraries installation
Install the libraries with the following commands:
sudo apt-get install python3-pip -y sudo pip3 install rpi_ws281x -y
For the latest libraries, you can visit the website: https://github.com/jgarff/rpi_ws281x
Download the examples and run them for a try
wget https://files.waveshare.com/upload/b/b2/RGB_LED_HAT.zip unzip RGB_LED_HAT.zip sudo chmod 777 -R RGB_LED_HAT cd RGB_LED_HAT sudo python3 ws2812.py
- If the library is installed successfully, you can see the RGB LED flickering.
- If the LED displays the wrong color, please add the lines below into the file /boot/config.txt, and restart the Pi to take the effect.
- RGB LED adopts DMA control, which may occupy the video output DMA channel on the Raspberry Pi. Therefore, adding these lines may make the earphone connector unusable.
hdmi_force_hotplug=1 hdmi_force_edid_audio=1
Web control with Bottle
Make sure that the basic use is possible, then execute the following command:
sudo apt-get install python3-bottle cd RGB_LED_HAT/web/ sudo python3 main.py
If you are using RGB LED HAT (B), you need to modify main.py to change the LED_COUNT to 64.
As shown above, enter the Raspberry Pi IP address and port number 8000 in the address bar of your mobile browser, and the RGB LED will display different colors by clicking different positions of the color palette. "static", "breath" and "flash" correspond to three display modes respectively.
Take RGB LED HAT as an example, and the actual demonstration effect:
Problem
1: If there is an error RuntimeError: "ws2811_init failed with code -3 (Hardware revision is not supported)" <div class="tabbertab" title="resources" id="myresources"
A: Uninstall rpi_ws281x, download the source code manually, and compile and install.
sudo pip uninstall rpi_ws281x git clone --recurse-submodules https://github.com/rpi-ws281x/rpi-ws281x-python cd rpi-ws281x-python/library/, sudo python setup.py install If it is python3, change pip to pip3 and python to python3. If you still get this error after updating, you can refer https://github.com/jgarff/rpi_ws281x/issues/483
Resources
Documentation
Software
Others
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 AM GMT+8 (Monday to Friday)