This is the Arduino sketch code used to communicate between the Blynk On-Line Message Broker “BOMB” (NodeMCU, Wemos D1Mini, or Heltec WiFiKit8 configuration) and the Arduino Zero stepper-motor “Devia” controller. It receives commands from the Blynk cellphone App via the Blynk Cloud, and sends them to the Devia. Maybe not the final version, but close enough to see what is going on under the covers. This code matches the Blynk App UI screenshot previously posted on this project thread.
/* ************************************************************
Blynk is a platform with iOS and Android apps to control the
Arduino and Raspberry Pi for the IOT (Internet of Things).
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
The Blynk library is licensed under MIT license;
Therefore, this example code is also in the public domain.
*************************************************************
WARNING!
It's very tricky to get it working. Please read this article:
http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
This example shows how values can be pushed from Arduino to
the Blynk App.
NOTE: BlynkTimer provides SimpleTimer functionality:
http://playground.arduino.cc/Code/SimpleTimer
************************************************************ */
// Blynk On-line Message Broker (The "BOMB")
// License: Open Software GPL License v2
// Copyright (C) 2020 All Rights Reserved
// Author: Michael Stoddard (BaxRoad.com)
// Timeline:
// 2020-0401 Inception
// 2020-0422 Elaboration
// 2020-0423 Construction
// 2020-0501 Software Transition
// 2020-0701 Support
// Updates:
// 2020-0609 Add BXTD Time Delay and X5CS Speed SET messages
// 2020-0609 Add Heltec display invert & CLEAR commands
// 2020-0621 Use #ifdef conditional compilation for the boards
// Arduino IDE: compiled with 1.8.13
// THIS SOFTWARE IS PROVIDED "AS IS" AND THERE IS NO
// EXPRESS OR IMPLIED WARRANTIES WHATSOEVER WITH RESPECT TO
// ITS FUNCTIONALITY, OPERABILITY, OR USE, INCLUDING, WITHOUT
// LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, OR INFRINGEMENT.
// THERE SHALL BE NO LIABILITY WHATSOEVER FOR ANY DIRECT,
// INDIRECT, CONSEQUENTIAL, INCIDENTAL OR SPECIAL DAMAGES,
// INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS,
// LOSSES RESULTING FROM BUSINESS INTERRUPTION OR LOSS OF DATA,
// REGARDLESS OF THE FORM OF ACTION OR LEGAL THEORY UNDER WHICH
// THE LIABILITY MAY BE ASSERTED, EVEN IF ADVISED OF THE
// POSSIBILITY OR LIKELIHOOD OF SUCH DAMAGES.
/* Comment next line out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG // Debug - enable verbose mode
#define BLYNK_HEARTBEAT 30
#define BLYNK_NO_FLOAT // Disable floating point operations
// Sketch definitions to run in Arduino:
//#include <ESP8266_Lib.h>
//#include <BlynkSimpleShieldEsp8266.h>
//---------------------------//
// Sketch definitions to run in ESP8266:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define MSGMAXLEN 20 // Max Devia Controller App message length
#include "heltec.h" // if using Heltec board
#define D2 2
// Hardware Serial on Mega, Leonardo, Micro...
// #define EspSerial Serial1
// -------------------------------------- //
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial ESPSerial(11, 10); // Software Serial RX, TX
// Attach virtual serial terminal to Virtual Pin V19
WidgetTerminal terminal(V19);
//ESP8266 wifi(&EspSerial);
//BlynkTimer timer;
// Define and set board definition for Blynk:
String Board = "Heltec WiFi Kit 8 ";
#define WiFiKit8
// or
//String Board = "NodeMCU ESP8266 ";
//#define NodeMCU
// or
//String Board = "Wemos D1 Mini ";
//#define WemosD1Mini
String BlynkOnline = "Blynk On-line Message Broker";
String Version = Board + "2020-0621"; // compile date
bool object_tracking = false;
bool delayed_start = false;
bool display_inverted = false;
unsigned int speed_time = 15;
unsigned int delay_time = 15;
unsigned int rail_length = 600;
unsigned int xaxis_length = 500;
unsigned int yaxis_length = 300;
unsigned int zaxis_tilt = 0;
char prbuff[100];
char packetBuffer[MSGMAXLEN];
// This function sends Arduino's up-time every X seconds to
// Virtual Pin (21). In the app, the Widget's reading frequency
// should be set to PUSH. This means that you define how often
// to send data to Blynk App.
//void myTimerEvent()
//{
// You can send any value at any time.
// Don't send more that 10 values per second.
// Blynk.virtualWrite(V21, millis() / 1000);
//}
// The functions listed below will be called every time
// widgits in the Blynk app write values to their Virtual Pin.
BLYNK_WRITE(V0) // "0" -- Object Tracking
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V0 Button value is: ");
Serial.println(pinValue);
terminal.print("Object Tracking is set to: ");
if (pinValue != 0) {
terminal.println("ON");
object_tracking = true;
} else {
terminal.println("OFF");
object_tracking = false;
}
terminal.flush();
}
BLYNK_WRITE(V1) // "1" -- Delayed Start
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V1 Button value is: ");
Serial.println(pinValue);
terminal.print("Delayed Start is set to: ");
if (pinValue != 0) {
terminal.println("ON");
delayed_start = true;
} else {
terminal.println("OFF");
delayed_start = false;
}
terminal.flush();
}
BLYNK_WRITE(V2) // "2" -- Travel Time in seconds
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V2 Slider value is: ");
Serial.println(pinValue);
terminal.print("TRAVEL TIME is set to: ");
terminal.print(pinValue);
terminal.println(" seconds");
terminal.flush();
speed_time = pinValue;
sprintf(prbuff, "%04d", speed_time);
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'X';
packetBuffer[1] = '5';
packetBuffer[2] = 'C';
packetBuffer[3] = 'S';
packetBuffer[16] = prbuff[0];
packetBuffer[17] = prbuff[1];
packetBuffer[18] = prbuff[2];
packetBuffer[19] = prbuff[3];
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
BLYNK_WRITE(V3) // "3" -- Time Delay
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V3 Slider value is: ");
Serial.println(pinValue);
terminal.print("TIME DELAY is set to: ");
terminal.print(pinValue);
terminal.println(" seconds");
terminal.flush();
delay_time = pinValue;
sprintf(prbuff, "%04d", delay_time);
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'B';
packetBuffer[1] = 'X';
packetBuffer[2] = 'T';
packetBuffer[3] = 'D';
packetBuffer[16] = prbuff[0];
packetBuffer[17] = prbuff[1];
packetBuffer[18] = prbuff[2];
packetBuffer[19] = prbuff[3];
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
BLYNK_WRITE(V4) // "4" -- Rail Length
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V4 Slider value is: ");
Serial.println(pinValue);
terminal.print("RAIL LENGTH is set to: ");
terminal.print(pinValue);
terminal.println(" mm");
rail_length = pinValue;
terminal.flush();
}
BLYNK_WRITE(V5) // "5" -- X-Axis Length
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V5 Slider value is: ");
Serial.println(pinValue);
terminal.print("X-AXIS LENGTH is set to: ");
terminal.print(pinValue);
terminal.println(" mm");
xaxis_length = pinValue;
terminal.flush();
}
BLYNK_WRITE(V6) // "6" -- Y-Axis Length
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V6 Slider value is: ");
Serial.println(pinValue);
terminal.print("Y-AXIS HEIGHT is set to: ");
terminal.print(pinValue);
terminal.println(" mm");
yaxis_length = pinValue;
terminal.flush();
}
BLYNK_WRITE(V7) // "7" -- Z-Axis Tilt
{
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V7 Slider value is: ");
Serial.println(pinValue);
terminal.print("Z-AXIS tilt is set to: ");
terminal.print(pinValue);
terminal.println(" degrees");
zaxis_tilt = pinValue;
terminal.flush();
}
BLYNK_WRITE(V8) // "8" -- START
{
if ( param.asInt() != 0 ) { // debounce
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V8 Button value is: ");
Serial.println(pinValue);
terminal.println("");
terminal.println("START!");
terminal.print("Time Delay ");
if (delayed_start) {
//terminal.print("ON for ");
terminal.print(delay_time);
terminal.print(" seconds");
} else {
terminal.print("off ");
}
terminal.println("");
terminal.print("Object Tracking ");
if (object_tracking) {
terminal.print("ON -- Angle is ");
volatile int32_t object_angle = atan2(float(yaxis_length), float(xaxis_length)) * 180 / PI;
terminal.print(object_angle); terminal.print(" degrees");
} else {
terminal.print("off");
}
terminal.println("");
terminal.print("Rail Length "); terminal.print(rail_length); terminal.print("mm ");
terminal.print(" ");
terminal.print("Z-axis Tilt "); terminal.print(zaxis_tilt); terminal.print(" degrees");
terminal.println("");
terminal.print("X-axis Length "); terminal.print(xaxis_length); terminal.print("mm ");
terminal.print(" ");
terminal.print("Y-axis Height "); terminal.print(yaxis_length); terminal.print("mm ");
terminal.println("");
unsigned int t = speed_time;
unsigned int s = t % 60;
t = (t - s) / 60;
unsigned int m = t % 60;
t = (t - m) / 60;
unsigned int h = t;
terminal.print("Travel Time ");
if (h > 0) {
terminal.print(h);
terminal.print(" Hour(s) ");
}
if (m > 0) {
terminal.print(m);
terminal.print(" Mins ");
}
terminal.print(s); terminal.print(" Seconds");
terminal.println("");
terminal.flush();
if (delayed_start == true) // start with delay
{
terminal.println("START with DELAY");
terminal.flush();
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'X';
packetBuffer[1] = '3';
packetBuffer[2] = 'C';
packetBuffer[3] = 'S';
sprintf(prbuff, "%04d", rail_length);
packetBuffer[4] = prbuff[0];
packetBuffer[5] = prbuff[1];
packetBuffer[6] = prbuff[2];
packetBuffer[7] = prbuff[3];
sprintf(prbuff, "%04d", xaxis_length);
packetBuffer[8] = prbuff[0];
packetBuffer[9] = prbuff[1];
packetBuffer[10] = prbuff[2];
packetBuffer[11] = prbuff[3];
sprintf(prbuff, "%04d", yaxis_length);
packetBuffer[12] = prbuff[0];
packetBuffer[13] = prbuff[1];
packetBuffer[14] = prbuff[2];
packetBuffer[15] = prbuff[3];
sprintf(prbuff, "%04d", speed_time);
packetBuffer[16] = prbuff[0];
packetBuffer[17] = prbuff[1];
packetBuffer[18] = prbuff[2];
packetBuffer[19] = prbuff[3];
if (object_tracking == false) {
for (int j=8; j<16; j++) {
packetBuffer[j] = '0';
}
}
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
else
{
terminal.println("START with no delay");
terminal.flush();
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'X';
packetBuffer[1] = '1';
packetBuffer[2] = 'C';
packetBuffer[3] = 'S';
sprintf(prbuff, "%04d", rail_length);
packetBuffer[4] = prbuff[0];
packetBuffer[5] = prbuff[1];
packetBuffer[6] = prbuff[2];
packetBuffer[7] = prbuff[3];
sprintf(prbuff, "%04d", xaxis_length);
packetBuffer[8] = prbuff[0];
packetBuffer[9] = prbuff[1];
packetBuffer[10] = prbuff[2];
packetBuffer[11] = prbuff[3];
sprintf(prbuff, "%04d", yaxis_length);
packetBuffer[12] = prbuff[0];
packetBuffer[13] = prbuff[1];
packetBuffer[14] = prbuff[2];
packetBuffer[15] = prbuff[3];
sprintf(prbuff, "%04d", speed_time);
packetBuffer[16] = prbuff[0];
packetBuffer[17] = prbuff[1];
packetBuffer[18] = prbuff[2];
packetBuffer[19] = prbuff[3];
if (object_tracking == false) {
for (int j=8; j<16; j++) {
packetBuffer[j] = '0';
}
}
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
}
}
BLYNK_WRITE(V9) // "9" -- STOP
{
if ( param.asInt() != 0 ) { // debounce
int pinValue = param.asInt(); // assigning incoming value
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V9 Button value is: ");
Serial.println(pinValue);
terminal.println("STOP");
terminal.flush();
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'X';
packetBuffer[1] = '0';
packetBuffer[2] = 'C';
packetBuffer[3] = 'S';
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
}
BLYNK_WRITE(V10) // "10" -- Continue
{
if ( param.asInt() != 0 ) { // debounce
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V10 Button value is: ");
Serial.println(pinValue);
if (delayed_start == true) // continue with delay
{
terminal.println("CONTINUE with DELAY");
terminal.flush();
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'X';
packetBuffer[1] = '4';
packetBuffer[2] = 'C';
packetBuffer[3] = 'S';
sprintf(prbuff, "%04d", rail_length);
packetBuffer[4] = prbuff[0];
packetBuffer[5] = prbuff[1];
packetBuffer[6] = prbuff[2];
packetBuffer[7] = prbuff[3];
sprintf(prbuff, "%04d", xaxis_length);
packetBuffer[8] = prbuff[0];
packetBuffer[9] = prbuff[1];
packetBuffer[10] = prbuff[2];
packetBuffer[11] = prbuff[3];
sprintf(prbuff, "%04d", yaxis_length);
packetBuffer[12] = prbuff[0];
packetBuffer[13] = prbuff[1];
packetBuffer[14] = prbuff[2];
packetBuffer[15] = prbuff[3];
sprintf(prbuff, "%04d", speed_time);
packetBuffer[16] = prbuff[0];
packetBuffer[17] = prbuff[1];
packetBuffer[18] = prbuff[2];
packetBuffer[19] = prbuff[3];
if (object_tracking == false) {
for (int j=8; j<16; j++) {
packetBuffer[j] = '0';
}
}
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
else // continue with no delay
{
terminal.println("CONTINUE with no delay");
terminal.flush();
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'X';
packetBuffer[1] = '2';
packetBuffer[2] = 'C';
packetBuffer[3] = 'S';
sprintf(prbuff, "%04d", rail_length);
packetBuffer[4] = prbuff[0];
packetBuffer[5] = prbuff[1];
packetBuffer[6] = prbuff[2];
packetBuffer[7] = prbuff[3];
sprintf(prbuff, "%04d", xaxis_length);
packetBuffer[8] = prbuff[0];
packetBuffer[9] = prbuff[1];
packetBuffer[10] = prbuff[2];
packetBuffer[11] = prbuff[3];
sprintf(prbuff, "%04d", yaxis_length);
packetBuffer[12] = prbuff[0];
packetBuffer[13] = prbuff[1];
packetBuffer[14] = prbuff[2];
packetBuffer[15] = prbuff[3];
sprintf(prbuff, "%04d", speed_time);
packetBuffer[16] = prbuff[0];
packetBuffer[17] = prbuff[1];
packetBuffer[18] = prbuff[2];
packetBuffer[19] = prbuff[3];
if (object_tracking == false) {
for (int j=8; j<16; j++) {
packetBuffer[j] = '0';
}
}
ESPSerial.print(packetBuffer);
memset(prbuff, 0, (sizeof(prbuff)/sizeof(prbuff[0])));
Serial.println(packetBuffer);
}
}
}
BLYNK_WRITE(V19) // Virtual Terminal
{
while(true) {
if (String(param.asStr()) == String("clear")) {
terminal.clear(); // Clear the Blynk terminal
terminal.println(BlynkOnline + " (the BOMB)");
terminal.println(Version + " BaxRoad.com");
terminal.println("") ;
terminal.flush();
#ifdef WiFiKit8
Heltec.display->clear(); // Clear the HelTec display
Heltec.display->drawString(0, 0, BlynkOnline);
Heltec.display->drawString(0, 10, Version);
Heltec.display->display();
#endif
break;
}
#ifdef WiFiKit8
if (String(param.asStr()) == String("invert")) {
if (!display_inverted) { // only works once ...
Heltec.display->clear(); // Clear the HelTec display
Heltec.display->init(); // invert the display 180 degrees
Heltec.display->drawString(0, 0, BlynkOnline);
Heltec.display->drawString(0, 10, Version);
Heltec.display->display();
display_inverted = true;
terminal.println("OK") ;
terminal.flush();
}
break;
}
#endif
if (String(param.asStr()) == String("marco")) {
terminal.println("You said: 'Marco' !") ;
terminal.println("I say: 'Polo' !") ;
terminal.flush();
break;
}
terminal.println(" ??") ; // unknown command
terminal.flush();
break;
}
}
BLYNK_WRITE(V20) // WiFi Test
{
if ( param.asInt() != 0 ) { // debounce
String LocalIP = "IP address: " + WiFi.localIP().toString();
terminal.println(LocalIP);
terminal.flush();
#ifdef WiFiKit8
Heltec.display->clear(); // Heltec
Heltec.display->drawString(0, 0, BlynkOnline);
Heltec.display->drawString(0, 10, Version);
Heltec.display->drawString(0, 20, LocalIP);
Heltec.display->display();
digitalWrite(D2, HIGH); // HelTec but actually the LED is on; this is because
#endif
#ifdef WemosD1Mini
digitalWrite(BUILTIN_LED, LOW); // Wemos Mini
#endif
#ifdef NodeMCU
digitalWrite(BUILTIN_LED, LOW); // NodeMCU - Turn the BLUE LED on (Note that LOW is the voltage level
#endif
delay(500); // Wait a bit
#ifdef NodeMCU
digitalWrite(BUILTIN_LED, HIGH); // turn the LED off by making the voltage HIGH
#endif
#ifdef WemosD1Mini
digitalWrite(BUILTIN_LED, HIGH); // turn it off
#endif
#ifdef WiFiKit8
digitalWrite(D2,LOW);
Heltec.display->clear();
Heltec.display->drawString(0, 0, BlynkOnline);
Heltec.display->drawString(0, 10, Version);
Heltec.display->display();
#endif
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
memset(packetBuffer, '0', MSGMAXLEN);
packetBuffer[0] = 'B';
packetBuffer[1] = 'X';
packetBuffer[2] = 'W';
packetBuffer[3] = 'T';
ESPSerial.print(packetBuffer);
Serial.println(packetBuffer);
}
}
void setup()
{
#ifdef WiFiKit8
Heltec.begin(true /*DisplayEnable Enable*/, true /*Serial Enable*/);
#endif
Serial.begin(9600); // Start serial port
delay(1000);
ESPSerial.begin(9600); // start Devia Controller comm port
delay(1000);
Serial.println("");
Serial.println("Blynk Online Message Broker (the BOMB) BaxRoad.com");
// Router authentification variables: (use your own)
char auth[] = "YourAuthString";
char ssid[] = "YourSSID";
char pass[] = "YourPassword";
String Connecting = "Connecting to "+ String(ssid);
Serial.println(Connecting);
#ifdef WiFiKit8
//Heltec.display->clear();
//Heltec.display->init(); // inverts the display if needed
Heltec.display->drawString(0, 20, Connecting );
Heltec.display->display();
#endif
Blynk.begin(auth, ssid, pass); // Fireup the Blynk engine
delay(1000); // stabilize
#ifdef WemosD1Mini
pinMode(BUILTIN_LED, OUTPUT); // Wemos D1 Mini
digitalWrite(BUILTIN_LED, HIGH); // Turn it off to start
#endif
#ifdef NodeMCU
pinMode(BUILTIN_LED, OUTPUT); // NodeMCU
digitalWrite(BUILTIN_LED, HIGH); // Turn it off to start
#endif
#ifdef WiFiKit8
pinMode(D2, OUTPUT); // HelTec
digitalWrite(D2, LOW); // Turn it off to start
#endif
// Setup a function to be called every one second if needed
//timer.setInterval(1000L, myTimerEvent);
terminal.clear();
terminal.println(BlynkOnline + " (the BOMB)");
terminal.println(Version + " BaxRoad.com");
terminal.println("") ;
terminal.flush();
#ifdef WiFiKit8
Heltec.display->clear();
Heltec.display->drawString(0, 0, BlynkOnline);
Heltec.display->drawString(0, 10, Version);
String LocalIP = "IP address: " + WiFi.localIP().toString();
Heltec.display->drawString(0, 20, LocalIP);
Heltec.display->display();
delay(2000);
Heltec.display->clear();
Heltec.display->drawString(0, 0, BlynkOnline);
Heltec.display->drawString(0, 10, Version);
Heltec.display->display();
#endif
//Serial.swap(); // $Debug -- move Rx/Tx connections
}
void loop()
{
if (Serial.available()) // Check if incoming data is available
{
//Serial.print("$");
byte byteRead = Serial.read(); // Read the most recent byte
if (byteRead != 0x0D) {
Serial.print(char(byteRead)); // Echo the byte
ESPSerial.print(char(byteRead)); // Echo the byte to Serial2
if (byteRead == 0x0A) {
Serial.println(""); // force a linefgeed
}
}
}
if (ESPSerial.available()) // Check if incoming data is available
{
//Serial.print("$");
byte byteRead = ESPSerial.read(); // Read the most recent byte
if (byteRead != 0x0D) {
Serial.print(char(byteRead)); // Echo the byte
ESPSerial.print(char(byteRead)); // Echo the byte to Serial2
if (byteRead == 0x0A) {
Serial.println(""); // force a linefgeed
}
}
}
Blynk.run(); // Keep Blynk running; refresh
//timer.run(); // Initiate BlynkTimer here if needed
}
// Message Definitions:
// ===================
// Message J5CS : Change speed camera slider + 4 params ()
// Message J4CS : Continue with delay camera slider + 4 params ()
// Message J3CS : Start from init with delay camera slider + 4 params ()
// Message J2CS : Continue camera slider + 4 params ()
// Message J1CS : Start from init camera slider + 4 params ()
// Message J0CS : STOP
// Message BXTD : Set Time Delay
// Message BXWT : WiFi Test for Blynk-to-Bomb connectivity