[SOLVED] Can two bridged ESP8266 = 14 GPIO's for one program?

@Dave1829 you have access to 32 virtual pins with one dashboard and 2 devices sharing one token.
I’m not quite sure how you map the 32 virtual pins to the pins of the 2 devices though.
Surely if you have V0 in the dashboard and you can only refer it to say GPIO 2 on an ESP and it would trigger the GPIO 2 on BOTH devices so you are still left with the 7 unique GPIO’s you refer to in your original post.

With bridge and 2 tokens you have access to the 14 pins you require.

Maybe I am missing something @Pavel?

1 Like

@Pavel

OK, i have two ESP operating with same Token, two separate sketches on each.

in the sensor node sketch i create variable:

float presNode01

that holds the value of the pressure measured by BME280 sensor

this displays on the app in the V2 display value widget, via:

Blynk.virtualWrite(V2, presNode01);

in the sensor sketch.

now - how do i use the value in V2 in the other sketch?

is it as simple as:

float presNode01;

BLYNK_READ(V2)
{
  Blynk.virtualWrite(2, presNode01);
}

and then i can use the variable presNode01 in this code:

double dewPoint(double celsius, double humidity, float presNode01)
{

  // (1) Saturation Vapor Pressure = ESGG(T)
  double RATIO = 373.15 / (273.15 + celsius);
  double RHS = -7.90298 * (RATIO - 1);
  RHS += 5.02808 * log10(RATIO);
  RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1 / RATIO ))) - 1) ;
  RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
  RHS += log10(presNode01); // was 1013.246

  // factor -3 is to adjust units - Vapor Pressure SVP * humidity
  double VP = pow(10, RHS - 3) * humidity;

  // (2) DEWPOINT = F(Vapor Pressure)
  double T = log(VP / 0.61078); // temp var
  return (241.88 * T) / (17.558 - T);
}

or have i got it all wrong???

@Dave1829 if you are using just one token then each sketch has the variables available. So for the variable you want to pass you just ensure it is defined in both sketches.

I find the read and write’s a little confusing and consider them to be named in the opposite way to human thinking but that might just be me.

So sketch 1 write’s the value on the display with the READ command:

BLYNK_READ(V2)
{
  Blynk.virtualWrite(2, presNode01);
}

And sketch 2 reads the value from the display with the WRITE command:

BLYNK_WRITE(V2)
{   
   float presNode01 = param.asFloat(); 
}

I think the READ and WRITE are taken in respect of what the server is doing rather than what the end user is doing.

2 Likes

yes, i feel the same way,

it is sad my FTDI converter bricked itself last night, i would dearly love to try your suggestions!!!

thank you for your wise guidance @Costas

param.asFloat() does not compile:

Arduino: 1.6.5 (Windows 8.1), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck"

Build options changed, rebuilding all

_160311_basement_plenum_controller.ino: In function 'void BlynkWidgetWrite30(BlynkReq&, const BlynkParam&)':
_160311_basement_plenum_controller:64: error: 'const class BlynkParam' has no member named 'asFloat'
_160311_basement_plenum_controller.ino: In function 'void BlynkWidgetWrite2(BlynkReq&, const BlynkParam&)':
_160311_basement_plenum_controller:69: error: 'const class BlynkParam' has no member named 'asFloat'
'const class BlynkParam' has no member named 'asFloat'

but param.asDouble & param.asInt both compile?

this page: https://github.com/blynkkk/blynkkk.github.io/blob/master/BlynkFirmware.md

shows param.asFloat as a valid term?

thank you @Costas my new FTDI programer arrived and i have now uploaded and tested these adjustments you suggest - all working now! (seems not to matter if variable changes type between sketches!)

i have one ESP8266 node that sends its sensor outputs the the master ESP8266 that controls my relays!!!

it is like BLYNK MAGIC

:heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes::heart_eyes:

1 Like

Hi Dave1829, i try to make something like you but not working.Can you post working code’s for two EPS?

I can post up my codes in 15 hours or so, but simply use the code @costas posted but use param.asDouble because float does not work.

If @costas code does not work, the rest of your code must have a fault…

hi, sorry for the long delay!

here is the basic code:

“Master” - where the readings are USED decide when to open/close relays:

double TempNode02, DewPointNode02; //from Node02 

BLYNK_WRITE(V26)
{
  TempNode02 = param.asDouble(); // gets reading from Node02 which is a separate ESP8266 device - it is the LIVING ROOM DHT22 sensor
}

BLYNK_WRITE(V7)
{
  DewPointNode02 = param.asDouble(); // gets reading from Node02 which is a separate ESP8266 device - it is the LIVING ROOM DHT22 sensor
}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

the “Node” code where the sensor is operated, and ‘sends’ readings to the “Master”:

float TempNode02, DewPointNode02;

BLYNK_READ(V26)
{
  Blynk.virtualWrite(26, TempNode02);
}

BLYNK_READ(V7)
{
  Blynk.virtualWrite(7, DewPointNode02);
}

void runDHT22()
{
  int chk;
  chk = DHT.read22(LIVING_DHT22_PIN);
  HumNode02 = DHT.humidity;
  TempNode02 = DHT.temperature;
  DewPointNode02 = dewPoint(DHT.temperature, DHT.humidity);

  Blynk.virtualWrite(V26, TempNode02);
  Blynk.virtualWrite(V7, DewPointNode02);
}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

i don’t really know how having the variables as a float in one sketch but double in the other is affecting anything - certainly doesn’t seem to…

Thank you.Will try code.

@vshymanskyy I have also noticed that param.asFloat() fails to compile. Is it no longer available?

Sorry to resurrect such an old thread, but I also notice param.asFloat() does not compile. Bug?

it should be asDouble()…

@vshymanskyy can you please arrange for your documentation to be corrected at http://docs.blynk.cc/ search for param.asFloat().

@Costas, I think I’ll just add asFloat support as well :wink:

2 Likes

Wise decision @vshymanskyy as many users work with floats and it removes the need to make long and integer conversions.

I recieved the value from light sensor at A0 Pin in Node MCU. I want to use this value for automatic dimmig lighting by adjusted Duty cycle of PWM at D2 Pin in Node MCU. How to program the code and I want to use them with Blynk.

How to connect Vitual pin to real pin on node MCU.

First, there is no need to involve Blynk in these kinds of operations. Why do you need Virtual Pin, when you can just take the A0 sensor data and map it to D2 output?

Secondly, check the basic examples included in the library, or read documentation on how to use Virtual Pins.

Dimitriy how many devices can i use sharing the same aunth token. Im using just two but im having disconnection issues. I dunnonifbis my code or the fact of sending the data to 2 devices. However im not reading the same virtu pins for both of them for instance one reads v10 to v20 the other v110 to v120
Thabks for your help

We don’t have any limits here.

In that case issue most probably in wiring, code, wi-fi strength, etc.