hi
i’m trying to monitor distance using ultrasonic sensor (HC-SR04)
on my thinger.io console
i’m writing this code :
#include<ESP8266Wii> .h>
#include <ThingerESP8266.h>
> #define USERNAME "***********"
> #define DEVICE_ID "*****************"
>#define DEVICE_CREDENTIAL "****************"
> #define TRIGGER_PIN 14 // D5
> #define ECHO_PIN 12 //D6
> //defining SSID and password for the router
> #define SSID "**************"
> #define SSID_PASSWORD "**************"
> ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
> void setup()
> {
>
> thing.add_wifi(SSID, SSID_PASSWORD);
> pinMode(TRIGGER_PIN, OUTPUT);
> pinMode(ECHO_PIN, INPUT);
> }
> void loop() {
> thing.handle();
> double duration, distance;
>
> digitalWrite(TRIGGER_PIN, LOW); // Get Start
> delayMicroseconds(2); // stable the line
> digitalWrite(TRIGGER_PIN, HIGH); // sending 10 us pulse
> delayMicroseconds(10); // delay
>
> digitalWrite(TRIGGER_PIN, LOW); // after sending pulse wating to receive signals
>
> duration = pulseIn(ECHO_PIN, HIGH); // calculating time
>
> distance = (duration/2) / 29.1; // single path
> thing["SONIC"] >> [] (pson& out){
> out = distance;
> };
> delay(100);
>
> }
but i’m getting this error
C:\Users\Hussam\Desktop\thinger.io - Copy\thinger.io\thinger.io.ino: In lambda function:
thinger.io:56: error: 'distance' is not captured
in = distance;
^
thinger.io:59: error: 'distance' is not captured
distance = in;
^
exit status 1
'distance' is not captured
what’s wrong???
help