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

BlynkTimer.h Simpletimer confrontation

arduino

#1

Since

Blynk has a problem with SimpleTimer didnt worked together, because of this:

    /tmp/759171214/custom/Blynk/src/Blynk/BlynkTimer.h:38:36: error: conflicting declaration 'typedef void (* timer_callback)()'
    typedef void (*timer_callback)(void);
    ^
    In file included from /tmp/759171214/blynk_audio/blynk_audio.ino:35:0:
    /tmp/759171214/custom/SimpleTimer/SimpleTimer.h:42:35: error: 'timer_callback' has a previous declaration as 'typedef class std::function<void()> timer_callback'
    typedef std::function<void(void)> timer_callback;
    ^
    /tmp/759171214/blynk_audio/blynk_audio.ino: In function 'void setup()':
    /tmp/759171214/blynk_audio/blynk_audio.ino:83:3: error: 'timer' was not declared in this scope
    timer.setInterval(1000,soundFreq);
    ^
    /tmp/759171214/blynk_audio/blynk_audio.ino: In function 'void loop()':
    /tmp/759171214/blynk_audio/blynk_audio.ino:130:3: error: 'timer' was not declared in this scope
    timer.run();
    ^
    exit status 1

my code

    #include <Arduino.h>
    #undef max
    #undef min
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    // SimpleTimer - Version: Latest 
    #include <SimpleTimer.h>
    #include <FHT.h> //source http://wiki.openmusiclabs.com/wiki/ArduinoFHT?action=AttachFile&do=view&target=ArduinoFHT4.zipt&target=ArduinoFHT4.zip
    #include <AudioAnalyzer.h>//source image.dfrobot.com/image/data/DFR0126/library/AudioAnalyzer%20v1.3.zip
    #include <SPI.h>
    #include <WiFi101.h>
    #include <BlynkSimpleMKR1000.h>

    //------------Initialize the variables for the AUDIO sensor

    #define SoundSensorPin A0  //this pin read the analog voltage from the sound level meter
    #define VREF  5.0 

    //to identify which freq band range is the loudest,
    // its need to be labelled by its peak num
    // Always show the max magnitude from the sound signal

    Analyzer Audio = Analyzer(4,5,0);//Strobe pin ->4  RST pin ->5 Analog Pin ->0
    //Analyzer Audio = Analyzer();//Strobe->4 RST->5 Analog->0 
    //String FreqNames[] = {"63", "160","400", "1K","2.5K", "6.25K","16K"};
    int FreqNames[] = {63,160,400,1000,2500,6500,16000};
    int FreqVal[7];//
    int max_index;//
    //int hz = 0;
    float voltageValue,dB;



    //to identify the testperson
    int testperson = 1;

    // Create instance of WiFi client
    WiFiClient client;
   
    char auth[] = "";

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

    SimpleTimer timer;

    void setup()
    {
      // Debug console
      Serial.begin(57600);
      Audio.Init();//Init module

      Blynk.begin(auth, ssid, pass);
      timer.setInterval(1000,soundSensor);
      //timer.setInterval(1010,soundVol);
      //timer.setInterval(1020,testp);
    }

    void soundSensor()
    {
      Audio.ReadFreq(FreqVal);//return 7 value of 7 bands pass filiter 
                              //Frequency(Hz):63  160  400  1K  2.5K  6.25K  16K
                              //FreqVal[]:      0    1    2    3    4    5    6  magnitude
      max_index = 0;
        for(int i=1; i<7; i++)   //         
      {
        if (FreqVal[max_index] < FreqVal[i]) max_index = i;
      }
      if(FreqNames[max_index])
      {
      Serial.println("Frequenzy: ");
      Serial.print(FreqNames[max_index]);
      Serial.print("hz");
      Blynk.virtualWrite(V0,FreqNames[max_index]);
      }
      delay(10);
      
      voltageValue = analogRead(SoundSensorPin) / 1024.0 * VREF;
      dB = voltageValue * 50.0;
      if(dB) 
      {
      Serial.println("Volume: ");
      Serial.print(dB);
      Serial.print("dB");
      Blynk.virtualWrite(V1, dB);
      }
      delay(20);
      
      if(testperson)
      {
      Serial.println("testperson: ");
      Serial.print(testperson);
      Blynk.virtualWrite(V2, testperson);
      }
      delay(40);
    }

    void loop()
    {
        // Connects to the WiFi
      // If the network does not need a password: WiFi.begin(ssid);
      WiFi.begin(ssid, pass);
      //delay(10000);   // Waits 10 seconds to confirm connection
      
      // Print WiFi strength information
      Blynk.run();
      timer.run();
      printCurrentNet() ;
      
      // Disconnects from the WiFi
      //WiFi.disconnect();
    }
    void printCurrentNet() {
      // Print the WiFi signal strength:
      long rssi = WiFi.RSSI();
      Serial.print("Signal strength (RSSI): ");
      Serial.print(rssi);
      Serial.println(" dBm");
    }

If the Simpletimer is excluded Arduino is verified the code and its connecting but Blynk doesnt seems to read anything


#2

solved


#3

To clarify this issue/solution.

As per the Documentation … BlynkTimer has long since replaced SimpleTimer by being embedded into the Blynk Library and thus no need to include SimpleTimer library anymore. Otherwise it’s operation and commands work the same, even improved.

Closing this topic.


#4