Hello,

I hope someone can help because I am really confused :(

I have some code that I am ruining on an Arduino to start a race - Take your marks, Get set, Go - type of thing and some LED's that act in a very similar way to the light tree for drag racing. Everything is working ok at the moment, on one Arduino board, with wires connecting the peripherals. However, I would like to separate the lightshow using 2 ESP-32's and ESP-NOW, so that I can go wireless on the lights.

Currently, I have a couple of .h and .cpp files to handle both the sequencing and the FastLED's. What I am trying to achieve is to have the ESP-32 receiver as a dumb node that just receives the serial output data that would normally go to the defined PIN via ESP-NOW.

The documentation for ESP-NOW shows using a typedef struct{} to transmit the data and if I use something like -

typedef struct RGB_steps {
  byte Red;
  byte Green;
  byte Blue;
  byte steps[NUMSTEPS];
} RGB_steps;

and

for (led=0; led<NUMLEDS; led++) {
    if (seq[led].steps[p] == 1)
        neopixel.setPixelColor(led, seq[led].Red, seq[led].Green, seq[led].Blue);
    else
        neopixel.setPixelColor(led, 0, 0, 0);        
}

Including everything in the main.ino, I am able to populate the struct for transition (taken from the example Click Here). This seems to work by sending the individual colors to each LED along with the sequence pattern.

However, I can't seem to get my switch case() to a struct for some reason, I hope it's just me being an idiot :) The sequence.cpp is

Sequence::Sequence(LightShow* lightshowOb) {
  lightshow = lightshowOb;
}

void Sequence::begin_sequence() {
  uint8_t step = 0;
  uint32_t offset;
  uint32_t now = 0;
  int8_t val;

  offset = millis();

  while(step < count) {

    // a tight loop that waits the target amount of time
    while (target[step] > now) {
      now = millis() - offset;
    }

    for (int i=0; i<3; i++){
      val = seq[step][i];
      // -1 means ignore

      if (val >= 0){
        // 0 = lighSHOW
        if (i == 0){
          lightshow->light_set(val);
        }

      }
    }
    step++;
  }
}

And the lightshow.cpp is

void LightShow::light_set(int step) {
  serial_print_val("Set LED ", step);
  #if (LIGHT_SHOW_STRIP)

      int position = 4-step;    // bottom of strip up
      // int position = step-1; // top of strip down

      switch (step) {       
        case 1:
          // set team Red LEDs
          for(int i=0;i<team_size;i++) {
            leds[i+position*team_size] = CRGB::Red;
          }
          break; 
        case 2:
          // set team Orange LEDs
          for(int i=0;i<team_size;i++) {
            leds[i+position*team_size] = CRGB::Yellow;
          }
          break;
        case 3:
          // set 2nd team Orange LEDs 
          for(int i=0;i<team_size;i++) {
            leds[i+position*team_size] = CRGB::Orange;
          }
          break;
        case 4:
          //set team Green LEDs
          for(int i=0;i<team_size;i++) {
            leds[i+position*team_size] = CRGB::Green;
          }
          break;
        default:
          led_reset();
      }
  FastLED.show();
  #endif
}

When I run the code on a single board and view the serial monitor it reads

Set LED 1
Set LED 2
Set LED 3
Set LED 4

with the sequence and timing attached. What is confusing me is that in the example above that I am able to get working, I am just sending individual colors to individual LED's whereas, my code assigns a color to a group of LED's based on team_size. The typedef struct {} above doesn't seem to work as it is just single colors or am I missing something? Basically, I am just trying to send the serial output data that would normally go the the defined output pin over ESP-NOW.

Any help would be greatly appreciated.

Thanks

Hello rproffitt,

Thank you for the reply. I'm sorry for the delayed response but I only came across my post whilst searching for a solution, I was having problems posting to Daniweb and was unaware it had beed put on the forum.

The RGB_steps are allocated in a seperate sequence tab and passed to the LightShow.cpp and the structure I mentioned is from a seperate sketch that I used as a proof of conceot type of thing. My sketch works as it sould until I try to send the serial data using ESP-NOW.

I think I am overcomplicating the explination of what it is I am trying to acheive and it's getting confusing. All that I am trying to do is use the data that would normally be sent to a defined GPIO when I call FastLED.show(); and send that data to a slave ESP-32 using the ESP-NOW protocol.

Regards

Me? Decades of embedded design and code. But I do not have your board/system to look at so moving on with my current thought.

  1. I'm guessing the post above is incomplete code. That's why I can't find this or that. Moving on.
  2. Here's where I'm going next:
    You write "send that data to a slave ESP-32 using the ESP-NOW protocol." Do you have any communication working?

Sometimes I find the serial comms to be an embedded worker's undoing. There are tutorials about ESP NOW so I'll end with a search for some.
https://duckduckgo.com/?q=send+that+data+to+a+slave+ESP-32+using+the+ESP-NOW+protocol.

Hi rproffitt,

Thank you once again for the reply. However, I don't understand your opening as I didn't ask who you were or what your experience was. I would find that extremely rude when asking someone for help!

To address some of your other points, I stated in the first post that I had been able to send FastLED data over ESP-NOW, however, that was using a struct{} and individual RGB values and everything in the main.ino file. Also, I only included the code snippets that I thought relevant to help find a solution. It is entirely possible that I explained my problems poorly and that I hadn't included enough code to be useful, for that you have my sincerest apologies. I have used the link you provided and the first dozen pages (at Least), show that I have visited every link. Please don't assume that someone hasn't done any research before reaching out for assistance.

Just to reiterate, my issues are not with the sketch (works perfectly), nor with transmitting individual color values using ESP-NOW (I was able to do that), but rather the fact that I have a sketch with multiple tabs (classes/functions), and I am finding it difficult to send data from another tab via ESP-NOW.

The simplest way I can explain what I am trying to acheive is that instead of FastLED.show() activating the #define DATA_PIN I would like it to go to ESP-NOW. Though I have absolutely no idea if this is even possible. I will have to do some more research before trying the nRF24L01 route.

Thank you again for taking the time to reply.

Regards

Maybe I'm not understanding the problem. I took this system was the usual two or more board system with some serial comms to send messages around.

But then you write "I am finding it difficult to send data from another tab via ESP-NOW."

Hold up, I wonder if you are running the code on some PC on two boards and want the code development IDE to send data across a tab?
Something's not jiving here.

My usual system in the end doesn't use any PC as the code is installed on the boards, the boards are connected and the PC is no longer connected. Sometimes I have to pull out the oscilloscope to check if the comms are good.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.