I would like to have your advice on a project that I'm trying to accomplish with my ESP32, and before going to the question I'll give you some context.
I want to use my ESP32 to control 8 DC motors by interpreting commands/data from BLE or/and WIFI. The motors will be controlled by sending commands though I2C bus to 4 wemos motor shields.
I'm using at the moment Blynk connected through BLE to send imput information and when sending information of 2 motors it's response is sluggish so after some research I believe that it would be best to have a solution as following:
- Have a global int array where each element will be the direction/speed of each motor;
- In the loop() function read the BLE/Wifi input and update the array;
- Create a Task pinned in the core 0 that periodically (max each 100ms) will read the values of the array and send the I2C commands to the shields.
- In the above case hoe can I manage concurrency? Should I use mutexes when updating the array values?
- Is this solution too overkill? do you recommend another solution?