How to get readings on ios app

I am using this code to get a digital reading. Now where does that number go? If I am trying to calibrate a FSR, how can I get an alert of the number? Whenever I press the button on the app nothing happens.

- (IBAction)readVariableButtonTapped:(id)sender {
     // 1
     [[SparkCloud sharedInstance] getDevices:^(NSArray *sparkDevices, NSError *error) {
            NSLog(@"%@",sparkDevices.description);
            // 2
            if (!error)
            {
                // 3
                for (SparkDevice *device in sparkDevices)
                {
                    if ([device.name isEqualToString:@"myDevice"])
                    {
                        SparkDevice *myPhoton = device;
                        // 4
                        [myPhoton callFunction:@"digitalwrite" withArguments:@[@"D7",@"HIGH"] completion:^(NSNumber *resultCode, NSError *error) {
                            // 5
                            if (!error)
                            {
                                NSLog(@"Called a function on myDevice");
                            }
                        }];
                    }
                }
            }
        }];
}

If you’re trying to get a number from the Photon you should use getVariable code:

be sure to export this variable in your photon firmware code:
https://docs.particle.io/reference/firmware/photon/#particle-variable-

the reading will be available inside the getVariable completion block

1 Like