After the introduction of the New Blueprint with Particle! on 31st August 2023, which helps connect Particle devices to Blynk, I tried it out but I am getting errors when compiling the code generated by the Blueprint. I’m using a Core with the latest update. See the below code followed by the error.
#include "Particle.h"
#include <math.h> // This library is only for function simulating a sensor
const char *firmware_version = "0.0.0";
double v15 = 3.14159;
uint32_t simSensor_timer_last = 0; // This is a variable for a function that simulates a sensor
uint8_t led_state = LOW;
bool particle_fn_called = TRUE; // causes the device to publish data immediately after started/boot and connected to the Particle cloud.
// Register the Particle cloud function
int blynkLED(String on_or_off);
/////////////////////////////////////////////////////////////////////////
// Blynk
// Update below with your Blynk auth token for your device (automatically populated by Blueprint)
#define BLYNK_TEMPLATE_ID "<---redacted--->"
#define BLYNK_TEMPLATE_NAME "Connect a Particle device"
#define BLYNK_AUTH_TOKEN "<---redacted--->"
void simSensor() //This function simulates a sensor
{
long sim = random(millis());
if (millis() - simSensor_timer_last >= 20000) {
simSensor_timer_last = millis();
float deltaSensor = cos(float(sim) / 1000) / 100;
if (v15 <= 0 || v15 >= 3.3)
{
v15 = v15 - deltaSensor;
}
else
{
v15 = v15 + deltaSensor;
}
}
} // simSensor
/////////////////////////////////////////////////////////////////////////
bool deviceHasLedOnD7()
{
// Returns TRUE if the device has a built-in LED on D7:
// Boron, Argon, Photon 2, Photon, Electron, Core
// 8: P1
switch (PLATFORM_ID)
{
case PLATFORM_BORON:
case PLATFORM_ARGON:
case 0: // Core
case 6: // Photon (PLATFORM_PHOTON_PRODUCTION)
case 10: // Electron (PLATFORM_ELECTRON_PRODUCTION)
return TRUE;
default:
return FALSE;
}
} // deviceHasLedOnD7()
/////////////////////////////////////////////////////////////////////////
// Timer
const uint32_t TIMER_INTERVAL_MS = 300000L;
uint32_t timer_last = 0;
void pubToParticleBlynk()
{
if (Particle.connected())
{
char data[90]; // See serial output for the actual size in bytes and adjust accordingly.
// Note the escaped double quotes around the ""t"" for BLYNK_AUTH_TOKEN.
snprintf(data, sizeof(data), "{\"t\":\"%s\",\"v14\":%u,\"v15\":%f,\"v16\":%u,\"v17\":%u}", BLYNK_AUTH_TOKEN, millis(), v15, led_state, led_state);
Serial.printlnf("Sending to Blynk: '%s' with size of %u bytes", data, strlen(data));
bool pub_result = Particle.publish("blynk_https_get", data, PRIVATE);
if (pub_result)
{
timer_last = millis();
}
else
{
Serial.println("ERROR: Particle.publish()");
}
}
} // pubToParticleBlynk()
void pubTimer()
{
// A timer for publishing data to Particle Cloud, and then continuing to Blynk.
if (timer_last > millis())
timer_last = millis();
if ((millis() - timer_last) > TIMER_INTERVAL_MS && Particle.connected())
{
pubToParticleBlynk();
timer_last = millis();
}
} // pubTimer()
/////////////////////////////////////////////////////////////////////////
void setup()
{
if (deviceHasLedOnD7() == TRUE)
{
pinMode(D7, OUTPUT);
digitalWrite(D7, LOW);
}
Serial.begin(9600);
waitFor(Serial.isConnected, 30000);
delay(1000);
Serial.printlnf("Device OS v%s", System.version().c_str());
Serial.printlnf("Free RAM %lu bytes", System.freeMemory());
Serial.printlnf("Firmware version v%s", firmware_version);
// register the Particle cloud function (funcKey, funcName)
Particle.function("blynk_led", blynkLED);
Serial.println("Setup complete");
} // setup()
void loop()
{
simSensor(); // This is function simulates a sensor
pubTimer();
if (particle_fn_called == TRUE)
{
particle_fn_called = FALSE;
// Publish data to Particle cloud..
pubToParticleBlynk();
}
if (deviceHasLedOnD7() == TRUE)
{
digitalWrite(D7, led_state);
}
} // loop()
int blynkLED(String on_off)
{
// Custom Particle cloud function that changes the state of the built-in LED
// on D7 in response to an instruction from Blynk calling this
// custom cloud function.
// Returns the value 1 if the LED has been turned on, and 0 if turned off,
// -1 if an unexpected on_off value is received.
// Cloud functions must return int and take one String argument
// curl https://api.particle.io/v1/devices/{your 25 char device id}/blynk_led
// -d access_token={your 40 char access token}
// -d "args=on/off"
if (on_off == "on" || on_off == "1")
{
particle_fn_called = TRUE;
led_state = HIGH;
return 1;
}
else if (on_off == "off" || on_off == "0")
{
particle_fn_called = TRUE;
led_state = LOW;
return 0;
}
else
{
Serial.print("Unexpected on_off value of: '");
Serial.print(on_off);
Serial.println("'");
}
return -1;
} // blynkLED()
HERE IS THE ERROR
Processing blynxparticleexample02.ino
make -C ../newlib_nano
make[1]: Entering directory '/firmware/newlib_nano'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/newlib_nano'
make -C ../user
make[1]: Entering directory '/firmware/user'
Building cpp file: blynxparticleexample02.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-0-lto
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F10X_MD -DPLATFORM_THREADING=0 -DPLATFORM_ID=0 -DPLATFORM_NAME=core -DUSBD_VID_SPARK=0x1D50 -DUSBD_PID_DFU=0x607F -DUSBD_PID_CDC=0x607D -DSPARK_PLATFORM -DFLASHEE_EEPROM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -flto -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=0 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=1.2.1-rc.2 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/src -I../hal/inc -I../hal/shared -I../hal/src/core -I../hal/src/stm32 -I../platform/shared/inc -I../platform/MCU/STM32F1xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F1xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F1xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F1xx/CMSIS/Include -I../platform/MCU/STM32F1xx/CMSIS/Device/ST/Include -I../platform/NET/CC3000/CC3000_Host_Driver -I../dynalib/inc -I -I./libraries -I. -MD -MP -MF ../build/target/user/platform-0-ltoblynxparticleexample02.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLATFORM_NET=CC3000 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DMODULE_VERSION=1211 -DMODULE_FUNCTION=3 -DMODULE_DEPENDENCY=0,0,0 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\"" -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o ../build/target/user/platform-0-ltoblynxparticleexample02.o blynxparticleexample02.cpp
blynxparticleexample02.ino: In function 'void pubToParticleBlynk()':
blynxparticleexample02.ino:71:149: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'system_tick_t {aka long unsigned int}' [-Wformat=]
snprintf(data, sizeof(data), "{\"t\":\"%s\",\"v14\":%u,\"v15\":%f,\"v16\":%u,\"v17\":%u}", BLYNK_AUTH_TOKEN, millis(), v15, led_state, led_state);
^
blynxparticleexample02.ino:71:149: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'system_tick_t {aka long unsigned int}' [-Wformat=]
Building target: ../build/target/user/platform-0-ltolibuser.a
Invoking: ARM GCC Archiver
mkdir -p ../build/target/user/platform-0-lto
arm-none-eabi-gcc-ar -cr ../build/target/user/platform-0-ltolibuser.a ../build/target/user/platform-0-ltoblynxparticleexample02.o
make[1]: Leaving directory '/firmware/user'
make -C ../wiring
make[1]: Entering directory '/firmware/wiring'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/wiring'
make -C ../hal
make[1]: Entering directory '/firmware/hal'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/hal'
make -C ../system
make[1]: Entering directory '/firmware/system'
make -C ../third_party/miniz
make[2]: Entering directory '/firmware/third_party/miniz'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/firmware/third_party/miniz'
make[1]: Leaving directory '/firmware/system'
make -C ../services
make[1]: Entering directory '/firmware/services'
make -C ../third_party/nanopb
make[2]: Entering directory '/firmware/third_party/nanopb'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/firmware/third_party/nanopb'
make[1]: Leaving directory '/firmware/services'
make -C ../communication
make[1]: Entering directory '/firmware/communication'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/communication'
make -C ../platform
make[1]: Entering directory '/firmware/platform'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/platform'
make -C ../wiring_globals
make[1]: Entering directory '/firmware/wiring_globals'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/wiring_globals'
make -C ../crypto
make[1]: Entering directory '/firmware/crypto'
make -C ../third_party/mbedtls
make[2]: Entering directory '/firmware/third_party/mbedtls'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/firmware/third_party/mbedtls'
make[1]: Leaving directory '/firmware/crypto'
Building c file: src/module_info.c
Invoking: ARM GCC C Compiler
mkdir -p target/obj/./src/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F10X_MD -DPLATFORM_THREADING=0 -DPLATFORM_ID=0 -DPLATFORM_NAME=core -DUSBD_VID_SPARK=0x1D50 -DUSBD_PID_DFU=0x607F -DUSBD_PID_CDC=0x607D -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -flto -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=0 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DSYSTEM_VERSION_STRING=1.2.1-rc.2 -DRELEASE_BUILD -Werror -I../user/inc -I../wiring/inc -I../hal/inc -I../hal/shared -I../hal/src/core -I../hal/src/stm32 -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/src -I../platform/shared/inc -I../platform/MCU/STM32F1xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F1xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F1xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F1xx/CMSIS/Include -I../platform/MCU/STM32F1xx/CMSIS/Device/ST/Include -I../platform/NET/CC3000/CC3000_Host_Driver -I../crypto/inc -I../third_party/mbedtls/mbedtls/include -I../dynalib/inc -I. -MD -MP -MF target/obj/./src/module_info.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DMODULE_VERSION=1211 -DMODULE_FUNCTION=3 -DMODULE_DEPENDENCY=0,0,0 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -std=gnu11 -Wno-pointer-sign -c -o target/obj/./src/module_info.o src/module_info.c
Building file: ../build/arm/startup/startup_stm32f10x_md.S
Invoking: ARM GCC Assembler
mkdir -p target/obj/startup/
arm-none-eabi-gcc -g3 -gdwarf-2 -mcpu=cortex-m3 -mthumb -I../build/arm/startup -Wa,--defsym -Wa,SPARK_INIT_STARTUP=1 -x assembler-with-cpp -fmessage-length=0 -c -o target/obj/startup/startup_stm32f10x_md.o ../build/arm/startup/startup_stm32f10x_md.S
Building target: target/workspace.elf
Invoking: ARM GCC C++ Linker
mkdir -p target/
arm-none-eabi-g++ -DSTM32_DEVICE -DSTM32F10X_MD -DPLATFORM_THREADING=0 -DPLATFORM_ID=0 -DPLATFORM_NAME=core -DUSBD_VID_SPARK=0x1D50 -DUSBD_PID_DFU=0x607F -DUSBD_PID_CDC=0x607D -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -flto -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=0 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DSYSTEM_VERSION_STRING=1.2.1-rc.2 -DRELEASE_BUILD -Werror -I../user/inc -I../wiring/inc -I../hal/inc -I../hal/shared -I../hal/src/core -I../hal/src/stm32 -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/src -I../platform/shared/inc -I../platform/MCU/STM32F1xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F1xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F1xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F1xx/CMSIS/Include -I../platform/MCU/STM32F1xx/CMSIS/Device/ST/Include -I../platform/NET/CC3000/CC3000_Host_Driver -I../crypto/inc -I../third_party/mbedtls/mbedtls/include -I../dynalib/inc -I. -MD -MP -MF target/workspace.elf.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DMODULE_VERSION=1211 -DMODULE_FUNCTION=3 -DMODULE_DEPENDENCY=0,0,0 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE target/obj/./src/module_info.o target/obj/startup/startup_stm32f10x_md.o --output target/workspace.elf -nostartfiles -Xlinker --gc-sections -flto -Os -fuse-linker-plugin -Tlinker_stm32f10x_md_dfu.ld -L../build/arm/linker --specs=nano.specs -lc -lnosys -u _printf_float -Wl,-Map,target/workspace.map -L../build/target/user/platform-0-lto -L../build/target/wiring/platform-0-lto/ -L../build/target/system/platform-0-lto/ -L../build/target/services/platform-0-lto/ -L../build/target/communication/platform-0-lto-prod-0/ -L../build/target/hal/platform-0-lto/ -L../build/target/platform/platform-0-lto/ -L../build/target/wiring_globals/platform-0-lto/ -L../build/target/crypto/platform-0-lto/ -L../build/target/newlib_nano/platform-0-lto -L../build/target/miniz/platform-0-lto -L../build/target/nanopb/platform-0-lto -L../build/target/mbedtls/platform-0-lto -L../build/arm/linker -Wl,--whole-archive -lnewlib_nano -luser -lwiring -lhal -lsystem -lservices -lcommunication -lplatform -lwiring_globals -lcrypto -lminiz -lnanopb -lmbedtls -Wl,--no-whole-archive
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: target/workspace.elf section `.data' will not fit in region `APP_FLASH'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: region `APP_FLASH' overflowed by 792 bytes
collect2: error: ld returned 1 exit status
../build/module.mk:232: recipe for target 'target/workspace.elf' failed
make: *** [target/workspace.elf] Error 1
I have basic programming skills. Please help.