Hello, has anyone successfully interfaced a servo with blynk 2.0? i’ve tried both ESP32Servo and ServoESP32 libraries, but none of the two codes below seems to work… i’ve powered the circuit both from the computer and powerbank (separately), to no avail… the example codes from both libraries work though
servo → esp32
vcc → vin
data → gpio25
gnd → gnd
ServoESP32 code:
#define BLYNK_TEMPLATE_ID "REDACTED"
#define BLYNK_DEVICE_NAME "REDACTED"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WROVER_BOARD
//#define USE_TTGO_T7
#include "BlynkEdgent.h"
#include <Servo.h>
static const int servoPin = 25;
Servo myservo;
bool isFirstConnect = true;
BLYNK_CONNECTED()
{
//corrects the current state of the LEDs to the
//state of the virtual buttons
if (isFirstConnect)
{
Blynk.syncAll();
isFirstConnect = false;
}
}
BLYNK_WRITE(V7)
{
int servo_angle = param.asInt();
myservo.write(servo_angle);
Serial.println(servo_angle);
}
void setup()
{
Serial.begin(115200);
delay(100);
myservo.attach(servoPin, Servo::CHANNEL_NOT_ATTACHED, 0, 180, 480, 2400);
BlynkEdgent.begin();
}
void loop() {
BlynkEdgent.run();
}```
#define BLYNK_TEMPLATE_ID "REDACTED"
#define BLYNK_DEVICE_NAME "REDACTED"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WROVER_BOARD
//#define USE_TTGO_T7
#include "BlynkEdgent.h"
#include <ESP32Servo.h>
Servo myservo; // create servo object to control a servo
// 16 servo objects can be created on the ESP32
static const int servoPin = 25;
bool isFirstConnect = true;
BLYNK_CONNECTED()
{
//corrects the current state of the LEDs to the
//state of the virtual buttons
if (isFirstConnect)
{
Blynk.syncAll();
isFirstConnect = false;
}
}
BLYNK_WRITE(V7)
{
int servo_angle = param.asInt();
myservo.write(servo_angle);
Serial.println(servo_angle);
}
void setup()
{
Serial.begin(115200);
delay(100);
// Allow allocation of all timers
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
myservo.setPeriodHertz(50); // standard 50 hz servo
myservo.attach(servoPin, 480, 2400); // attaches the servo on pin 18 to the servo object
// using default min/max of 1000us and 2000us
// different servos may require different min/max settings
// for an accurate 0 to 180 sweep
BlynkEdgent.begin();
}
void loop() {
BlynkEdgent.run();
}
i’ve deliberately not include my template id and device name for this post, but i do make sure that those are included in both of the codes that i’ve posted here when i upload… yet nothing happens to the servo after uploading when i try to change the angle using slider widget
Post your code exactly as uploaded, but replace the temp[late ID and Device Name with the word “REDACTED”.
This tells us nothing!
Have you successfully provisioned the device in the app, and is it showing as being online?
What does your serial monitor show?
Are you seeing the serial prints of the servo angle when you move whatever widget is connected to V7?
If you want help then you need to explain in detail where exactly the issue lies.