element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Light Up Your Life
  • Challenges & Projects
  • Design Challenges
  • Light Up Your Life
  • More
  • Cancel
Light Up Your Life
Forum RGB-Matrix testing wireless communication - BLOG 4
  • News
  • Forum
  • Projects
  • DC
  • Leaderboard
  • Files
  • Members
  • More
  • Cancel
  • New
Join Light Up Your Life to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 1 reply
  • Subscribers 45 subscribers
  • Views 62 views
  • Users 0 members are here
  • esp32
  • ESPNOW
  • würth elektronik
  • led
  • Light Up Your Life
  • remote
Related

RGB-Matrix testing wireless communication - BLOG 4

embeddedguy
embeddedguy 5 days ago

Table of Contents

  • Introduction
  • Testing of different LEDs
    • 1313210530000 LED
    • 1315050930002 LED
    • 1312020030000 LED
  • Controlling LED color using Wi-Fi
  • Final thoughts

Introduction

In the previous blog post, I have talked about different LED types from Wurth Electronics kit in this challenge. This blog post will be more about the progress that I have made so far and remaining parts of the previous blog post. 

Testing of different LEDs

In the blog-3 of this challenge, I have discussed about some LEDs, and the others were yet to be discussed. In this blog post I am discussing about those LEDs.

As I am using MicroPython for development and software it is important to note that all the LEDs are not compatible with neopixel library provided by Micropython. Well, that is not a burden to me at all. But it is important to note.

The LEDs discussed in this blog post are all compatible with Neopixel format. This is because some LEDs do have different timing and protocol requirements. Such that for those LEDs sometimes separate clock signal is required.

Along with clock signal it needs data line. So for these LEDs it is required to have a detailed look on their datasheet and develop driver to drive those LEDs. 

Most common workaround would be to use interface such as SPI, I2S, etc. These protocols can generate the data required by the different LED types. 

In the previous blog post, I have used hardware SPI interface to send data to this LEDs. It took me some time to understand the exact bit format for this LEDs. But right frequency on SCK and properly encoded data could make it possible for anyone to work with these LEDs.

1313210530000 LED

From all the LEDs in the kit this one is the smallest one. When I started creating PCB, I thought that it would be nice to place these LEDs on the rounded corner of the PCB. This LEDs are suitable for tiny size requirements or to create some designs on the PCB like letters or logo etc. due to its small size. It is compatible with Neopixel library.

{gallery}LEDs

image

1313210530000 LED: Tiny corner mounted 

image

image

image

1315050930002 LED

These LEDs are somewhat big in size and has 4 pins. In my opinion this is exact replacement of ws-2812b type of LEDs. It is suitable for lighting application in home, office or anything similar. It can change colors so can be used for applications that require color 

imageimage

1312020030000 LED

These are tiny LEDs that can run with Neopixel format. These are also tiny LEDs with nice color spread. It can be used for decorative lights, home applications and other similar applications.

imageimage

imageimage

 

import time
import machine, network
import espnow
import ubinascii
import neopixel

ledcorner = machine.Pin(12)
ledfive = machine.Pin(45)
ledseven = machine.Pin(47)

neopixelcorner = neopixel.NeoPixel(ledcorner, 9)
neopixelfive = neopixel.NeoPixel(ledfive, 5)
neopixelseven = neopixel.NeoPixel(ledseven, 7)

red = 0
green = 255
blue = 0
    
while(1):
    for i in range(9):
        neopixelcorner[i] = (red, green, blue)
    
    for i in range(5):
        neopixelfive[i] = (red, green, blue)
        
    for i in range(7):
        neopixelseven[i] = (red, green, blue)
        
    #neopixelcorner.write()
    #neopixelfive.write()
    neopixelseven.write()
    

Controlling LED color using Wi-Fi

ESPNOW is a Wi-Fi based protocol for wireless communication. It offers simple point-to-point connection between devices. 

With ESPNOW it is possible to connect upto 20 devices simultaneously. The protocol does not require complex setup and AP/STA mode requirements. 

Another advantage is that ESPNOW can operate for quite long range than traditional Wi-Fi or Bluetooth communication. It can range up to 1.2 kms. This makes it quite suitable for smart light and remote control-based application.

For now, I have tried a simple remote control to change LED color to either RED, GREEN or BLUE based on the status of the push button press on the sending device.

Use of remote control to change LED light color and intensity is more common than using something else. Like for example WiFi or Bluetooth. It eliminates complex setup and cost related to software development and it's faster than other methods. Also, security is not an issue with remote control. 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

In the Python code for control of the colors of LEDs one just need the MAC address of the sender and the receiver node for point-to-point communication.

Here is the code for sender node. The sender node checks for push button press and if a specific button is pressed then the color on the other side will change to specific color. There are only three pushbuttons so only three colors are possible.

#This is a sender for changing LED colors based on button values

import time
import machine
import espnow
import network
from machine import ADC
import ubinascii

sender = network.WLAN(network.WLAN.IF_STA)
sender.active(True)

mac_bytes = sender.config('mac')
mac_address = ubinascii.hexlify(mac_bytes, ':').decode().upper()
print(mac_address)

espnow = espnow.ESPNow()
espnow.active(True)

receiver = b'\x10\x20\xBA\x59\x7A\xC8'

espnow.add_peer(receiver)

sw2 = ADC(machine.Pin(1))
sw3 = ADC(machine.Pin(2))
sw4 = ADC(machine.Pin(3))

time.sleep(2)

while(1):
    red = sw2.read()
    print(red)
    
    green = sw3.read()
    print(green)
    
    blue = sw4.read()
    print(blue)
    send = bytearray(3)
    
    if red == 0:
        send[0] = 0
        send[1] = 255
        send[2] = 255
        espnow.send(receiver, send, True)    
        time.sleep(1)
        
    if blue == 0:
        send[0] = 255
        send[1] = 0
        send[2] = 255
        espnow.send(receiver, send, True)    
        time.sleep(1)
        
    if green == 0:
        send[0] = 255
        send[1] = 255
        send[2] = 0
        espnow.send(receiver, send, True)    
        time.sleep(1)
        
    time.sleep(1)

Here is the code for the receiver node. In this case the RGB-Matrix PCB. The code continuously checks for new values on ESPNOW network and changes the color of the LED if there is a new value.

# 7C:DF:A1:07:BE:A6
# Receiving the espnow packate and changing the LED colors to RED | GREEN | BLUE
# depending on the button pressed

import time
import machine, network
import espnow
import ubinascii
import neopixel

receiver = network.WLAN(network.WLAN.IF_STA)
receiver.active(True)

mac_bytes = receiver.config('mac')
mac_address = ubinascii.hexlify(mac_bytes, ':').decode().upper()
print(mac_address)

espnow = espnow.ESPNow()
espnow.active(True)

sender = b'\x7C\xDF\xA1\x07\xBE\xA6'
espnow.add_peer(sender)

ledcorner = machine.Pin(12)
ledfive = machine.Pin(45)
ledseven = machine.Pin(47)

neopixelcorner = neopixel.NeoPixel(ledcorner, 9)
neopixelfive = neopixel.NeoPixel(ledfive, 5)
neopixelseven = neopixel.NeoPixel(ledseven, 7)

red = 255
green = 0
blue = 0
    
while(1):
    for i in range(9):
        neopixelcorner[i] = (red, green, blue)
    
    for i in range(5):
        neopixelfive[i] = (red, green, blue)
        
    for i in range(7):
        neopixelseven[i] = (red, green, blue)
        
    neopixelcorner.write()
    neopixelfive.write()
    neopixelseven.write()
    
    mac, msg = espnow.recv()
#     print(mac)
#     print(msg[0])
#     print(msg[1])
#     print(msg[2])
    
    if(msg[0] == 0):
        red = 255
        green = 0
        blue = 0
        
    if(msg[1] == 0):
        red = 0
        green = 255
        blue = 0
    
    if(msg[2] == 0):
        red = 0
        green = 0
        blue = 255
        
    time.sleep(1)

Final thoughts

For this blog, I have keep it simple. But I have also trained ML model on Edge-Impulse and want to try that on this device. The model can detect keywords to change LED colors. Another possibility would be to use libraries such as Emlearn to train and develop ML model. But this can be challenging on tiny devices such as SoC or microcontrollers. Such tiny devices have less memory and have less RAM to fit the model accurately. Emlearn has an advantage that it is compatible with Micropython devices.

  • Sign in to reply
  • Cancel
Parents
  • DAB
    DAB 2 days ago

    Nice update.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • DAB
    DAB 2 days ago

    Nice update.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube