Blynk app Showing device offline using in local server works fine with blynk default parameters fine as worked with other program

When using blynk default the data is seen properly in app but the app shows device offline when using my own local server.I have added the auth code and using Blynk.begin(auth, ssid, pass, “mydomain”, port number); the device is showing it’s getting the IP address in Serial monitor but the app shows it as offline

Sounds like you have a problem… :stuck_out_tongue:

Any more info so we don’t have to guess? Hardware? Sketch? IP or actual hosted address? Port forwarding? Running hardware inside or outside your network? How about the App, in or out? Colour of your socks (optional)… etc.

I am using a temperature sensor to measure temperature can very well see the readings in the monitor,have logged in using my local server details but only thing is app shows device offline


/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = "my token";

/* WiFi credentials */
char ssid[] = "my wifi ssid";
char pass[] = "pass";

/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;
char blynk_token[34];

  
void setup() 
{
  Serial.begin(115200);
  WiFiManager wifiManager;
  wifiManager.autoConnect();
  Blynk.begin(auth, ssid, pass, "my-domain", my server port);
  DS18B20.begin();
  timer.setInterval(1000L, getSendData);
  
}

void loop() 
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
  if(temp < 23){
  Blynk.notify("Home Aquarium Alert - Temperature Reaching Below 23 C!");
}
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  Serial.println(temp);
  Blynk.virtualWrite(10, temp); //virtual pin V10
}

I had to fix your post… please read the Welcome Topic and see how proper formatting is needed for any future posting of code.

I am really grateful for that and will surely take care in future but what’s causing the error and device being offline in app

Based on what you have supplied, possibly the wrong IP and/or port?

You also have a lot going on with the added webserver and wifi manager… have you tried just a basic sketch first?

Blynk hasn’t required this isince Library ver 0.4.7

And even if you did get online, this command sitting in the void loop() just waiting to run thousands of times a second would not allow you to stay online.

image

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

I modified the code but still the app is offline the server address works fine in another program developed but don’t know what’s causing issue here making the app offline


/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = "my token";

/* WiFi credentials */
char ssid[] = "my ssid";
char pass[] = "my ssid pass";

/* TIMER */
SimpleTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;
char blynk_token[34];

  
void setup() 
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, "my domain", my domain port number);
  DS18B20.begin();
  timer.setInterval(1000L, getSendData);
  
}

void loop() 
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  Serial.println(temp);
  Blynk.virtualWrite(10, temp); //virtual pin V10
}

Just an update it seems the code works perfectly fine when I use blynk default login and data can be seen in app but issue with local server connectivity and to mention server is fine as other program I have run on using the url and port as specified in local server

I am facing issue as the app is showing device offline I am using following code
Blynk.begin(auth,ssid,pass,“my domain”,my port); but the same code connects to blynk cloud perfectly well showing code is fine where I used Blynk.begin(auth,ssid,pass) also another program connects perfectly well to my local server developed in another computer …Kindly guide how to fix

Please don’t open new topics for same issue… I moved your last post back here.

If it works on the Cloud, then the issue is something on your script setup (re: the Local IP/port), Your Local Server itself or your network setup… not sure how we can help there, particularly with the very limited info you have provided.

The issue is the program is same only while using cloud I am using blynk.begin(auth,ssid,pass); and while on local server blynk.begin(auth,ssid,pass,“my domain”,my domain port); local server is perfectly working as other program developed in other has successfully connected to the server…let me know if any other info.Thanks a lot :slight_smile:

Why keep repeating useless info?

What is the exact IP and port you are using (if it is on the LAN side, it is of no use to anyone else, thus safe to show).

Is it the proper IP/port for your Local Server (It should be port 8080)

What versions are you using for everything,

And so on.

If you have some other script that properly connects, then simply copy what it is using.

Have you correctly configured the app to use your local server and the appropriate port, Andrade you using an Auth code in your sketch that was generated from your local server rather than the cloud server?

Pete.

It’s a public domain,IP is 8088(custom port which I have set) same command used with other computer created program is connecting the app to the remote private server but here the app won’t connect but the same code is fine as said earlier it works with blynk cloud

Blynk app-2.27.0
Server- 0.41.0

Yes I have checked the auth code is fine as I know and created progom working well on another pc

Then short of you sharing private info (not recommended) we can’t help

None of this makes sense, to me at least :stuck_out_tongue_winking_eye: What command? What computer? Are you discussing the App not connecting or the device not connecting? For that matter, why is the device connecting via a public address anyhow? Usually they are inside the same network as the Local Server.

Your explanations are no better now than at the beginning.

Cloud and Local are totally different servers with totally different data, Auth, IP, ports, etc… , so “it works with one but not other” is (mostly) totally irrelevant

I think there is a bit of confusion I’ll explain the same hope you understand same as from beginning I am mentioning the Blynk app present in android shows device offline, I have run blynk based project and ran perfectly fine whilch I told earlier and facing this strange issue in a different computer

  • It’s in public domain means I am not using it on local server but hosted it in cloud which I guess is pretty common thing if you need the domain I’ll provide but I don’t think it has something to do with actual cause as informed that the same private server domain is working fine with other program developed with other computer using same code Blynk.begin(auth,ssid,pass,“my public domain”,8088); also the same program works fine when connected to blynk cloud using Blynk.begin(auth,ssid,pass); here I’ll expect I am updating relevant AUTH Token and switching to private server/blynk cloud login when needed

  • Command was intended to make the query bit short…it simply means I am using code Blynk.begin(auth,ssid,pass,“my public domain”,8088);

You keep referring to “computer”, but I don’t see where this fits in to your issue. Are you running an Android emulator on this computer, or is it the computer used to compile your code and upload to your MCU?

Pete.

I mean I am running arduino IDE that’s what I mean,in another computer used same code Blynk.begin(auth, ssid, pass, “mydomain”, port number); to connect to my private server and it worked don’t know why the same code when I am running now in different computer is getting uploaded but the app shows device offline…blynk cloud on the same code works fine using Blynk.begin(auth,ssid,pass);

Now I’m totally confused!

Pete.

1 Like