'variable' is not captured problem

hi guys,

I have a little problem with my ESP8266 module. I want to send randomly generated 15 int numbers, and send them to thinger.io via wifi. But somehow, I cant figure how to output the numbers.

here is the code(I used mostly example from thinger.io library, and I added a for loop for generating numbers)

#define _DISABLE_TLS_
#define _DEBUG_

#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>

#define USERNAME "******"
#define DEVICE_ID "******"
#define DEVICE_CREDENTIAL "******"

#define SSID "********"
#define SSID_PASSWORD "********"



ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  int RandNumber;
  Serial.begin(115200);
  pinMode(BUILTIN_LED, OUTPUT);

  thing.add_wifi(SSID, SSID_PASSWORD);

  // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
  thing["led"] << digitalPin(BUILTIN_LED);

  // resource output example (i.e. reading a sensor value)
  thing["millis"] >> outputValue(millis());

  int myVar [15];
  for (int i = 1; i<15; i++) {
    myVar[i]= random(0,15);

  for (i =1; i<15; i++) {
    thing["random"] >> outputValue(myVar[i]); //here is error: 'myVar' is not captured
  }
  }
  
  // more details at http://docs.thinger.io/arduino/
}
void loop() {
  thing.handle();
}

thanks for help :slight_smile:

    thing["random"] >> outputValue(myVar[i]); //here is error: 'myVar' is not captured

Don't you want to put the values INTO thing["random"]?

PaulS:

    thing["random"] >> outputValue(myVar[i]); //here is error: 'myVar' is not captured

Don't you want to put the values INTO thing["random"]?

probably. I'm new to arduino, altough i have some experience in programming.

Can you post a link to the ThingerESP8266 library. It isn’t clear what, exactly, << and >> are doing, or what the outputValue() function is doing.

That being said, I would expect you to store the values in thing[“random”] by using << and having the value to store follow the <<, like the way the output from digitalRead() is stored in thing[“led”].

PaulS:
Can you post a link to the ThingerESP8266 library. It isn’t clear what, exactly, << and >> are doing, or what the outputValue() function is doing.

That being said, I would expect you to store the values in thing[“random”] by using << and having the value to store follow the <<, like the way the output from digitalRead() is stored in thing[“led”].

here’s the link for the library:

https://github.com/thinger-io/Arduino-Library

I tried the same way, by using << like the thing[“led”] but it didn’t worked either.

I tried the same way, by using << like the thing[“led”] but it didn’t worked either.

Well, something happened.