Need Support with Arduino Wifi Rev2 and BlynkCloud

Hi there,
can anyone please get me some hints to solve the following issue I am not able to overcome:
I am using the following:
Arduino Wifi Rev2
I have added the Blynk library using the library manager. My code includes: #include <BlynkSimpleWiFiNINA.h>

When using the latest library version for Blynk 1.01 I am getting the compiling error:

…Wifi_Strom_Spg\Wifi_Strom_Spg.ino:6:
C:\Users\Andreas\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkConsole.h:20:10: fatal error: functional: No such file or directory…
This problem was solved some time ago by going back to Blynk library version 0.61.
I did and the compiling error disappeared.
BUT, even though I have correctly used:
#define BLYNK_TEMPLATE_ID “…”
#define BLYNK_DEVICE_NAME “…”
#define BLYNK_AUTH_TOKEN “…”
in my code the device can not connect to BlynkConsole.
The device is connected to my router, stated by serial monitor, but I get the error:
[12857] Invalid auth token

Well, this probem was solved as well: Update the Blynk library to at leats version 1.00

Sure, I do , but then I am back to my compiling error…

I am in an endless loop here.
Any support is highly appreciated.
Thanks a lot in advance !!!

Hi Andyy,

Are you sure the Auth_Token you provide exists in Blynk? (Device should be created in Console first in case of using static provision)

To be honest, I’m surprised that you’ve made it this far, as there is an unresolved issue with this board type in Blynk IoT…

Maybe if you post your full sketch, and details of the settings you are using in the IDE it would help?

Don’t forget to use triple backticks at the beginning and end of your sketch when you post it. Triple backticks look like this:
```

Pete.

Hi Pete,
thanks a lot. I think I did read dozens of specifically your replies regarding this topic last few days and it seems - as you already stated - it is an unresolved issue.
I wanted to use this specific board with Blynk in upcoming summer course with my students. Looks like I need to alter my plan, even though I liked the idea of building a smart meter and blynk as a great topic for our young engineeres. No time to shop for new devices now.
Sure, I can start trying working around the glitch in the library (long long declaration and atoll()) but my experience says that this may even open pandoras box on another topic.
Thanks again and once you read this message I will close later today this post since there is no work around this issue.
Sincerely Andreas

I’m a bit confused by your response.
You appear to have managed to get past the compiler error to a point where you were able to upload the code and are now getting an “ Invalid auth token” message.

Am I missing something here?

Pete.

Also, there is another option…

You could use the Rev2 boards to send/receive data to/from a computer running an MQTT broker and Node-Red. This could then link to Blynk via the Blynk plug-in for Node-Red.

The MQTT broker/Node-Red server could run an a Windows machine on your network, which could be a fairly basic spec.

This is the basis for my home automation systems (although I use a Raspberry Pi as my broker/server rather than a Windows machine). The Mosquitto MQTT broker and Node-Red are all free, as is the Blynk plug-in for Node-Red.

Pete.

Hi Pete,

thanks a lot - specifically for sending me insights in your home automation project. Really interesting.
Regarding your first statement: I get the code compiled and uploaded, but only with Blynk library version 0.61. But this comes with an invalid auth. token message. I also found certain posts regarding this where the conclusion was made, that at least Blynk library version 1 (or higher) has to be installed for getting a valid connection to blynk.cloud. Well, here starts the problem: neither Blynik library 1.0 nor 1.01 works - it stops with above shown compiling errors.
Thanks again and with best wishes to you
Andreas

Yes, that makes sense now.
The 0.6.1 library won’t work with the new blynk.cloud servers, so when it connects to the old blynk-cloud.com servers it can’t find your project because it doesn’t exist there.

Pete.

Thanks, Pete !

Hi Pete,
even though I dint want I was spending quite some time yesterday with forensic work on the Blynk libraries (latest version, 1.01) to find why Arduino Wifi Rev2 can not work with Blynk.Cloud and Blynk library (>ver 0.61). Looking at the specific error during compliation I got I was able to identify one specific library:BlynkParam.h inside …Arduino\libraries\Blynk\src\Blynk
The library BlynkParam.h shows two lines of code: return atoll () but in fact atoll does not exist, it is return atol (). When changing two entries in this specific library (return atoll(buff) to return atol(buff)) my Arduino wifi was up and running I got an email from your Maria stating that my device is online, I see my device in the cloud and I was able to upload your demo code Blynk Simple Demo with successfull mobile app interaction. May I ask you to verify if atoll () was indeed a spelling error and should be replaced by atol(). At least it worked well for me. Thanks, Andreas

2 Likes

Excellent work!

@vshymanskyy - for info… (hope you are okay by the way :heart:)

Pete.

1 Like

Thanks so much.
Looking forward for an interesting project now with my students.
All the best to all of you
Andreas

hello! i’ve followed your steps and edited the codes but it shows this.

Arduino: 1.8.19 (Mac OS X), Board: “Arduino Uno WiFi Rev2, ATMEGA328”

BlynkParam1_test:16:10: fatal error: Blynk/BlynkParam1_test.h: No such file or directory
#include <Blynk/BlynkParam1_test.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Blynk/BlynkParam1_test.h: No such file or directory

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

@hellosnakie all you have to do is go to blynk/src/blynk/blynkparam.h file then use any text editing software for example notepad++ to replace atoll with atol.
You can use find and replace feature to replace all atolls with a single button click.

hello @John93! thank you for your prompt reply. i’ve replaced all “atoll” with “atol” & the error still persists. :frowning:

Arduino: 1.8.19 (Mac OS X), Board: “Arduino Uno WiFi Rev2, ATMEGA328”

BlynkParam:16:10: fatal error: Blynk/BlynkConfig.h: No such file or directory

  • #include <Blynk/BlynkConfig.h>*
  •      ^~~~~~~~~~~~~~~~~~~~~*
    

compilation terminated.
exit status 1
Blynk/BlynkConfig.h: No such file or directory

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

#ifndef BlynkParam_h
#define BlynkParam_h

#include <string.h>
#include <stdlib.h>
#include <Blynk/BlynkConfig.h>
#include <Blynk/BlynkDebug.h>

#define BLYNK_PARAM_KV(k, v) k "\0" v "\0"
#define BLYNK_PARAM_PLACEHOLDER_64 "PlaceholderPlaceholderPlaceholderPlaceholderPlaceholderPlaceholder"

#if !defined(BLYNK_NO_FLOAT)
extern char*        dtostrf_internal(double number, signed char width, unsigned char prec, char *s);
#endif

#if !defined(BLYNK_NO_LONGLONG)
extern long long    atol_internal(const char *s);
#endif

class BlynkParam
{
public:
    class iterator
    {
    public:
        iterator(const char* c, const char* l) : ptr(c), limit(l) {}
        static iterator invalid() { return iterator(NULL, NULL); }

        operator const char* () const   { return asStr(); }
        operator int () const           { return asInt(); }
        const char* asStr() const       { return ptr; }
        const char* asString() const    { return ptr; }
        int         asInt() const       { if(!isValid()) return 0; return atoi(ptr); }
        long        asLong() const      { if(!isValid()) return 0; return atol(ptr); }
#if !defined(BLYNK_NO_LONGLONG) && defined(BLYNK_USE_INTERNAL_ATOL)
        long long   asLongLong() const  { return atol_internal(ptr); }
#elif !defined(BLYNK_NO_LONGLONG)
        long long   asLongLong() const  { return atol(ptr); }
#endif
#if !defined(BLYNK_NO_FLOAT)
        double      asDouble() const    { if(!isValid()) return 0; return atof(ptr); }
        float       asFloat() const     { if(!isValid()) return 0; return atof(ptr); }
#endif
        bool isValid() const            { return ptr != NULL && ptr < limit; }
        bool isEmpty() const            { if(!isValid()) return true; return *ptr == '\0'; }

        bool operator <  (const iterator& it) const { return ptr < it.ptr; }
        bool operator >= (const iterator& it) const { return ptr >= it.ptr; }

        iterator& operator ++() {
            if(isValid()) {
                ptr += strlen(ptr) + 1;
            }
            return *this;
        }
    private:
        const char* ptr;
        const char* limit;
    };

public:
    explicit
    BlynkParam(const void* addr, size_t length)
        : buff((char*)addr), len(length), buff_size(length)
    {}

    explicit
    BlynkParam(void* addr, size_t length, size_t buffsize)
        : buff((char*)addr), len(length), buff_size(buffsize)
    {}

    const char* asStr() const       { return buff; }
    const char* asString() const    { return buff; }
    int         asInt() const       { return atoi(buff); }
    long        asLong() const      { return atol(buff); }
#if !defined(BLYNK_NO_LONGLONG) && defined(BLYNK_USE_INTERNAL_ATOL)
    long long   asLongLong() const  { return atol_internal(buff); }
#elif !defined(BLYNK_NO_LONGLONG)
    long long   asLongLong() const  { return atol(buff); }
#endif
#if !defined(BLYNK_NO_FLOAT)
    double      asDouble() const    { return atof(buff); }
    float       asFloat() const     { return atof(buff); }
#endif
    bool isEmpty() const            { return *buff == '\0'; }

    iterator begin() const { return iterator(buff, buff+len); }
    iterator end() const   { return iterator(buff+len, buff+len); }

    iterator operator[](int index) const;
    iterator operator[](const char* key) const;

    void*  getBuffer() const { return (void*)buff; }
    size_t getLength() const { return len; }
    size_t getBuffSize() const { return buff_size; }

    // Modification
    void clear() { len = 0; }

    void add(int value);
    void add(unsigned int value);
    void add(long value);
    void add(unsigned long value);
    void add(long long value);
    void add(unsigned long long value);
#ifndef BLYNK_NO_FLOAT
    void add(float value);
    void add(double value);
#endif
    void add(const char* str);
    void add(const void* b, size_t l);
#if defined(ARDUINO) || defined(SPARK) || defined(PARTICLE)
    void add(const String& str);
#if defined(BLYNK_HAS_PROGMEM)
    void add(const __FlashStringHelper* str);
#endif
#endif

    template<typename T, typename... Args>
    void add_multi(T last) {
        add(last);
    }

    template<typename T, typename... Args>
    void add_multi(T head, Args... tail) {
        add(head);
        add_multi(tail...);
    }

    template <typename TV>
    void add_key(const char* key, const TV& val) {
        add(key);
        add(val);
    }

    void remove_key(const char* key);

protected:
    char*    buff;
    size_t   len;
    size_t   buff_size;
};


class BlynkParamAllocated
    : public BlynkParam
{
public:
    BlynkParamAllocated(size_t size)
        : BlynkParam(malloc(size), 0, size)
    {}
    ~BlynkParamAllocated() {
        free(buff);
    }
};

inline
BlynkParam::iterator BlynkParam::operator[](int index) const
{
    const iterator e = end();
    for (iterator it = begin(); it < e; ++it) {
        if (!index--) {
            return it;
        }
    }
    return iterator::invalid();
}

inline
BlynkParam::iterator BlynkParam::operator[](const char* key) const
{
    const iterator e = end();
    for (iterator it = begin(); it < e; ++it) {
        if (!strcmp(it.asStr(), key)) {
            return ++it;
        }
        ++it;
        if (it >= e) break;
    }
    return iterator::invalid();
}

inline
void BlynkParam::remove_key(const char* key)
{
    bool found;
    do {
        found = false;
        const iterator e = end();
        for (iterator it = begin(); it < e; ++it) {
            if (!strcmp(it.asStr(), key)) {
                const char* key = it.asStr();
                ++it; ++it;
                const char* next = it.asStr();
                memmove((void*)key, next, (buff+len)-next);
                len -= (next-key);
                found = true;
                break;
            }
            ++it;
            if (it >= e) break;
        }
    } while (found);
}

inline
void BlynkParam::add(const void* b, size_t l)
{
    if (len + l > buff_size)
        return;
    memcpy(buff+len, b, l);
    len += l;
}

inline
void BlynkParam::add(const char* str)
{
    if (str == NULL) {
        buff[len++] = '\0';
        return;
    }
    add(str, strlen(str)+1);
}

#if defined(ARDUINO) || defined(SPARK) || defined(PARTICLE)
inline
void BlynkParam::add(const String& str)
{
#if defined(ARDUINO_AVR_DIGISPARK) \
    || defined(__ARDUINO_X86__) \
    || defined(__RFduino__)

    size_t len = str.length()+1;
    char buff[len];
    const_cast<String&>(str).toCharArray(buff, len);
    add(buff, len);
#else
    add(str.c_str());
#endif
}

#if defined(BLYNK_HAS_PROGMEM)

inline
void BlynkParam::add(const __FlashStringHelper* ifsh)
{
    PGM_P p = reinterpret_cast<PGM_P>(ifsh);
    size_t l = strlen_P(p) + 1;
    if (len + l > buff_size)
        return;
    memcpy_P(buff+len, p, l);
    len += l;
    buff[len] = '\0';
}

#endif

#endif

#if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32)

    #include <stdlib.h>

    inline
    void BlynkParam::add(int value)
    {
        char str[2 + 8 * sizeof(value)];
        itoa(value, str, 10);
        add(str);
    }

    inline
    void BlynkParam::add(unsigned int value)
    {
        char str[1 + 8 * sizeof(value)];
        utoa(value, str, 10);
        add(str);
    }

    inline
    void BlynkParam::add(long value)
    {
        char str[2 + 8 * sizeof(value)];
        ltoa(value, str, 10);
        add(str);
    }

    inline
    void BlynkParam::add(unsigned long value)
    {
        char str[1 + 8 * sizeof(value)];
        ultoa(value, str, 10);
        add(str);
    }

    inline
    void BlynkParam::add(long long value)  // TODO: this currently adds just a long
    {
        char str[2 + 8 * sizeof(value)];
        ltoa(value, str, 10);
        add(str);
    }

    inline
    void BlynkParam::add(unsigned long long value) // TODO: this currently adds just a long
    {
        char str[1 + 8 * sizeof(value)];
        ultoa(value, str, 10);
        add(str);
    }

#ifndef BLYNK_NO_FLOAT

    inline
    void BlynkParam::add(float value)
    {
        char str[33];
        dtostrf(value, 5, 3, str);
        add(str);
    }

    inline
    void BlynkParam::add(double value)
    {
        char str[33];
        dtostrf(value, 5, 7, str);
        add(str);
    }
#endif

#else

    #include <stdio.h>

    inline
    void BlynkParam::add(int value)
    {
        len += snprintf(buff+len, buff_size-len, "%i", value)+1;
    }

    inline
    void BlynkParam::add(unsigned int value)
    {
        len += snprintf(buff+len, buff_size-len, "%u", value)+1;
    }

    inline
    void BlynkParam::add(long value)
    {
        len += snprintf(buff+len, buff_size-len, "%li", value)+1;
    }

    inline
    void BlynkParam::add(unsigned long value)
    {
        len += snprintf(buff+len, buff_size-len, "%lu", value)+1;
    }

    inline
    void BlynkParam::add(long long value)
    {
        len += snprintf(buff+len, buff_size-len, "%lli", value)+1;
    }

    inline
    void BlynkParam::add(unsigned long long value)
    {
        len += snprintf(buff+len, buff_size-len, "%llu", value)+1;
    }

#ifndef BLYNK_NO_FLOAT

#if defined(BLYNK_USE_INTERNAL_DTOSTRF)

    inline
    void BlynkParam::add(float value)
    {
        char str[33];
        dtostrf_internal(value, 5, 3, str);
        add(str);
    }

    inline
    void BlynkParam::add(double value)
    {
        char str[33];
        dtostrf_internal(value, 5, 7, str);
        add(str);
    }

#else

    inline
    void BlynkParam::add(float value)
    {
        len += snprintf(buff+len, buff_size-len, "%2.3f", value)+1;
    }

    inline
    void BlynkParam::add(double value)
    {
        len += snprintf(buff+len, buff_size-len, "%2.7f", value)+1;
    }

#endif

#endif

#endif


#endif

Here’s the modified file
https://mega.nz/file/Rc9BQT4A#yc3IhuBNn02C0yODmrm9DBROdhecLhgyQtGFye1-U1U

@hellosnakie Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

@PeteKnight noted!

@John93 thank you for your reply! :slight_smile: I’ve used the modified file attached but the following error still exists. (line 16 showed in the screenshot attached)

Arduino: 1.8.19 (Mac OS X), Board: “Arduino Uno WiFi Rev2, ATMEGA328”

BlynkParam:16:10: fatal error: Blynk/BlynkConfig.h: No such file or directory
#include <Blynk/BlynkConfig.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Blynk/BlynkConfig.h: No such file or directory

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

Have you tried uninstall/reinstall ?