Unable to use the table widget (compiling error)

• Raspberry pi B+(C++), Blynk Cloud server

}
 if (ora == 5 && minuti == 1) {
  stringa1 = "";
  stringa1.append(to_string(giorno));
  stringa1.append(to_string(mese));
  stringa1.append(to_string(turno));
 
  stringa2 = "";
  stringa2.append(to_string(giorno));
  stringa2.append("/");
  stringa2.append(to_string(mese));
  stringa2.append(" ");
  stringa2.append(to_string(turno));
 
  Blynk.virtualWrite(V1, "add", stoi(stringa1), stringa2, (100-under_target));
  turno = 1;
  active = 0;
  under_target = 0;
  Blynk.virtualWrite(V6, turno);
 }

I get this error when compiling:

…/src/Blynk/BlynkParam.h:117:9: error: no matching function for call to ‘ BlynkParam::add(std::__cxx11::basic_string<char>&)
add (head);
^~~

Any clue?

Just to specify, Giorno means Day (so a number from 1 to 31) mese means month(1 to 12) and turno is a number from 1 to 3.
What I wanted to do is add a line in a table with the id that is ggmmt (day month turno ex. 11122) and then Title: 11/12 3 and value is a number from 0 to 100.
This is the code that I use:

#define BLYNK_PRINT stdout
#ifdef RASPBERRY
 #include <BlynkApiWiringPi.h>
#else
 #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>
static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);
#include <BlynkWidgets.h>
#include <ctime>
#include <string>

long lastChangeTime = 0;
int pulse = 0;
bool state;
bool stopb = false;
long m;
long sb;
long under_target = 0;
int active = 0;
int turno;
int target;
int calibration;
string stringa1 = "";
string stringa2 = "";


void setup()
{
  pinMode(21, INPUT);
  m = millis();
}

void loop()
{
 Blynk.run();

 time_t now = time(0);
 tm *ltm = localtime(&now);
 int mese = 1 + ltm->tm_mon;
 int giorno = ltm->tm_mday;
 int ora = 1 + ltm->tm_hour;
 int minuti = 1 + ltm->tm_min;

 if (ora == 5 && minuti == 1) {
  stringa1 = "";
  stringa1.append(to_string(giorno));
  stringa1.append(to_string(mese));
  stringa1.append(to_string(turno));

  stringa2 = "";
  stringa2.append(to_string(giorno));
  stringa2.append("/");
  stringa2.append(to_string(mese));
  stringa2.append(" ");
  stringa2.append(to_string(turno));

  Blynk.virtualWrite(V1, "add", stoi(stringa1), stringa2, (100-under_target));
  turno = 1;
  active = 0;
  under_target = 0;
  Blynk.virtualWrite(V6, turno);
 }

 if (ora == 13 && minuti == 1){
  stringa1 = "";
  stringa1.append(to_string(giorno));
  stringa1.append(to_string(mese));
  stringa1.append(to_string(turno));

  stringa2 = "";
  stringa2.append(to_string(giorno));
  stringa2.append("/");
  stringa2.append(to_string(mese));
  stringa2.append(" ");
  stringa2.append(to_string(turno));

  Blynk.virtualWrite(V1, "add", stoi(stringa1), stringa2, (100-under_target));
  turno = 2;
  active = 0;
  under_target = 0;
  Blynk.virtualWrite(V6, turno);
 }

 if (ora == 21 && minuti == 1) {
  stringa1 = "";
  stringa1.append(to_string(giorno));
  stringa1.append(to_string(mese));
  stringa1.append(to_string(turno));

  stringa2 = "";
  stringa2.append(to_string(giorno));
  stringa2.append("/");
  stringa2.append(to_string(mese));
  stringa2.append(" ");
  stringa2.append(to_string(turno));

  Blynk.virtualWrite(V1, "add", stoi(stringa1), stringa2, (100-under_target));
  turno = 3;
  active = 0;
  under_target = 0;
  Blynk.virtualWrite(V6, turno);
}
  long t = millis();
  while (millis() - t < 5000) {
    state = digitalRead(21);
    if (state && stopb == false) {
        sb = millis();
        stopb = true;
        pulse++;
    }

    if (millis() - sb > 50){
         stopb = false;
    }
  }
  if (pulse > 40) pulse = 0;
  if (pulse*12 <= target) under_target+=5;
  if (pulse*12 > 5) active+=5;


  Blynk.virtualWrite(V5, ((under_target*100)/28800)); //pin under target
  Blynk.virtualWrite(V4, ((active*100)/28800)); //pin attiva
  Blynk.virtualWrite(V3, (100 - ((under_target*100)/28800))); //pin performance
  Blynk.virtualWrite(V1, (pulse*12*calibration)); //
  Blynk.virtualWrite(V8, (target)); //Assegna a V8 il valore target
  pulse = 0;
}

BLYNK_WRITE(V2) //pin del target
{
   target = param.asInt();
}
BLYNK_WRITE(V7) //pin calibration
{
   calibration = param.asInt();
}

int main(int argc, char* argv[])
{
  const char *auth, *serv;
  uint16_t port;
  parse_options(argc, argv, auth, serv, port);

  Blynk.begin(auth, serv, port);

  setup();
  while(true) {
    loop();
  
  }

  return 0;
}

Compiling errors aside… which are probably syntax based or due to how you combine strings into one command?

https://www.google.com/search?q=combining+strings+in+arduino

Your void loop() is utterly NOT Blynk compliant. read here…

1 Like

I have a 5 sec delay:
long t = millis(); while (millis() - t &lt; 5000) {

int stoi(stringa1)

1 Like

Like this?
Blynk.virtualWrite(V1, "add", int stoi(stringa1), stringa2, (100-under_target));

yes
you have few lines in your sketch to be corrected.

1 Like

now I get this error:
main.cpp:60:33: error: expected primary-expression before ‘int’
Blynk.virtualWrite(V1, “add”, int stoi(stringa1), stringa2, (100-under_target));
^~~

in table widget parameter,
Id must be an integer

1 Like

may be you can try int id=stoi(stringa1)

1 Like

Blynk.virtualWrite(V1, “add”, id, “Name”, “Value”);
with id as integer

1 Like

“Name” can be a string right?

yes name and value can be a string.
id must be integer.

1 Like

I get an error when I do this:

    if (ora == 5 &amp;&amp; minuti == 1) {
    stringa2 = "Hey" ;
    Blynk.virtualWrite( V , "add", id, stringa2, "test" );

But not when I do this:

    if (ora == 5 &amp;&amp; minuti == 1) {
    stringa2 = "Hey" ;
    Blynk.virtualWrite( V , "add", id, "Hey", "test" );

Why?

String() not just variable named stringa2

Possibly like this?

String stringa2 = "Hey";

I tried like this:

    String stringa2="Hey";
    Blynk.virtualWrite( V , "add", id, stringa2, "test" );

But I get this error:
main.cpp: In function ‘ void loop() ’:

main.cpp:51:2: error:String ’ was not declared in this scope

String stringa2 = “Hey”;

main.cpp:58:37: error:stringa2 ’ was not declared in this scope

Blynk.virtualWrite(V8, “add”, id, stringa2 , “test”);

Well… first off, you still need to fix the issue of having all that code in the void loop() trying to run thousands of times a second.

Then click on and start reading that link I gave ( String() in green) to the Arduino reference pages… might as well read this one as well, about declaring variables as Local and Global… Scope

We try to help with Blynk questions here, more than “how to program” questions.

I did some testing but I was not able to declare a string.
It’s wrong: #include and String Prova=“Test”?

String not string

main.cpp:27:1: error:String ’ does not name a type

String titolo;

main.cpp:28:1: error:String ’ does not name a type

String contenuto;