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