Sparkfun ESP32 Thing disconnects and connects frequently

This scetch is running without any problem when I disable this line: // ledcWrite(ledChannel, ledout);

uint32_t freq = 5000;
uint8_t ledChannel = 1;
uint8_t resolution = 10;
uint8_t LED_Pin = 15;

ledcAttachPin(LED_Pin, ledChannel);
ledcSetup(ledChannel, freq, resolution);

BLYNK_WRITE(V15) // 
{
  int ledout = param.asInt();
//  ledcWrite(ledChannel, ledout);
  delay (7);
}

But ESP32 connects and disconnect frequently when I comment this line out.
Any idea?
Regards
Hanno

Aside from this NOT being a Blynk related issue… you are contradicting yourself…

Which is it? works with or without that line :stuck_out_tongue:

My guess is that the ledcWrite function that you’re using to simulate Analog.write is a blocking function that’s causing Blynk to be starved of processor time, resulting in the disconnects.

Pete.

It works without this line!
Hanno

@PeteKnight that command should work fine, even with Blynk. I have used it in this example for both LED and servo.

@Hanno make sure you have all the correct supporting libraries and any setup… try different channels, resolution and frequency.

@Gunner, I see that you used 8 bit resolution, whereas @Hanno is using 10 bit. I wonder if that makes a difference?

Pete.

I used different resolution depending on application. 8 bit is all needed for LED (0-255)

@Hanno NOTE, the higher the bitrate you set, the lower the frequency must be (stated, but unclarified in the various documents I have read)… perhaps that is your issue.

Reducing frequency doesn’t help
and changing resolution to 8 bit didn’t solve the problem.
tomorrow I’ll try different channels.
Hanno

Try a different sketch as well.

is it possible that use of function BlynkTimer cause this problem?

As I said, try other sketches… it could be something in your current one?? I showed a link above that works just fine with BlynkTimer and a couple of differing settings for two channels.

I tried your sample scetch but got same problem.
I’m using Sparkfun ESP32 Thing.
Did you check your scetch on this device?
Hanno

On a SparkFun ESPThing? No, I used a Wemos Lolin32

Make sure you are using the latest updates for the ESP32 Arduino Core.

This line made the problem:

#define BLYNK_PRINT Serial

after deleting this line everthing is working fine.

That also doesn’t make sense as I successfully have BLYNK_PRINT running on my ESP32 testbench, along with the same Servo and RGB-LED PWM control commands… plus SPI for a display which is showing the BLYNK_PRINT results… no problems.

Have you confirmed latest Arduino Core?

Do you have something plugged into the RX/TX pins??

Don’t know why but everthing is working fine now.
Thanks for your help.
Hanno