Nodemcu online but servo not moving

Is it just me or is the stress relation to executing projects with blynk too much?

My nodemcu shows that it is online on my android app but the slider i added does not move my servo at all.
Even the value display i setup on the app that should show the current position of the servo does not work show anything.

I’m even more confused why it shouldn’t work, considering that it is the same code @mjrovai provided in his servo control project.

#define SW_VERSION "ServoCtrlBlynk_V.1" 

/*NodeMCU */
#include <ESP8266WiFi.h>
char ssid [] = "<./>";
char pass [] = "1Firewall#@aadmin";

/* Blynk */
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth [] = "20a8d9a65af94697b21fa1f2db5cb2da"; // Servo Control Project // Servo Control Project

/* OLED */
#include "SSD1306Wire.h"
#include "Wire.h"
const int I2C_DISPLAY_ADDRESS = 0x3c;
const int SDA_PIN = 5;
const int SCL_PIN = 4;
SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN);

/* Servo */
#define servo1Pin D2
#include <Servo.h>
Servo servo1;

/* Initial pot reading and servo position set the position to neutral */
#define potPin A0
int potReading = 1023/2;
int servo1Angle = 90;

/* Reads slider in the Blynk app and writes the value to "potReading" variable */
BLYNK_WRITE(V2) 
{
  potReading = param.asInt();
}

/* Display servo position on Blynk app */
BLYNK_READ(V1) 
{
  Blynk.virtualWrite(V1, servo1Angle);
}

void setup () 
{
  Serial.begin(115200); 
  servo1.attach(servo1Pin);
  displaySetup();
  Blynk.begin(auth, ssid, pass);
}

void loop() 
{
  Blynk.run();
//  PotReading = analogRead(potPin);               // Read Analog data from potenciometer not used here
  servo1Angle = map(potReading, 0, 1023, 0, 180);  // Map the pot reading to an angle from 0 to 180 
  servo1.write(servo1Angle);                       // Move the servo to a position
  displayAngle();
  delay (200);
}

/* Initiate and display setup data on OLED */
void displaySetup()
{
  display.init();         // initialize display
  display.clear();        // Clear display
  display.display();      // Put data on display
}

/*  Display Servo position */
void displayAngle()
{
  display.clear();
  display.setFont(ArialMT_Plain_16);
  display.drawString(10, 0, "Servo Control");
  display.drawString(0, 45, "POSITION:" );
  display.setFont(ArialMT_Plain_24);
  display.drawString(80, 40, String(servo1Angle));
  display.display();
}

Just you according my experience with Blynk… no stress at all…:wink:…Did you check the example to use a servo with Blynk?

This should be the starting point to understand the way it works and be relaxed moving your servo…:blush:

1 Like

let me check that now…

can you point me in that direction kindly?

https://examples.blynk.cc/?board=NodeMCU&shield=ESP8266%20WiFi&example=GettingStarted%2FServo

Pete.

1 Like

That was helpful, Pete. I got it working. :smiley: Thanks.

:roll_eyes:

2 Likes

:rofl::rofl::rofl:

2 Likes

Seeing this in the void loop() all trying to run thousands of times a second, is causing me a bit of stress :stuck_out_tongue:

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-control-anything-with-blynk-app

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-display-any-sensor-data-in-blynk-app

I think we’ve just identified a new medical condition - Void Loop Stress Disorder.
Do you think we’ll get nominated for a Nobel Prize? :trophy:

Pete.

3 Likes