Blynk for Beginners and help with your project

simple question - what is the purpose and function of F in the println function ?

@mars compile the sketch with and without the F’s (and associated opening and closing brackets) and check program space used.

With the F’s

Sketch uses 236,641 bytes (22%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 34,560 bytes (42%) of dynamic memory, leaving 47,360 bytes for local variables.

Without the F’s

Sketch uses 236,529 bytes (22%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 34,592 bytes (42%) of dynamic memory, leaving 47,328 bytes for local variables.

Not important with a simple sketch like this one but if your code has a few thousand lines with lot’s of Serial Print’s it can make a difference.

thanks Costas but I’m still not clear as to what the F does :wink:
it seems to use more memory based in your notes above.

A throwback to working with Nano’s 32KB of Flash memory and just 2KB of RAM.

Dynamic memory (RAM) is much more limited than Flash (Programmable memory).

Take a look at this Arduino thread and see if that makes it clearer https://forum.arduino.cc/index.php?topic=428015.0

1 Like

got it thanks - the F in println forces the use of flash vs dynamic ram.

1 Like

I agree… and would amend that with “experienced or bullheaded coderwanabees”… which of course explains why I skipped over millis() and went right for delayMicroseconds() :stuck_out_tongue:

Great goto topic @Costas… I think I will bookmark it as well :wink:

With regards to the F in print() statements… am I correct in thinking that this is only a benefit when using ‘Pre-written’ strings (actual text in-between the brackets) as opposed to variables that refer to a bunch of combined strings or other incoming data?

println(F("This Is Data! "));

vs

u = "That ";
v = "This ";
w = "Was ";
x = "Is ";
y = "Data! ";
z = "Sparta! ";

println(F(v + x + y));  // Is the F of any dynamic memory benefit here?

Aside from the fact that the variables themselve take up memory.

1 Like

Yes, the F macro will not accept the following based on u, v, w defined as String’s.
Serial.println(F(u + v + w));

@Costas I saw that you managed to install blynk on an omega 2, I’m trying to install it following this tutorial

But I have an error in step 2 (./scripts/feeds update -a)

/bin/ash: ./scripts/feeds: not found

Could you tell me how you installed it?

@Omar_Mariscal do you have a 2 or a 2+? You need a 2+ or some way of transferring the file system to a USB stick if you are using a 2 as it’s doesn’t have enough memory for all the required packages.

The link you gave is giving me a 404 error, did you mean this page https://github.com/vshymanskyy/OpenWRT-Espruino-packages

This is the tutorial I followed https://wiki.onion.io/Tutorials/blynk-library and I think there was just a minor path mod that I needed to do. The tutorial is for the Omega 1 but it worked pretty much the same for the 2+

Please don’t spam multiple help requests across different threads… you have already received an answer to your question in another old thread you re-opened.

2 Likes

Hlo Blynk Employees i think you need to prepare one ppt for blynk server how controlling happend with phone thats good for your company plz focus on it

I need to make a weekday timer … is there a way you can help me ? I’m new to arduino and Blynk … please contact me vivianatej9@gmail.com

@Vivianatej9 This forum is for Blynk users to share and assist other Blynk users with ideas and guidance.

We are not a for-hire code factory, nor is begging for code considered acceptable, here in the open forum nor via private messaging, as you have also been doing.

Please cease from sending out these types of requests or you risk getting blocked from the forums.

1 Like

I just needed help with my project … but that’s for your time .

@Vivianatej9 hello, what have you tried so far?

Hi, I’m struggling with the bridge widget!

What I need seems pretty simple but can’t make it work, the Blynk library examples aren’t helping.

I want to connect two Arduino boards via the bridge widget and that whenever a led in board A is ON turn an led in board B ON. And whenever the led of board A is OFF the led of board B is OFF.

I would really appreciate some help with the code, I’m completely stuck!

Thanks!!

@Edu_Ferrer paste your formatted bad code.

Code Arduino A

#define BLYNK_PRINT SwSerial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>


char auth[] = "c4338d1814324794ba0802364381f740"; //Arduino A

WidgetBridge bridge1(V1);

static bool value = true;

BLYNK_CONNECTED() {
  bridge1.setAuthToken("4059dde6593b444592d25b53c36089ea"); // Arduino B
}

void setup()
{

  SwSerial.begin(9600);
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

}

void loop()
{
  Blynk.run();

  if (value) {
    bridge1.digitalWrite(9, HIGH);  // Digital Pin 9 on the second board will be set HIGH
    bridge1.virtualWrite(V5, 1); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.

  } else {
    bridge1.digitalWrite(9, LOW); // Digital Pin 9 on the second board will be set LOW
    bridge1.virtualWrite(V5, 0); // Sends 0 value to BLYNK_WRITE(V5) handler on receiving side.
  }
  // Toggle value
  value = !value;
}

Code Arduino B

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>

char auth[] = "4059dde6593b444592d25b53c36089ea";

 BLYNK_WRITE(V5){
    int pinData = param.asInt(); // pinData variable will store value that came via Bridge
    }

void setup()
{
  SwSerial.begin(9600);
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

@Edu_Ferrer is Arduino A being disconnected from the server as you look to be sending far too much data i.e. 1000’s of times a second.

Before the line value = !value; add:

delay(1000); // NEVER USE DELAY WITH BLYNK, USE BLYNK TIMER