Problem with hardware local server connection

Hello all,

I know there is a lot of topics with connection problems and i read all of them but i don`t find a solution. I use a local Blynk server ver.: 0.3.10 and library ver.: 0.5.4 and when i start the server i can connect with admin page also with the app. But i have a problem with hardware connection only on local server on cloud my program works well. First i try with server on Windows 10 then i install Ubuntu 18.4 with the same result i check opened ports also check the incoming traffic the NodeMcu tries to connect but without success. If you can help me this will be great :slight_smile:

I will add a link to google photos.

https://photos.app.goo.gl/KpXdJrpTQi7cqNds8

Call me jaded, but that statement always raises my “I didn’t really look, but since you will tell me to anyhow, I will say I did” suspicions :stuck_out_tongue_winking_eye: Particularly with only 16 min read time in your stats.

Each issue is unique… the process of searching and reading is not to find the “exact” same issue/answer (rare) but to assist yourself in the troubleshooting methods.

For example, based on one of your pics (we also prefer them actually posted here) you are getting a repeated NTP time sync… which to me indicates that something is processing the time sync, then connecting, then possibly rebooting (EDIT - looping) every 5 seconds. Thus the question is what else is in your code… Therefor, you need to show us the actual code (properly formatted for forum viewing), not another screenshot or link please.

Also enabling Debug will give you more info in the Serial monitor.

1 Like

This is one of those “I don’t know what is going on, but IT DOESN’T WORK!.. Thus I’m reporting error…”. For now we must assume it is “your fault” somewhere… A lot of local servers are spread around the world already (among them there is my too :stuck_out_tongue: ) and I can’t confirm any connection issue. Yes, from time to time there are some “errors and issues”, but this is not the case now.

Hello again and thanks for the quick answers. First to say I apologize for the unprofessional question :slight_smile: but everyone is wrong. And now that I started answering, I reviewed the code again and noticed the mistake (after a few days of trying). I just saw that I’m trying to use: “BlynkSimpleEsp8266_SSL.x”. I apologize once again for the stupid topic. Here is the entire code for the program:

/*************************************************************
Control the LED lamp with Blynk and ultrasonic distance
 *************************************************************/
#define BLYNK_PRINT Serial // Defines the object that is used for printing
//#define BLYNK_DEBUG        // Optional, this enables more detailed prints

#include <ESP8266WiFi.h>
//#include <BlynkSimpleEsp8266_SSL.h> // Before that i use this
#include <BlynkSimpleEsp8266.h>


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "My token";
char server[] = "172.16.1.137";
int port = 8080;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SSID";
char pass[] = "PASS";

long duration, distance;
bool ledState = HIGH;
bool firstBoot = true;
int distanceSet = 0;

unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 200;           // interval in milliseconds
unsigned long antiShortCicle = 0;        // delay between two separate LED switch

void setup()
{
  // Debug console
  Serial.begin(9600);

  //Blynk.config(server, port);
  Blynk.begin(auth, ssid, pass, server, port);



  pinMode(D1, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D2, INPUT);
}

BLYNK_WRITE(V0) { // Button Widget function
  digitalWrite(D1, param.asInt()); // take the state of the Button and send it to the pin

  if (param.asInt() == 0) {
    Blynk.virtualWrite(V1, 0); // Send timer state back to button to update it.
  }
  else {
    Blynk.virtualWrite(V1, 1023); // Send timer state back to button to update it.
  }
  ledState = param.asInt();
}

BLYNK_WRITE(V1) { // Timer Widget function
  int dimmer = param.asInt();

  analogWriteFreq(20000);
  analogWrite(D1, dimmer); // take the state of the Timer and send it to the pin

  if (dimmer > 0) {
    Blynk.virtualWrite(V0, HIGH); // Send timer state back to button to update it.
    ledState = HIGH;
  }
  else {
    Blynk.virtualWrite(V0, LOW); // Send timer state back to button to update it.
    ledState = LOW;
  }
}

BLYNK_WRITE(V3) { // Button Widget function

  int dimmer = param.asInt();
}

void FirstBootUp() {
  digitalWrite(D1, LOW); // Swith off the LED at startup
  Blynk.virtualWrite(V0, LOW); // Send ledState button to update it.
  Blynk.virtualWrite(V1, 0); // Send ledState to button to update it.
  firstBoot = false;
}

void DistanceMessure() {
  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  digitalWrite(D3, LOW);
  delayMicroseconds(5);
  digitalWrite(D3, HIGH);
  delayMicroseconds(10);
  digitalWrite(D3, LOW);

  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(D2, INPUT);
  duration = pulseIn(D2, HIGH);

  // convert the time into a distance
  distance = (duration / 2) / 29.1;
}

void SwitchLed() {
  while (distance < 20) {

    DistanceMessure();

    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis >= interval) {
      // save the last time you turn ON the LED

      // if the LED is off turn it on and vice-versa:
      if (ledState == LOW) {
        ledState = HIGH;
        Blynk.virtualWrite(V1, 1023); // Send ledState to button to update it.
        Blynk.virtualWrite(V0, HIGH); // Send ledState button to update it.
      } else {
        ledState = LOW;
        Blynk.virtualWrite(V1, 0); // Send ledState to button to update it.
        Blynk.virtualWrite(V0, LOW); // Send ledState button to update it.
      }
      digitalWrite(D1, ledState);
      antiShortCicle = millis() + 2000;
      return;
    }
  }
}

void loop()
{
  if (!Blynk.connected()) {
    Blynk.connect();
  }

  if (millis() > 10000 && firstBoot == true) {
    FirstBootUp();
  }

  DistanceMessure();

  if (distance < 15) {
    if (antiShortCicle < millis()) {
      previousMillis = millis();
      SwitchLed();
    }
  }

  Blynk.run();
}

clean the loop :stuck_out_tongue: