BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Anenometer - Blynk

Hi. I need connect anenometer to ESP8266 Devkit but i dont know how i can change sketch…
Here is sketch for Arduino and this sketch is working but in sketch is not declare pin D3…
Thanks.

http://www.bosblog.cz/index.php/2018/03/14/anemometer-a-arduino-nano/

const int m_time = 5;      //Meassuretime in Seconds
int wind_ct = 0;
float wind = 0.0;
unsigned long time = 0;


void setup()
{
  Serial.begin(9600);
  time = millis();
}

void loop()
{

  meassure();

  Serial.print("Windgeschwindigkeit: ");
  Serial.print(wind);       //Speed in Km/h
  Serial.print(" km/h - ");
  Serial.print(wind / 3.6); //Speed in m/s
  Serial.println(" m/s");

}

void countWind() {
  wind_ct ++;
}

void meassure() {
  wind_ct = 0;
  time = millis();
  attachInterrupt(1, countWind, RISING);
  delay(1000 * m_time);
  detachInterrupt(1);
  wind = (float)wind_ct / (float)m_time * 2.4;
}

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

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

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

 const int hallPin=3;
 volatile byte half_revolutions;
 unsigned int rpm, ms, kmh, maxMs, h1_2, m1_2, h3_4, m3_4, h5_6, m5_6, h7_8, m7_8, h9_10, m9_10, h11, m11, h3, m3, d1_2, d3_4, d5_6, d7_8, d9_10, d11, d3;
 unsigned long  count1_2, count3_4, count5_6, count7_8, count9_10, count_11, count_3;
 unsigned int den = 86400;
 unsigned int hodina = 3600;
 unsigned int minuta = 60;
 String zacatekMereni = "20.02.2017";

 SimpleTimer timer;

// This function will run every time Blynk connection is established
BLYNK_CONNECTED() {
  //get data stored in virtual pin V0 from server
  Blynk.syncVirtual(V30);
}

// restoring counter from server
BLYNK_WRITE(V30){
  //restoring int value
  maxMs = param[0].asInt();
  count1_2 = param[1].asLong();
  count3_4 = param[2].asLong();
  count5_6 = param[3].asLong();
  count7_8 = param[4].asLong();
  count9_10 = param[5].asLong();
  count_11 = param[6].asLong();
  count_3 = param[7].asLong();
}



void setup(){
   pinMode(hallPin,INPUT);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  attachInterrupt(digitalRead(hallPin), rpm_fun, RISING);
   half_revolutions = 0;
   rpm = 0;
   ms = 0;
   kmh = 0;

   timer.setInterval(3000L, mereniRPM); //kazdy tri vteriny vypocte ze signalu udaje
   timer.setInterval(600000L, zaloha); //kazdych 10 minut ulozi data na blynk server
   timer.setInterval(60000L, vypocet); //kazdou minutu vypocita udaje a posle na blynk
}

void zaloha(){
Blynk.virtualWrite(V30, maxMs, count1_2, count3_4, count5_6, count7_8, count9_10, count_11, count_3);
 }
 
void mereniRPM(){  
     rpm = (half_revolutions*20)/3;
     ms = half_revolutions/7;
     kmh = half_revolutions/2;
     
if (ms > maxMs) maxMs = ms;
if ((ms == 1)||(ms == 2)) count1_2 += 3;
if ((ms == 3)||(ms == 4)) count3_4 += 3;
if ((ms == 5)||(ms == 6)) count5_6 += 3;
if ((ms == 7)||(ms == 8)) count7_8 += 3;
if ((ms == 9)||(ms == 10)) count9_10 += 3;
if (ms >= 11) count_11 += 3;
if (ms >= 3) count_3 += 3;
     
//     Serial.println(half_revolutions,DEC); //pocet signalu za 3s. (3 signaly na otacku)
     Blynk.virtualWrite(V1, rpm);
     Blynk.virtualWrite(V2, ms);
     Blynk.virtualWrite(V3, kmh);
     Blynk.virtualWrite(V4, maxMs);

     half_revolutions = 0;
}

void vypocet(){
    d1_2 = count1_2 / den;
    h1_2 = (count1_2 % den) / hodina;
    m1_2 = ((count1_2 % den) % hodina) / minuta;

    d3_4 = count3_4 / den;
    h3_4 = (count3_4 % den) / hodina;
    m3_4 = ((count3_4 % den) % hodina) / minuta;

    d5_6 = count5_6 / den;
    h5_6 = (count5_6 % den) / hodina;
    m5_6 = ((count5_6 % den) % hodina) / minuta;

    d7_8 = count7_8 / den;
    h7_8 = (count7_8 % den) / hodina;
    m7_8 = ((count7_8 % den) % hodina) / minuta;

    d9_10 = count9_10 / den;
    h9_10 = (count9_10 % den) / hodina;
    m9_10 = ((count9_10 % den) % hodina) / minuta;

    d11 = count_11 / den;
    h11 = (count_11 % den) / hodina;
    m11 = ((count_11 % den) % hodina) / minuta;

    d3 = count_3 / den;
    h3 = (count_3 % den) / hodina;
    m3 = ((count_3 % den) % hodina) / minuta;

  if (m1_2 < 10) Blynk.virtualWrite(V5, d1_2, " d  ", h1_2, ":0", m1_2);
  else Blynk.virtualWrite(V5, d1_2, " d  ", h1_2, ":", m1_2);
  
  if (m3_4 < 10) Blynk.virtualWrite(V6, d3_4, " d  ", h3_4, ":0", m3_4);
  else Blynk.virtualWrite(V6, d3_4, " d  ", h3_4, ":", m3_4);
    
  if (m5_6 < 10) Blynk.virtualWrite(V7, d5_6, " d  ", h5_6, ":0", m5_6);
  else Blynk.virtualWrite(V7, d5_6, " d  ", h5_6, ":", m5_6);
    
  if (m7_8 < 10) Blynk.virtualWrite(V8, d7_8, " d  ", h7_8, ":0", m7_8);
  else Blynk.virtualWrite(V8, d7_8, " d  ", h7_8, ":", m7_8);
    
  if (m9_10 < 10) Blynk.virtualWrite(V9, d9_10, " d  ", h9_10, ":0", m9_10);
  else Blynk.virtualWrite(V9, d9_10, " d  ", h9_10, ":", m9_10);
    
  if (m11 < 10) Blynk.virtualWrite(V10, d11, " d  ", h11, ":0", m11);
  else Blynk.virtualWrite(V10, d11, " d  ", h11, ":", m11);
    
  if (m3 < 10) Blynk.virtualWrite(V11, d3, " d  ", h3, ":0", m3);
  else Blynk.virtualWrite(V11, d3, " d  ", h3, ":", m3);

  Blynk.virtualWrite(V12, zacatekMereni);
}

void loop(){
  Blynk.run();
  timer.run(); // Initiates SimpleTimer

 }
 void rpm_fun()
 {
   half_revolutions++;
 }
3 Likes

Thanks:-) I try.

So it is working. Thanks

Hi, may I know whats the meaning of #include <version.h> ?

Hey @Ariqah_Huwaida I guess you’re asking about the #include <version.h> because you can’t upload sketch to your board, am I right ?

Yes. Thats right

I need to complete my project but I dont know how to make the coding of anemometer, esp8266 connect to the blynk.

Can you help me?

You probably have an outdated arduino core for the ESP8266, update to the latest version.
also update the arduino ide to the latest version as well.

@Ariqah_Huwaida Your question is very odd, because neither of the sketches in this three and a half year old topic contain the line #include <version.h>

I guess that means that your question isn’t actually related to either of these two sketches, so I assume that you’ve posted the question in the wrong topic?

Pete.