I’m sorry I came in from the back door:confounded:
It’s been a year I am not working with Blynk nor Photon !
I’m working in a project that read 5 analog sensors trough a PSoC 5LP from Cypress.
Then PSoC 5LP send 5 character buffers of 6 element each through the serial port towards the photon serial port 1.
I am using Blink as GUI so that 5 labeled values display each of those analog reading.
The Blynk app get disconnected periodically and reconnected.
Labeled values just display only the the first two values the others three are shown with no format ( Format is ###,##).
I suspect that something is happening with the time stamp I am using.
I would appreciate very much any help.
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
#define BLYNK_printserial
char auth[] = "745cf23fe70543bcbfcd68673d82e3ff" ;
char Lbs_1[6]; // 1th sensor array
char Lbs_2[6]; // 2th sensor array
char Lbs_3[6]; // 3th sensor array
char Lbs_4[6]; // 4th sensor array
char Lbs_5[6]; // 5th sensor array
BlynkTimer timer;
int Email_1=0;
const unsigned long SendEmail=17000L;
unsigned long lastEmail; // Global initialize to 0
const unsigned long SendLbs_1=1000L;
unsigned long lastLbs_1; // Global initialize to 0
const unsigned long SendLbs_2=1000L;
unsigned long lastLbs_2; // Global initialize to 0
const unsigned long SendLbs_3=1000L;
unsigned long lastLbs_3; // Global initialize to 0
const unsigned long SendLbs_4=1000L;
unsigned long lastLbs_4; // Global initialize to 0
const unsigned long SendLbs_5=1000L;
unsigned long lastLbs_5; // Global initialize to 0
void sendPressure_1()
{
int i=0;
while( Serial1.available() && i<7)
{
Lbs_1[i]=Serial1.read();
if (Lbs_1[i]=='\0;' )
{
break;
}
i++;
}
i=0;
Lbs_1[6]='\0';
/* Send it over the Blynk server */
Blynk.virtualWrite (V7,Lbs_1);
}
void sendPressure_2()
{
int i=0;
while( Serial1.available() && i<7)
{
Lbs_2[i]=Serial1.read();
if (Lbs_2[i]=='\0;' )
{
break;
}
i++;
}
i=0;
Lbs_2[6]='\0';
/* Send it over the Blynk server */
Blynk.virtualWrite (V8,Lbs_2);
}
void sendPressure_3()
{
int i=0;
while( Serial1.available() && i<7)
{
Lbs_3[i]=Serial1.read();
if (Lbs_3[i]=='\0;' )
{
break;
}
i++;
}
i=0;
Lbs_3[6]='\0';
/* Send it over the Blynk server */
Blynk.virtualWrite (V9,Lbs_3);
}
void sendPressure_4()
{
int i=0;
while( Serial1.available() && i<7)
{
Lbs_4[i]=Serial1.read();
if (Lbs_4[i]=='\0;' )
{
break;
}
i++;
}
i=0;
Lbs_4[6]='\0';
/* Send it over the Blynk server */
Blynk.virtualWrite (V10,Lbs_4);
}
void sendPressure_5()
{
int i=0;
while( Serial1.available() && i<7)
{
Lbs_5[i]=Serial1.read();
if (Lbs_5[i]=='\0;' )
{
break;
}
i++;
}
i=0;
Lbs_5[6]='\0';
/* Send it over the Blynk server */
Blynk.virtualWrite (V11,Lbs_5);
}
void SEmail()
{
while( Serial1.available()>0)
{
Email_1=Serial1.read();
if (Email_1==0xAA)
{
Blynk.email("Subjet","Lbs_1>250");
Email_1 =0; break;
}
}
}
void setup() {
// Debug Console
Serial1.begin(57600);
delay(5000);// Allow board to settle
Blynk.begin (auth);
}
void loop() {
unsigned long topLoop_1 = millis();
//unsigned long topLoop_2 = millis();
//unsigned long topLoop_3 = millis();
//unsigned long topLoop_4 = millis();
//unsigned long topLoop_5 = millis();
Blynk.run();
if ((topLoop_1-lastLbs_1 )>=SendLbs_1)
{
lastLbs_1=topLoop_1;
sendPressure_1();
}
if ((topLoop_1-lastLbs_2 )>=SendLbs_2)
{
lastLbs_2=topLoop_1;
sendPressure_2();
}
if ((topLoop_1-lastLbs_3 )>=SendLbs_3)
{
lastLbs_3=topLoop_1;
sendPressure_3();
}
if ((topLoop_1-lastLbs_4 )>=SendLbs_4)
{
lastLbs_4=topLoop_1;
sendPressure_4();
}
if ((topLoop_1-lastLbs_5 )>=SendLbs_5)
{
lastLbs_5=topLoop_1;
sendPressure_5();
}
}