Legacy app not connecting to local server

I’m am trying to setup a local legacy server to keep my apps work for a little bit longer while I figure out how to move forward. The apps worked fine with blynk cloud but I can’t get them to connect with the local server I just set up. The local server is running and I can access the admin webpage. I was able to clone my apps and bring them in successfully. I updated the code in my particle photon with the new auth code and added the ip and port but the legacy blynk apps show my hardware as offline.

It could be that I didn’t update my photon code correctly as I wasn’t able to find a clear example for that.

image

I also tried adding my ssid and password because I saw that in examples but it wasn’t needed for it to work before and it is connecting to my wifi through the particle side of things. I tried port 9443 and also port 8080 in my code.

Any ideas as to what could be keeping my hardware from connecting to my local server?

What does your serial monitor show?

We’re you using a Blynk.begin command before, or Blynk.config and Blynk.connect?

Pete.

I check and report back. I haven’t used that in a long time.

Currently struggling to get the serial monitor working. Will keep trying.

I was using Blynk.begin before:
Blynk.begin(auth);

Just added the IP address and port thinking that was all it needed to find the local server.

On your github for blynk local server it shows this.

Change your WIFI sketch from

Blynk.begin(auth, SSID, pass));

to

Blynk.begin(auth, SSID, pass, "your_host", 8080);

But when mine was working with the cloud server I did not have SSID and password, only auth.

I finally got the serial port connected. Bad usb cable wasn’t helping. I’m not sure what to look for though. After it connects nothing is printed to the console. I’m guessing blynk.begin is executed on started up before I have connected the serial monitor. power cycling the photon breaks the serial connection of course. I don’t have any print statements in my code. Is information printed automatically such as the blynk connection status? Sorry I haven’t used the serial monitor much.

If you have:

#define BLYNK_PRINT Serial

near the top of your sketch then it will show the Blynk logo in the serial monitor along with some other (very useful) information.

You’ll obviously need to have your serial monitor initialised in your void setup, and your serial monitor set to whatever baud rate you’ve specified in the Serial.begin command.
I’d recommend using the baud rate that your devices uses when it boots-up to output data about the board. this is usually 74880 for an ESP32 or 115200 for an ESP32, but I have no idea what the native baud rate is for your devices.

so why not add some, it will help eliminate some of the guesswork.

What version of the Arduino IDE are you using?
Normally the IDE will grey-out the serial monitor when the device reboots then start displaying serial data as it becomes available again, but earlier versions of the IDE required the serial monitor to be closed and re-opened.

Pete.

My sketch already has #define BLYNK_PRINT Serial
I must not be using the serial monitor correctly.

I am using Particle’s CLI to access the serial monitor for my photon device. Maybe my baud rate is wrong.

I could add print statements but If I could get to the built in Blynk ones I think I would be able to see why it isn’t connecting. I’m not sure what print statements I could add right now that would help with this.

I am using Particle’s web IDE but in order to the use the serial monitor I’ve connected via usb to my board. The Particle CLI works through command line and when the connect breaks I have to reestablish which I think means I could miss the blynk serial messages I will need to see.

Thanks for you help. Initially getting connected was the easy part and I spent all my time debugging my the rest of my project so I didn’t learn much about this and miraculously didn’t use print statements which I use all the time at my day job in another programming enviorment!

I have zero experience of the particle photon hardware and their IDE. It’s rather niche equipment which is over priced and over complicated in my opinion, which is why i never went down that route.

Have you tried downloading a simple serial monitor utility for your PC and looking at the appropriate COM port at the appropriate baud rate?

Pete.

I added my own print statement and it came through on the monitor. I also found an option to have it automatically reconnect. But the blynk serial info isn’t coming through. Getting closer!

I have had a good experience with their products. $19 for a wifi capable board seemed pretty economical to me. I don’t think it has been overly complicated as most of my code would basically run on an arduino.

That makes it about 2.5 times more expensive than an ESP32, and the whole Particle IDE is clearly making the process much more complex for you.

What syntax are you using for your serial print statements, and what does your Serial.begin command look like?

Pete.

Good to know about the ESP32. I only recently heard about them but haven’t looking into them yet. I bought 3 of the particle boards many years ago and still cycling the same hardware through projects. I will definitely look into it for future projects.

Here are my serial begin and test print statements:

Serial.begin(9600);
delay(5000);
Serial.println("Serial test");
Blynk.begin(auth, "192.168.0.13", 8080);

Up at the top of my sketch I have:
#define BLYNK_PRINT Serial

Is there anything else needed to get blynk to print to serial?

There shouldn’t be any other changes needed.

Can you post the first part (ten lines maybe) of your sketch, exactly as it is now - the sequence of commands can make a difference.

Pete.

This is a bit more lines than you asked for but there is a lot in my sketch (good and bad) but it was working as intended before trying to get the local blynk server going.

#include "PID_AutoTune.h"
#include "PID.h"
#include "SmartProbe.h"
#include "SmartBbq.h"
#include "Adafruit_LEDBackpack.h"
#include "Button.h"
#include "ThermistorProbe.h"
#include "SimpleLed.h"
#include "math.h"
#include <numeric>      // std::iota
#include <blynk.h>
#define PROBE1 A6
#define PROBE2 A5
#define PROBE3 A4
#define PROBE4 A3

#define PROBEINDICATOR1 D7
#define PROBEINDICATOR2 D6
#define PROBEINDICATOR3 D5
#define PROBEINDICATOR4 D4
#define BUTTON_LEFT A2
#define BUTTON_CENTER D3
#define BUTTON_RIGHT D2
#define FAN1 D1

TParameters Parameters; //for saving to eeprom.

int FAN2;
int FAN12 = D0;
int Speed = 0;

#define LEDCYCLE 300U
#define ALARMSETDELAY 800U

#define DEBUG FALSE

#define BLYNK_PRINT Serial  // Set serial output for debug prints


char revision[] = "1.0";

double probeTemp1 = 10000.0;
double probeTemp2 = 10000.0;
double probeTemp3 = 10000.0;
double probeTemp4 = 10000.0;

double prevInput = 0.0;
double inputRate = 0.0;
double avgInputRate = 0.0;

double probeAlarmHI1 = 0.0;
double probeAlarmHI2 = 0.0;
double probeAlarmHI3 = 0.0;
double probeAlarmHI4 = 0.0;

double probeAlarmLO1 = 0.0;
double probeAlarmLO2 = 0.0;
double probeAlarmLO3 = 0.0;
double probeAlarmLO4 = 0.0;

bool probeAlarmE1 = FALSE;
bool probeAlarmE2 = FALSE;
bool probeAlarmE3 = FALSE;
bool probeAlarmE4 = FALSE;
bool setTemp325 = FALSE;

float setProbeAlarmHI1 = 0.0;
float setProbeAlarmHI2 = 0.0;
float setProbeAlarmHI3 = 0.0;
float setProbeAlarmHI4 = 0.0;

float setProbeAlarmLO1 = 0.0;
float setProbeAlarmLO2 = 0.0;
float setProbeAlarmLO3 = 0.0;
float setProbeAlarmLO4 = 0.0;

bool probeAlarmAct1 = 0;
bool probeAlarmAct2 = 0;
bool probeAlarmAct3 = 0;
bool probeAlarmAct4 = 0;

int probeAlarmState1 = 4;
int probeAlarmState2 = 0;
int probeAlarmState3 = 0;
int probeAlarmState4 = 0;

int blynkSetpoint = 0;
int blynkSetpointPrev = 0;
unsigned long fanBump = millis();
unsigned long testTime = millis();
int list[500]; //list for poulating menu widget
char myword[] = { 'H', 'e', 'l', 'l', 'o'};
char auth[] = "dwUj1BmMRJpgB4SQitEqvN1mM_jXI7uG";
bool notified = FALSE;

bool tune = 0;
bool notifiedTuneComp = 0;

bool fanPulsedOn = FALSE;
unsigned long fanOffTime = 0;
unsigned long fanOnTime = 0;
bool alarmActive1 = 0;
unsigned long alarmTimeSinceActive = 0;
unsigned long alarmTimeRepeat = 0;
int probeAlarmState1Prev = 4;
int probeAlarmState2Prev = 0;
int probeAlarmState3Prev = 0;
int probeAlarmState4Prev = 0;
bool temp3Notified = 0;
bool temp4Notified = 0;

byte ATuneModeRemember=2;
double input=80, output=0, setpoint=165;
double displayedOutput = 0;
double kpmodel=1.5, taup=45, theta[50]; //try adjusting taup to decrease effect of output on simulated input
double outputStart=5;
double aTuneStep=50, aTuneNoise=1, aTuneStartValue=75;
unsigned int aTuneLookBack=20;
boolean tuning = false;
unsigned long  modelTime, serialTime;
boolean AutoMode = true;

PID myPID(&input, &output, &setpoint,Parameters.kp,Parameters.ki,Parameters.kd, DIRECT);
PID_ATune aTune(&input, &output);
double rateTestValue = 0;
double rateTestPreviousValue = 0;
double rateTestRate = 0;
double rateTestSetpoint = 0;
double rateTestAvgRate = 0;
double tmToSetpoint = 0;
double tmToSetpointAvg = 0;
float cookAvg = 0; // value for moving average
float cookTot = 0; // value for moving average
unsigned long cookNumSamples; // number of samples
const int probe1RunAvgCount = 16;
double probe1RunAvgBuffer[probe1RunAvgCount];
int probe1NextRunAvg = 0;
double probe1RunAvg = 0;
double probe1Fltr = 10000;
int tempMenu[39];
int pitAlmMenu[30];
int meatAlmMenu[27];
bool lidOpen = 0;
bool fanEnabled = 0;
unsigned long lidOpenDelay = 30;
unsigned long timeLidOpen = 0;
double probe1Deviation = 0;
int almCycle = 1;
double A, B, C;
double R1, R2, R3, T1, T2, T3;
bool alarmToggle = 0;
bool probeAlarmAckd1 = 1;
bool probeAlarmRepeat1 = 0;
bool probeAlarmAckd2 = 1;
bool probeAlarmRepeat2 = 1;
bool probeAlarmAckd3 = 1;
bool probeAlarmRepeat3 = 1;
bool probeAlarmAckd4 = 1;
bool probeAlarmRepeat4 = 1;
bool setpointAdj = 0;
unsigned long setPointAdjStart = 0;
bool probeAlarmAckdSetpoint = 1;
bool setpointAlarmEna = 0;
bool probeAlarmSetpoint = 0;
BlynkTimer timer;
// Define SmartBbq
SmartBbq bbq(PROBE1,PROBE2,PROBE3,PROBE4,PROBEINDICATOR1,PROBEINDICATOR2,PROBEINDICATOR3,PROBEINDICATOR4,FAN1,FAN2);
SYSTEM_THREAD(ENABLED);
void setup() {
    pinMode(FAN2, OUTPUT);
    std::iota(list, list + 500, 5); //builds list ranging from 1 to 500
    myPID.SetMode(AUTOMATIC);
    Serial.begin(9600);
    delay(5000);
    Serial.println("Serial test");
    Blynk.begin(auth, "192.168.0.13", 8080);

make this your very first line.

Pete.

That worked to get blynk printing, Thank you!
It just sits at Ready on the last line printed. Any idea what that means.

Serial monitor opened successfully:
Serial test
[8087]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.4 on Particle Photon

[8088] Connecting to 192.168.0.13:8080
[13089] Connecting to 192.168.0.13:8080
[13143] Ready (ping: 12ms).

It means that your device has connected successfully and is working as normal.

That’s a very old library. You should probably be using 0.6.1

Pete.

In the blynk app it says offline and variables are not updating. Why would that happen despite a good connection?

Thanks, I should update my firmware!

I didn’t catch on to what you were saying about the Blynk version. I’ve updated it now to 0.6.4. as 0.6.1 wasn’t an option and the next version was 1.0.0 which I’m guessing is maybe the blynk 2.0 library. But it still isn’t showing my hardware as connected in the app. I do now see it under blynk hardware on the local server web app. It may have already been showing there but at least the server is seeing something.

Fixed it! I mixed up the authorization keys between my two apps. I had started up my other blynk project which doesn’t have hardware running right now and saw that it was online! I can’t believe that was the problem. Feeling a little dumb but I sure learned a lot in the process.

Thank you Pete for all your help! An outage on my brisket smoker would have been a sad thing to endure :flushed: