Connecting Accelerometer to ESP32

I have the ESP32Feather and Adafruit Lis3DH. I have got the led lights working now using the WLED app, but now I need to work out a way to get the accelerometer to work to make the leds activate when the drum is hit. I have made a drum for my brother and want the lights to activate when the drum is struck.

Would love any help please.




1 Like

Hi Greg,

Welcome to the forum!

It might be worth exploring a sound input for WLED, you might have better luck there.

Otherwise it might be worth using the Arduino IDE to program in exactly what you want

What do you mean sound input?

And if I have to code in arduino can I get some help as I have no idea what I’m doing

1 Like

Hi Greg,

If you have the electronics placed inside of the drum you could use something like this: Sound input module (4-pin) | Core Electronics Australia

and combine with the button macros: Macros - WLED Project

As for the Arduino code, it’ll just be copying parts of different tutorials, feel free to ask questions though!

With the sound one wouldn’t this pick up the other drums going off and the guitar amps etc?

This is the link to the tread I was trying to follow.

1 Like

Is there some reason you would not simply use the code from that project? It seems to cover exactly what you are describing.

2 Likes

I have done that but it seems to have not worked.

1 Like

What do you mean by ‘not worked’? Did you have a problem installing the librarires or the code, did the code compile, did it download to the device correctly, did the MCU run, did the lights turn on, or was it just that the flashing did not synchronise with the drum beats?

2 Likes

Hey Greg,

With the sound one wouldn’t this pick up the other drums going off and the guitar amps etc?

Yes, it would, you’d need to perform some form of (likely very basic) noise filtering on the sensor in order to only detect the signals that you’re intending to receive. Just ignoring anything under a certain signal strength should be enough imo.

Once you’ve gotten back to Jeff’s questions we should have a much better idea as to what else you can try and fix to get this working.

The lights didnt turn on when i hit on. Then they still wouldnt when i hit the surface either. The code seemed like it uploaded correctly.

Did you wait 30s for demo mode to start? If it didn’t start after 30s then you should comment out everything in the main loop and insert

       demoMode();

If the lights don’t work then either they aren’t wired correctly of the code isn’t getting as far as the main loop. To see if the code is executing the main loop insert a debug print statement at the start of the demoMode() function. If the code gets that far then there is a problem with the lights. If the code doesn’t get that far then there is a problem during setup.

To find the problem during setup insert debug statements liberally throughout the setup code. The problem will be some point between the last debug statement that prints and the first one that doesn’t. Change that last debug statement to show all the values of the variables that are relevant to the subsequent code and run it again. The values that print out should indicate what the problem with the code is.

The lights definitely work.

I will try all you have said tonight. Ill try format the whole board and start again

You have confirmed they work with the WLED app. You still need to confirm that they work with this sketch. The configuration could be quite different.