Ok, I think I mis-explained my project, but here’s some code snippets to hopefully convey what I’m trying to do.
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>
#include <TimeLib.h>
#include <DHT.h>
#include <Wire.h>
char auth[] = "MASTER_AUTH"; // Cloud Server
//Initiating Bridge Widget
WidgetBridge Bridge1(V0); //Relays
WidgetBridge Bridge2(V1); //Pumps 1-4
WidgetBridge Bridge3(V2); //Pumps 5-8
BLYNK_CONNECTED() {
Bridge1.setAuthToken("SLAVE1"); // Slave_Relays
Bridge2.setAuthToken("SLAVE2"); // Slave_Pumps 1-4
Bridge3.setAuthToken("SLAVE3"); // Slave_Pumps 5-8
//Bridge4.setAuthToken("AUTH"); // Slave_XXX
}
uint32_t msPerGallon = 33000; //ms per gallon
uint32_t ROstart = 0;
uint32_t countGallons;
boolean runningRO = false;
int ROpumpOn = 0; //Blynk Triggered RO Pump
float totalGallons; //Number of RO Gallons Selected in Widget
BLYNK_WRITE(V34) {
totalGallons = param.asFloat(); // ROpump remote
}
void ROcheck() //RO Pump = 34 seconds on time per gallon
{
if (ROpumpOn == 1 && runningRO == false) // Activates when Blynk button is toggled
{
Bridge1.virtualWrite(V61, totalGallons); // Calculates length of runtime for pump
terminal.print("Pumping:");
terminal.print(totalGallons);
terminal.println(" Gallons of RO");
Blynk.virtualWrite(V33, 1); // Illuminates Blynk button widget
runningRO = true;
ROstart = millis();
countGallons = msPerGallon * totalGallons; // Calculates length of runtime for
}
if (millis() - ROstart > countGallons) // Determines when runtime ends
{
ROpumpOn = 0;
runningRO = false;
Blynk.virtualWrite(V32, 0); // Turn off lit button widget
Blynk.virtualWrite(V33, 0); // Turn off lit button widget
}
terminal.flush();
}
I want the above sketch to retrieve the value from it’s app, then apply the value to a Vpin and send that value over to the below slave. The app will illuminate the button widget like an LED for the duration that the slave relay is energized.
//------------SLAVE RELAYS
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "SLAVE1_AUTH"; // Cloud Server
char ssid[] = "network";
char pass[] = "password";
//Initiating Bridge Widget
WidgetBridge Bridge1(V0); //Relays
uint32_t msPerGallon = 33000; //ms per gallon
uint32_t ROstart = 0;
uint32_t countGallons;
boolean runningRO = false;
int ROpumpOn = 0; //Blynk Triggered RO Pump
float totalGallons; //Number of RO Gallons Selected in Widget
BLYNK_WRITE(V61) {
totalGallons = param.asFloat(); // ROpump remote
}
void ROcheck() //RO Pump = 34 seconds on time per gallon
{
if (totalGallons > 0 && runningRO == false) // Activates when Blynk button is toggled
{
digitalWrite(ROpump, TURN_ON);
runningRO = true;
ROstart = millis();
countGallons = msPerGallon * totalGallons; // Calculates length of runtime for pump
}
if (millis() - ROstart > countGallons) // Determines when runtime ends
{
digitalWrite(ROpump, TURN_OFF);
runningRO = false;
}
}
By using the Bridge widget, I figure I can circumvent the need to manually switch between AUTHs using the selector widget. Am I misunderstanding that? I’ll use a selector widget if left with no other choice, but if possible, I would greatly prefer to use the bridges, and just work everything out in code. I realize figuring out all the back and forth will be a task, but once through it, I’ll have a worry free project again.