• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Interfacing MPU6050 to WLED Controller

Q&A Forum › Interfacing MPU6050 to WLED Controller
0 Vote Up Vote Down
William Lucid asked 2 years ago

Thoughts on how to proceed with interfacing APDS9960 Gesture Module. Device is I²C.
Is there a non-compiled version of WLED/WLED SR for the ESP32? Current controller is an Athom WLED Music RGB Strip Controller. I also have ESP32, Node32s development boards available.

I have Python code that interfaces Athom controller using the HTTP Api; would like to use Gestures to to set variables in the Python code. Currently variables are FX and FP and time.sleep(seconds).

Python code for WLED effects

Regards,
William

Question Tags: APDS9960, ESP32, WLED
11 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
 
I’m sorry for taking so long to get back to you.
Unfortunately, I never experimented with that module. Have you taken a look at the adafruit library? Usually, their libraries are compatible with the ESP32 and you only need to adjust the I2C pins in the code. 
https://github.com/adafruit/Adafruit_APDS9960/blob/master/examples/gesture_sensor/gesture_sensor.ino
 
Regards,
Sara
 

0 Vote Up Vote Down
William Lucid answered 2 years ago

Hi Sara,
My apologies for the delayed response.
My finding on the APDS9960 Gesture sensore; not suited for the application of creating 0-255 values needed for WLED URL variables.  Thinking of using a “paddle” with the MPU6050 mounted, then a person could “wave” the “paddle” generating RGB values in the range 0-255.  I have coded a sketch to try “different” methods of declaring the red, green, and blue variables.  Sketch collects 40 passed of gathering data; then FTP becomes available for reading the data collected.
Testing_MPU6050.ino
Declarations of red, green, and blue:

  /* Get new sensor events with the readings */
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
int red = map((a.acceleration.x), -32768, 32767, 0, 255);
int green = map((a.acceleration.y), -32768, 32767, 0, 255);
int blue = map((a.acceleration.z), -32768, 32767, 0, 255);

Need to experiment to get the most 0-255 values I can “pull” out of the RGB declarations.  Any suggestions; I am seeing limited range and not the full 0-255 range.  I would like to elimanate any negative values.
 
Google Sheet of data logged
 
Regards,
William

0 Vote Up Vote Down
William Lucid answered 2 years ago

Good Evening,
Created a sketch that creates variables: “effects,” “intensity,” and “color pallete” for use with WLED.  More details about the WLED can be found at:  WLED Project
Here are the results of MPU6050 Accelerometer and Gyro Breakout project:
Resultsfrom MPU6050_WLED sketch
MPU6050_WLED project can be found at:  WLED Project
Short video of WLED receiving commands from Python linked in this topic:  WLED Strip LED light effects
Best of all WLED is a compiled binary, it can be installed to ESP32 from a Web base installer or you can compile a customized version.
Regards,
William

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Thanks for the update.
Looking forward to seeing the final project.
Regards,
Sara

0 Vote Up Vote Down
William Lucid answered 2 years ago

Good Evening,

Short video

Short video; waving “paddle” with ESP32 and MPU6050 Accelrometer/Gyroscope, effecting changes to RGB Leds being controlled by a Athom ESP32 Music controller for addressable RGB Leds.  Athom device is running WLED Sound Reactive firmware; which has WiFi and responds to a “custom” URL sent from the ESP32 on the “paddle.”.

There is a lag between paddle movement and seeing a change in effect, intensity, and color.  Maybe due to math processes running before the URL is sent.

MPU6050_WLED Github Repository

Regards,
William

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Wow.
Thanks for sharing the video. It is looking great!
Keep up the good work 😀

0 Vote Up Vote Down
William Lucid answered 2 years ago

Good Morning Sara,

Thank you; your feedback is apreciated.

“MPU6050_WLED.ino” sketch sends a “custom” URL from 2nd ESP32 to the controller; which runs the WLED Sound Reactive firmware.  Parameters FX (effects), intensity (IX), and colors (FP) are “generated” by motion of the MPU6050; if there is no MPU6050 motion,  FX, and FP are “generated” randomly. Sketch uses interrupt on the MPU6050; to know when motion is detected.

Regards,
William

0 Vote Up Vote Down
William Lucid answered 2 years ago

Good Morning,

Struggling to figure out a way to keep motion detection active, for sequential data readings; decide on another approach.  Using a touch pin with a conditional statement.  I have the desired result working.

If the “Chromawand” is in use the motion function is called; when not in use, noMotion function is called. Nearly perfect; except for some math processing time I think, as there is some lag between “Chromawand” movement andd seeing the change in RGB effects.

Code is on GitHUb

William

0 Vote Up Vote Down
William Lucid answered 2 years ago

Video of MPU6050_WLED running on Tom Parish’s ORB art project:  Video shows Tom using the Chromawand (pcb with ESP32 and MPU6050 Accellrometer/Gryou) for sending “custom” URL’s for controlling effects. intensity, and color pallette to a WLED controller for RGB Addressable RGB Leds.

Tom Parish’s Orb Art Project

William

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Wow.
The LED strip looks so cool in that configuration!
It’s looking good.

0 Vote Up Vote Down
William Lucid answered 2 years ago

Thanks for the feedback Sara.

Have created another version; this one uses four switches and does not use touch sensors.  Sketch can be found on Githb:  New version of MPU6050_WLED project

ChatGPT assisted in creating this project.

OpenAI’s ChatGPT Sign-in or Sign- up web page

Regards.
William

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.