Problem compiling Blynk lib / Arduino

Hello,

I am new to Blynk and I have a project to start but I was first trying to get familiar with the environment.
I am not using the Arduino IDE for my projects but VSCode + PlatformIO

At the moment I am just testing on an Arduino Clone : Arduino Due ATMega168
I am using the Blynk example below and run into compiling issues in VSCode/PIO
I tried on the Arduino IDE and it compiles and run perfectly (I did test with the Blynk app on my iPhone and it all works perfectly)

In VSCode/PIO I have just created a new project with my matching device and have included the Blynk library (see below the PlatformIO.ini file)

When I compile in VSCode I get the following errors:

> Executing task in folder RainSensor: pio run --environment diecimilaatmega168 <

Processing diecimilaatmega168 (platform: atmelavr; board: diecimilaatmega168; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/diecimilaatmega168.html
PLATFORM: Atmel AVR (3.0.0) > Arduino Duemilanove or Diecimila ATmega168
HARDWARE: ATMEGA168 16MHz, 1KB RAM, 14KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES: 
 - framework-arduino-avr 5.1.0 
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Blynk> 0.6.5
|-- <SoftwareSerial> 1.0
Building in release mode
Compiling .pio/build/diecimilaatmega168/src/main.cpp.o
Compiling .pio/build/diecimilaatmega168/libd00/Blynk/utility/BlynkDebug.cpp.o
Compiling .pio/build/diecimilaatmega168/libd00/Blynk/utility/BlynkHandlers.cpp.o
Compiling .pio/build/diecimilaatmega168/libd00/Blynk/utility/BlynkTimer.cpp.o
In file included from .pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkHandlers.h:15:0,
                 from .pio/libdeps/diecimilaatmega168/Blynk/src/utility/BlynkHandlers.cpp:11:
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::iterator::asLongLong() const':
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h:38:59: error: 'atoll' was not declared in this scope
         long long   asLongLong() const  { return atoll(ptr); }
                                                           ^
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::asLongLong() const':
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h:77:56: error: 'atoll' was not declared in this scope
     long long   asLongLong() const  { return atoll(buff); }
                                                        ^
*** [.pio/build/diecimilaatmega168/libd00/Blynk/utility/BlynkHandlers.cpp.o] Error 1
In file included from .pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkApi.h:16:0,
                 from .pio/libdeps/diecimilaatmega168/Blynk/src/BlynkApiArduino.h:14,
                 from .pio/libdeps/diecimilaatmega168/Blynk/src/Adapters/BlynkSerial.h:18,
                 from .pio/libdeps/diecimilaatmega168/Blynk/src/BlynkSimpleStream.h:18,
                 from src/main.cpp:39:
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::iterator::asLongLong() const':
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h:38:59: error: 'atoll' was not declared in this scope
         long long   asLongLong() const  { return atoll(ptr); }
                                                           ^
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h: In member function 'long long int BlynkParam::asLongLong() const':
.pio/libdeps/diecimilaatmega168/Blynk/src/Blynk/BlynkParam.h:77:56: error: 'atoll' was not declared in this scope
     long long   asLongLong() const  { return atoll(buff); }
                                                        ^
*** [.pio/build/diecimilaatmega168/src/main.cpp.o] Error 1
========================================================= [FAILED] Took 1.35 seconds =========================================================
The terminal process "pio 'run', '--environment', 'diecimilaatmega168'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

The platformio.ini file looks like this:

[env:diecimilaatmega168]
platform = atmelavr
board = diecimilaatmega168
framework = arduino
upload_port = /dev/cu.wchusbserial1410
monitor_port = /dev/cu.wchusbserial1410
monitor_speed = 9600
lib_deps = blynkkk/Blynk@^0.6.5

The Blynk code example (that works with the Arduino IDE)

#define <Arduino.h>

#define BLYNK_PRINT SwSerial


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

#include <BlynkSimpleStream.h>

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

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget
BLYNK_WRITE(V1)
{

  // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
  if (String("Marco") == param.asStr()) {
    terminal.println("You said: 'Marco'") ;
    terminal.println("I said: 'Polo'") ;
  } else {

    // Send it back
    terminal.print("You said:");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
  }

  // Ensure everything is sent
  terminal.flush();
}

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

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  // Clear the terminal content
  terminal.clear();

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println(F("-------------"));
  terminal.println(F("Type 'Marco' and get a reply, or type"));
  terminal.println(F("anything else and get it printed back."));
  terminal.flush();
}

void loop()
{
  Blynk.run();
}

Thanks a lot for your help!
Eric

#define <Arduino.h>? This must absolutely be #include <Arduino.h>

You’re right, this is uncompilable with the 0.6.5 version (even when fixing #include <Arduino.h>) but works in their previously released version 0.6.1. You found a bug.

I’ve opened Cannot compile anymore with 0.6.5, works on 0.6.1 · Issue #505 · blynkkk/blynk-library · GitHub to address this with the library authors. A workaround is also there.

You can double check that the library version in the Arduino IDE is also the (now outdated) 0.6.1 version that works.

Actually, it can be solved in the new version by disabling long long integer support in the library. See comment in issue.

Thanks a million for this quick and clear answer!

oops my bad about the #define of course in my VSCode/PIO code it was actually #include and not #define (was a bad copy/paste as obviously I did not use this include in the arduino IDE from which I did the copy/paste of the code example).

In any case as you mentioned this is not the issue with the Blynk lib.
and you’re absolutely right, in the Arduino IDE this is the 0.6.1 which is installed!

I will try the workaround you mention.

Again thank you very much, I’ve been struggling 2 or 3 hours on it trying to figure out what I was doing wrong.
Really appreciate your help!

At the moment I have uninstalled the latest 0.6.5 (It was released 5 days ago) and installed the 0.6.1…no more build issues