Disclaimer: So I am new to writing code as well as electronics hardware (background is machining and welding stuff) so be gentle. I have spent considerable time combing the forum and googling. None of the code is mine, I’m mostly finding different people doing similar things to what I want to do and trying to mash them together… so thanks to everyone who uploads their own code for me to butcher.
Goal: The goal I am trying to achieve is the use of the ESP to manually throw a switch with a servo, controlled by the blynk app. This is for a buddy to remotely turn on his coffee machine.
Hardware: Running an Adafruit HUZZAH ESP8266 breakout board flashed with the arduino package. I am powering it through an arduino connected to a battery to attempt to isolate any electrical issues I may have been causing it by powering it through USB power.
Blynk: using a slider to attempt to control the servo movement. Slider is set to the correct pin and from 0 to 255 using PWM (wavy line with circle around it…?)
Problem: Just like the subj. The servo reacts to the slider I am using to control it thorough the blynk app, but it does it erratically, and I cant figure out a rhyme or reason to it. It will respond to extremes, but not gradually as I would expect a slider to make it work…
Any feedback is much appreciated!
Current code that I am running.:
/*
* some of this info came from: https://github.com/blynkkk/blynk-library/blob/master/examples/GettingStarted/Servo/Servo.ino
*/
//#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <BlynkApiArduino.h>
#include <WidgetLCD.h>
#include <WidgetLED.h>
#include <SPI.h>
#include <Servo.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "mykeyhere";
Servo servo;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "SSIDhere", "PWhere");
servo.attach(5);
}
BLYNK_WRITE(V3)
{
servo.write(param.asInt());
}
void loop()
{
Blynk.run();
}
I don’t know if this thread is still relevant, but I had a similar situation and it had to do with the control signal level from the esp8266 which is powered by 3.3 Volts… The control signal from the esp had a peak voltage of about 3 volts and the servo I was using (TowerPro MG946R) required a control signal of 4.8 volts minimum. It turned out that the servo would react to the signal from the esp, but it was very erratic and sporadic. Maybe this is what you are experiencing also. The solution is to translate the control signal to 5 volts through a level shifter. Hope this helps.
if all you’re trying to do is turn on the coffee pot, it would be easier and less costly to just sever the switch and use a MOSFET as an electrical switch rather than trying to move a mechanical switch.