BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Pulse Timer (for misting)

#15

I just rewrote it not sure what was missing

0 Likes

#16

:rofl: Don’t you have the “original” still in the IDE files

PS, you could have gone back and edited the initial posts instead of adding more and more :wink:

Ayhow, enough posting lessons for today… If I interpret your code correctly you should be getting serial prints for whatever values your widgets are putting out, each time the widget is “pressed or moved”. So what is wrong?

0 Likes

#17

I get an error "expected constructor, destructor, or type conversion before ‘*’ token and the line highlighted is

BLYNK_WRITE (V2) // Time interval for delay 5-120 seconds

0 Likes

#18

OK, so I am guessing all this time you are not using your own code… otherwise you would probably have some ideas on how to write the functions… and what you have been posting is no help as I don’t know what you started with vs what you have been placing unformatted into these posts.

Look through the Help files and Documentation, even the Sketch Builder for proper syntax of Blynk functions etc.

0 Likes

#19

OK I will get my head around it…

0 Likes

#20

Lots of examples here as well…

0 Likes

#21

Why do you have the two ‘*’ symbolas before and after BLYNK_WRITE ?

Is this how it looks in your Arduino IDE, or is it something to do with the way you’ve posted your code?

It should look like this:

BLYNK_WRITE(V2) // Time interval for delay 5-120 seconds

Once you fix that error, you’ll also get errors saying that mistruntime and delaytime are not defined within this scope.
That’s because you haven declared these variables. As I said earlier, this declaration needs to happen near the top of your code, like this:

int mistruntime;
int delaytime;

You should insert these two lines just before the start of your void setup.

Pete.

0 Likes

#22

Hi Gunner,

Am I alot closer with this

[code]
/*
 * Turns on a digital output for "RunTime" set by the slider widget 
 * on virtual pin 1, then it will turn off the digital output for 
 * "DelayTime" as set by the slider widget on virtual pin 2. Then repeats
 */


#define BLYNK_PRINT Serial

int RunTime;
int Active = 4;

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Arduino.h"

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";

void setup()
{
  // Debug console
  Serial.begin(9600);
  
  //initialize digital pin as output
  pinMode(Active, OUTPUT);
  
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);


}
BLYNK_WRITE (V1) // Time interval for misting 0.5-10 seconds, with 0.5 second increments

{

RunTime = param.asInt(); // assigning incoming value from pin V1 to the variable RunTime

serial.println(RunTime);

}

**BLYNK_WRITE** (V2) // Time interval for delay 5-120 seconds, with whole second increments

{

DelayTime = param.asInt(); // assigning incoming value from pin V2 to the variable DelayTime

serial.println(DelayTime);
{
void loop()
{
  digitalWrite(Active, HIGH);
  delay(1000*RunTime);
  digitalWrite(Active, LOW);
  delay(1000*DelayTime);
  Blynk.run();
}
[/code]
0 Likes

#23

Thanks Pete, could you have a look at revision I have just pasted?
It’s done my head in, too much for a beginner, I might continue on tomorrow.

Thanks to both of you and more importantly for your patience. I WILL get there!

0 Likes

#24

Your revision is MUCH worse!

That stuff in your void loop will kill the Blynk process, and you’ve got some random unneeded pinmode declaration in there for some reason.
Go back to the earlier version, sort out the ** characters, declare your variables then tell us what results you’re getting.

Pete.

0 Likes

#25

oopsy, fresh start tomorrow.
I am thinking a bit like excel…

User to enter x and y values and tells it when to start, excel does the rest and calculates it.

ok I will revert, with a fresh head tomorrow :scream:

0 Likes

#26

Ok I thought I would have one last crack for the evening…

This is what I pasted. At first I had an error saying mistruntime was not declared in this scope. So I though maybe I had to declare them as I did below
int mistruntime;
int delaytime;

But now with that I have a new error saying ‘serial’ was not declared in this scope
Now it’s time to recharge my batteries and have a good sleep, again thank you both for your patience.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int mistruntime;
int delaytime;


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}
BLYNK_WRITE (V1) // Time interval for misting 0.5-10 seconds

{

mistruntime = param.asInt(); // assigning incoming value from pin V1 to a variable

serial.println(mistruntime);

}

BLYNK_WRITE (V2) // Time interval for delay 5-120 seconds

{

delaytime = param.asInt(); // assigning incoming value from pin V2 to a variable

serial.println(delaytime);
void loop()
{
  Blynk.run();
}
0 Likes

#27

OK… you must have an opening and closing bracket in a function… your one BLYNK_WRITE() function is missing it’s closing bracket and your compiler is basically confused :stuck_out_tongue:

Try to lay out things with self-determined spacing between functions and such, so you can look at things and get a feel for it at a glance… instead of lots of random extra lines and spacing

I tend to do it this way with single spacing between specific sections of code and triple spacing in between functions

int something;  // Declaring something as a global variable



BLYNK_WRITE(vPin)  {  // *** opening bracket
something = param.asInt();  // Get my value from my widget
// stuff that perhaps does things based on something
// then calls some other related function
function();
}  // *** closing bracket



void function()  {   // *** opening bracket
// stuff that takes something and does this
// and this
// and this

// then stuff that does that
// and that

// finally, stuff that does the other
}  // *** closing bracket
0 Likes

#28

Also, serial and Serial are two tolally different things as far as C++ is concerned.

You’ve used the correct capitalised Serial in your Serial.begin statement, but an incorrect lower case version in your serial.println statement.

Pete.

1 Like

#29

Thanks Guys,

I edited the sketch and uploaded. It is reading the values from the 2 sliders - although to not one decimal place - do I need to change int to float?

[code]
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int mistruntime;
int delaytime;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

BLYNK_WRITE (V1) // Time interval for misting 0.5-10 seconds
{
mistruntime = param.asInt(); // assigning incoming value from pin V1 to a variable

Serial.println(mistruntime);
}

BLYNK_WRITE (V2) // Time interval for delay 5-120 seconds
{
delaytime = param.asInt(); // assigning incoming value from pin V2 to a variable

Serial.println(delaytime);
}
void loop()
{
  Blynk.run();
}
[/code]
0 Likes

#30

Since integers are Whole numbers, then yes, if you need Fractionals change to float mistruntime; etc. You can also set your slider settings accordingly for number of decimal places it will account for when sending.

0 Likes

#31

Thanks Gunner

I changed them to float variables. Now the data is showing to 2 decimal places but it’s still rounded to a whole number essentially.

Do I need to change param.asInt() to param.asfloat()?

0 Likes

#32

Sorry, yes, otherwise it is just converting the incoming float back to int :stuck_out_tongue:

0 Likes

#33

Thanks. So now I have this code that seems to be interpreting the data correctly and storing that as a variable. (Only need run time as a float)

Any tips for the next step?

[code]
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

float mistruntime;
int delaytime;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***";
char pass[] = "***";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

BLYNK_WRITE (V1) // Time interval for misting 0.5-10 seconds
{
mistruntime = param.asFloat(); // assigning incoming value from pin V1 to a variable

Serial.println(mistruntime);
}

BLYNK_WRITE (V2) // Time interval for delay 5-120 seconds
{
delaytime = param.asInt(); // assigning incoming value from pin V2 to a variable

Serial.println(delaytime);
}
void loop()
{
  Blynk.run();
}
[/code]
0 Likes

#34

Now set up a timed function (via BlynkTimer) that will check every x amount of minutes/hours and do something based on your input parameters.

0 Likes