My NodeMCU project is not connecting to new server

  1. Add details :
    • Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
    • Smartphone OS (iOS or Android) + version
    • Blynk server or local server
    • Blynk Library version

NodeMCU 0.9, ESP8266, BLYNK 1.1.0 packages, Android mobile and windows laptop.

#define BLYNK_TEMPLATE_ID "TMPL8Lro23R4"
#define BLYNK_DEVICE_NAME "Plant Watering System"

#define BLYNK_AUTH_TOKEN "kCAsn7BHLiOQR39b3siLn8cdVq6QIiD1"

#define BLYNK_PRINT Serial

#include <OneWire.h>

#include <SPI.h>

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <DHT.h>

#include <DallasTemperature.h>

#define ONE_WIRE_BUS D2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

char auth[] ="kCAsn7BHLiOQR39b3siLn8cdVq6QIiD1";

char ssid[] = "Atomix";

char pass[] = "plantwateringsystem";

#define DHTPIN 2

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

SimpleTimer timer;

void sendSensor()

{

float h = dht.readHumidity();

float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {

Serial.println("Failed to read from DHT sensor!");

return;

}

Blynk.virtualWrite(V5, h); //V5 is for Humidity

Blynk.virtualWrite(V6, t); //V6 is for Temperature

}

void setup()

{

Serial.begin(9600);

dht.begin();

timer.setInterval(1000L, sendSensor);

Blynk.begin(auth, ssid, pass);

sensors.begin();

}

int sensor=0;

int output=0;

void sendTemps()

{

sensor=analogRead(A0);

output=(145-map(sensor,0,1023,0,100)); //in place 145 there is 100(it change with the change in sensor)

delay(1000);

sensors.requestTemperatures();

float temp = sensors.getTempCByIndex(0);

Serial.println(temp);

Serial.print("moisture = ");

Serial.print(output);

Serial.println("%");

Blynk.virtualWrite(V1, temp);

Blynk.virtualWrite(V2,output);

delay(1000);

}

void loop()

{

Blynk.run();

timer.run();

sendTemps();

}

So the code above was for a plant watering system project, i did that after watching some old tutorials as i’m very new to IoT and Blynk as well.
In my serial monitor its showing like this …

[6303] Connected to WiFi
[6303] IP: xxx.xx.xx.xx
[6303] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on ESP8266

 #StandWithUkraine    https://bit.ly/swua


[6429] Connecting to blynk-cloud.com:80
[7600] Invalid auth token
[24428] Connecting to blynk-cloud.com:80
[24972] Invalid auth token
[42428] Connecting to blynk-cloud.com:80
[42996] Invalid auth token
[60428] Connecting to blynk-cloud.com:80
[61016] Invalid auth token
[78428] Connecting to blynk-cloud.com:80
[78833] Invalid auth token

Bhavesh

I have seen many posts regarding this issue and tried them, but none of them solved this issue.

This is the Blynk Legacy server.
You haven’t bothered to fill-in any of the requested information, just kept the questions without any answers, so it’s difficult to tell if you are usingLegacy or not, but these lines suggest you are using Blynk IoT…

But, you’re missing the Template ID information, and without that the compiler will assume that it’s a Legacy sketch.

More info here…

Pete.

I’m extremely sorry ,
actually when i was copying the code it didn’t copy completely i have edited that as soon as i saw it. And the template ID was already present in the code

I have already referred to that , and i followed it thoroughly

I’m sorry about that.
Also yes I’m using Blynk IoT here but its still connecting to the blynk legacy software from the beginning. I have changed the code multiple times yet its not connecting to blynk 2.0

Hi @PeteKnight , would you suggest something regarding this issue, I’m kind of in a hurry regarding this. You suddenly went offline so i wanted to know if there’s a fix for this which can resolve asap. I’m sorry for rushing you.
Thanks
Bhavesh

Hi @PeteKnight , I have tried changing the network connection of my esp. and now
the serial monitor is spamming this message…

[42431] Connecting to blynk-cloud.com:80
[42668] Invalid auth token
[4290] Connected to WiFi
[4290] IP: 192.168.71.82
[4290] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on ESP8266

 #StandWithUkraine    https://bit.ly/swua


[4416] Connecting to 192.168.1.100
[10610] Connecting to 192.168.1.100
[16795] Connecting to 192.168.1.100
[23009] Connecting to 192.168.1.100
[29222] Connecting to 192.168.1.100
[35433] Connecting to 192.168.1.100

Firstly, my esp was connected to my mobile. And it was using mobile data. but i have later changed it to a wifi connection and now i’m getting this.

Well that’s not going to work unless you have a Blynk IoT server sitting on your home network at 192.168.1.100 - which you obviously don’t have.

Stop making changes that you don’t understand and go back to using Blynk.begin(auth, ssid, pass);

If the sketch you posted did actually create the serial output you posted in post #1 then the issue can only relate to the position of the #define BLYNK_TEMPLATE_ID and #define BLYNK_DEVICE_NAME lines of code within your sketch.

Your sketch has multiple other issues - duplicated auth token, use of SimpleTimer, use of delays and calling sendTemps(); from your void loop, all of which will need to be fixed, but you need to start by resolving the fact that it’s trying to connect to the Legacy server.

Pete.

I have already said that i have seen your thread regarding it. The one you posted. and the positions of those lines are correct according to what you have told me.

That’s why i’m here asking you. I can’t resolve it.

I didn’t get this one, what’s with duplicated auth token ?

Bhavesh.

The second line should read:

char auth[] = BLYNK_AUTH_TOKEN;

The only reasons why the compiler would revert to blynk-cloud.com is if:

  1. You’re using an earlier Blynk library, but your serial output says you are using v1.1.0
  2. You are hard-coding this URL in the Blynk.begin command, but your sketch says that you aren’t.
  3. The #define BLYNK_TEMPLATE_ID and #define BLYNK_DEVICE_NAME lines are in the wrong place in your sketch.

The other possibility is that the serial output you posted in post #1 isn’t produced by the code you posted in post #1

Pete.

Okay !! Got it.

Unfortunately it is produced by the code …