Fetching variables


I am finally starting to code photon for a smart device project. At this moment, I have flashed this onto the device

    //Define the pins we're going to use as input
double sensor = 0; // WKP
double noise = 0;
double maxAmps = 0;
double minAmps =0;
double lastAmps = 0;
String astring; 

void setup(){
pinMode(A7, INPUT);

void loop(){
 // Read the analog value of the sensor (TMP36)
  sensor = ((2960 - analogRead(A7))*45.4545/4095); //analog current reading in Amps
  sensor = 0.5*(sensor + lastAmps); //average of last value and current value to smooth graph out
  lastAmps = sensor;
  //Averaging to distinguish from capacitor noise - Check data sheet for acs712 Hammad and manan to fix it
maxAmps = max(maxAmps, sensor);
minAmps = min(minAmps, sensor);
noise = maxAmps - minAmps; //capacitor filter noise calculation
  if (analogRead(A7)!=-1) {maxAmps = sensor; minAmps = sensor;}

So after I flash this, I go on my cmd and type 'particle monitor 12345asdasasdhja12211212’
which asks me which variable I wanted. So far it looks like the datas are somehow going to the cloud. However, how do I fetch the data so I can display it or control it via an app?

I have tried the get function as it advised on reference/api webpage but this is what i get

C:\Users\PROJECT>particle get /v1/devices/12345asdasdasdhja12211212
polling server to see what devices are online, and what variables are available
Error { [Error: connect ETIMEDOUT]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '',
  port: 443 }

Why not try the documented way

particle get <your Device ID> <your Variable Name> 

oh no Error:Time Out. Could it be because this is a continuous loop?

edit: I tried this and I got value for one instance

particle get 123374734ahsdas sensor >my_sensor.csv

It made a csv excel file on my documents. Is it possible to make it fetch a number of instances

Why :weary:?
I’ve given you the link and there it tells you how! Not even 20 lines down.

1 Like

ah sorry! I forgot to mention that I have found it last night haha :slight_smile: but thank you so much!