ESP32 options

I currently use a Node MCU ESP-32 ESP32 Board WROOM-32 WiFi Bluetooth Arduino IDE Compatible board and connect to the Glowbit 8x1 led sticks from Core. This then daisy chains to multiple glowbit sticks. I have an Arduino sketch programmed to run and replicate on each glowbit stick. I dont currently use the WIFi or Bluetooth yet but it is in the list to learn.
I have 2 questions related to this :

  1. Is this ESP32 board overkill for what im using it for? Is there an alternative option, smaller that is still capable ie: the Beetle range of boards?

  2. Can i have 2 different Arduino Sketch’s loaded onto the single board to enable more than one colour output option?

1 Like

Please take this as just my view on things, as normally there is way more involved.

“Is the ESP32 Overkill” - need to define overkill.
In short most people will tend to pick a controller based on one of the following

  1. This is what I know (and have) - No issue for a hobby and one skill set can make things easier to learn and build on.

  2. This is what the wiki/guide said to use - A good way to get up and running fast, but in the long term may leave you needing to learn more specific skills just to use, debug and expand.

  3. What do I need/want at the end of the project: i.e. what are the project requirements; size, cost, available prebuilt things v dev 100% yourself; will all the parts be available in 1,2 10 years if I go to market.

So; short answer… this is hard to answer.

e.g. I have nearly always written my own code. often this can be based on someone else’s code and working with datasheets, but I have the sources code for what I want and do it at the chip level. i.e. I very really use frameworks and prebuilt library and apps. This is not for everyone and is much slower from start to finsih of a project; but once done, you have a better understanding of how things work and you get exactly what you want… but, and I must stress will have lots of road blocks as you learn whats needed to make thigs work v just using what someone else has already got working.

This feeds into your 2nd question

"Can I have 2 different… " My answer would be sure… but no idea if your setup would support that.
i.e. You may need to customise some code to allow dual threads and 2 instance (if in fact that’s the best design)

An ESP32 is a nice chip but it normally runs RTOS. As such its harder to get very accurate timers); I had all sorts of fun with my WS2812b led as they have strict timing on clocking out the data. But then I moved my buffer to a memory location and had the chip DMA the data and clock it out in the background (at the chip level) with very good timing. This then leaves more time in the 2 main cores for processing things like WiFi. the ADC on the ESP32 is not the best, but you can just use an external ADC if you need higher precision.

One thing I did like with the ESP32 is you can partition it. The do over the air updates; but you need to make sure your partitions are big enough, as lots of the chips “storage” is “lost” to provide this feature.
i.e. there is the “factory image” as flashed using the usb normal programming mode.
then there are 2 other image locations for the over the air updates. It will use 1, then if update is ok, switch over to that leaving the first one free for the next update… so 3 times the storage needed.

I will stop there as Im starting to waffle and more specific questions would be better to give specific answers.

Bottom line, my 2 cents worth, It depends. On what “your” key objectives are, and there is nothing wrong with rapid dev with pre built things; it it works for your projects.

1 Like

Hi Martin

Firstly welcome to the forum!

To answer your questions:

  1. The ESP32 you have is definitely capable of running your project as you’ve no doubt discovered, if you’re looking for a smaller form factor controller you might be interested in the RP2040-Zero.

  2. In terms of running 2 different sketches on the same module, as Michael99645 mentioned above it can be done, but there is a degree of complexity. If you’re looking to run two loops you could look into timers as a method of running the loops simultaneously without interrupting each other.

Let us know if you require any further questions or need help with your project :slight_smile:

1 Like

Michael thanks for the reply. To answer your first question would be Number 2! When i started i found out what would work quick and easy…but as you said im now needing to be more specific to achieve the goal i am chasing.

So here is my use case:

I have a project already where i make star ceiling panels. Example use is home theaters to create a night sky in a dark room. A room can have 4+ panels all daisy chained, but powered from the initial controller (ESP-32 currently). I have a sketch which gives the effect i want, which is not a problem. The current effect is select colours i have chosen.

What i am trying to make work now, is to have more than 1 selection of colours, example i may want it to be plain white. Or, i may want to have the option of multiple colour choices. To do this i need to have the right controller in the smallest package, then have the ability to activate 1 selection at a time.

I hope this gives more specific information, what would you recommend?

2 Likes

Michael, Thankyou for your suggestion i will have a further look at this tonight!

3 Likes

Hi Michael, i had a look at the RP2040-Zero. It does not mention, that i saw, compatible flashing with Arduino. Is this possible? Size wise and cost it looks like a great alternative otherwise. Is there any other aspect of this that you can see would be a roadblock? Cheers.

1 Like

There would usually be no need to run two separate sketches just because you want two different patterns. You could create just one sketch that selects the pattern to use from a table of different patterns, and if you code it carefully the number of different patterns would be limited only by available memory.

For this task you could go with a much simpler chip. In the ESP range this is about as simple as it gets:

Despite the small size it is quite capable of running a light show, with the pattern selected using an app on the mobile phone. Note that there is a small investment in a programmer to get started, but if you are making more than a few panels then the separate programmer turns out to cost much less than paying for programming facilities on each module.

1 Like

Jeff,

Thanks for that response. Yes i do realise i will need to engage a programmer to assist obtain the end goal i am chasing. Could this be you?

I just purchased some of the RP2040-zero michael recommended above, will they still be capable?

1 Like

From your description it seems you need only a few GPIO pins and, for future expansion, WiFi or Bluetooth capability. That requirement would cover almost everything except the original Arduino modules. I was pointing out one of the smallest and simplest ESP modules, which is fully compatible with what you currently have. But in fact there are many more options, including the RP2040 models, or any of the Pi range. If you are currently using a ESP I would recommend sticking with something from that family, as that would minimize the effort involved in migrating. But it all depends on the detail of what you are trying to do and the resources you have available.

3 Likes

Thanks again Jeff

Are you a programmer that could help me? Happy to take the conversation further :+1:

2 Likes

The forum is available to you for anyone to answer whatever questions you have about your project. Just post the bit of code that is giving you trouble with a good description of what it is supposed to do and what it is doing wrong, and I’m sure someone will jump in and offer advice.

3 Likes

Hi Martin,

The RP2040 Zero can absolutely be programmed using the Arduino IDE, you just need to add the board in board manager then select the appropriate one.

2 Likes

A suggestion for (2). You create some sort of UI (e.g. some buttons) and later develop a WWW page you connect to over WiFi.

Button 1 chooses colour 1
Button 2 chooses colour 2
Button 3 chooses a different effect, e.g. random colours
Button 4 chooses another effect, e.g. moving lights

in your code this uses a ‘case’ statement that calls (as separate functions) the code that would have been in the ‘main’ part of your different Sketches.
Dave

1 Like

Thanks for the feedback since i last checked.

Here is the arduino sketch im using.

void loop() {
int q;
for (q = 0; q < 7; q++) {
if (millis() > myNeoTimers[q]) {
if(myNeoSettings[q][0] < 0){//light is out so ready to start a new cycle

    //first select a colour for this neopixel
    
    //this gives a white/yellow/blue effect
    //add extra case statements and increase random max to add more fixed colours
    switch(random(4)){
        case 1://Yellow
          myNeoSettings[q][myRed] = 100;
          myNeoSettings[q][myGreen] = 100; 
          myNeoSettings[q][myBlue] = 0;
          break;
        case 2://Light Blue
          myNeoSettings[q][myRed] = 0;
          myNeoSettings[q][myGreen] = 100; 
          myNeoSettings[q][myBlue] = 100;
          break;
        case 3://Pink
          myNeoSettings[q][myRed] = 100;
          myNeoSettings[q][myGreen] = 50; 
          myNeoSettings[q][myBlue] = 100;
          break;
        default://Bright white
          myNeoSettings[q][myRed] = 255;
          myNeoSettings[q][myGreen] = 255; 
          myNeoSettings[q][myBlue] = 255;
          break;
       }
       
      
      //This will select random colours
      /*
      myNeoSettings[q][myRed] = random(256);
      myNeoSettings[q][myGreen] = random(256); 
      myNeoSettings[q][myBlue] = random(256);
      */

       
       myNeoSettings[q][lightDir] = 1;//as light is out we want it to increase in brightness
       myNeoSettings[q][lightState] = 1;//give the light a brightness value
  }
  if(myNeoSettings[q][0] == 256){//light maxxed so needs to start to turn off
    myNeoSettings[q][lightDir] = 0; //tell system this pixel will be getting dimmer 
    myNeoSettings[q][lightState] = 255;//give the light a brightness value
  }
    
  //this section deals with setting the led brightness value and resetting the millis timer
  
  //get the correct values for the RGB and set the neopixel to is.
  pixels.setPixelColor(q, colourState(myNeoSettings[q][myRed],myNeoSettings[q][lightState]), colourState(myNeoSettings[q][myGreen],myNeoSettings[q][lightState]), colourState(myNeoSettings[q][myBlue],myNeoSettings[q][lightState]));
  pixels.show();
  //increase or decrease the lightState depending if getting brighte or dimmer.
  if(myNeoSettings[q][lightDir] > 0){//getting brighter
    myNeoSettings[q][lightState]++;  
  }else{//dimming
    myNeoSettings[q][lightState]--;  
  }
  if (myNeoSettings[q][lightState] < 0 || myNeoSettings[q][lightState] > 255) {
    //at max state so longer value
    // myNeoTimers[q] = millis() + random(200, 4000);//0.2 - 4 seconds
    myNeoTimers[q] = millis() + random(50, 100);//0.1 - 1 seconds
  } else { //increasing or decreasing in value so short value
  if (random(250) < 2) { //lower this number to speed up flicker
  if (myNeoSettings[q][lightDir] > 0) {
     myNeoSettings[q][lightDir] = 0;
  } else {
     myNeoSettings[q][lightDir] = 1;
   }
  }
    myNeoTimers[q] = millis() + random(40);//0 - 20 milliseconds
  }
}

}
}

This is for a set colour appearance, but as mentioned i would like to have more than 1 and make the options selectable either by remote or by using the wifi and an app as such. This is where i need help.

Hi Martin,

If you’re still using the ESP32 from the start of the thread and are looking for something like that I have the perfect thing for you. WLED!

It will give you a browser based UI, as well as an app that you can use, it will give you control as to whether the LEDs are on or off, as well as allowing you to select solid colours, as well as giving you a variety of prebuilt patterns.

It will also give you scope for audio syncing later on as well as IR remote control.

And possibly the best part, if you decide you want a second device they can sync across your local network and be controlled from one interface.

We have a really detailed write up on how to install it (its refreshingly easy) available here WLED Guide

1 Like

Wifi will be easier, but do you have a local network to connect to?

You can start by following this example and simply handling an ‘On/Off’ application. Once you have that running you can have a go at integrating that code into your existing sketch. The step after that would be to change on and off to colour 1 and colour 2 (which is actually the easy bit). Then you can add as many buttons and colours as you want.
ESP8266 Arduino WiFi Web Server LED on off control | Circuits4you.com

Note that there are many similar examples which you can look at, but they will all do things slightly differently so be careful about trying to reconcile them. But if you find one that seems to explain things better then by all means try it out. There are also plenty of UTube videos but I don’t recommend trying to build a project using a video - much better to have a step-by-step guide in front of you.

1 Like

Hi Dan,

Thanks for the feedback. Yes i already use WLED around the house and have looked into this before. The issue i have is being able to utilise the arduino sketch i currently use for the required effect.

Thanks Jeff, i will read up and try this!