How can I get temperature and pressure readings into variables or arrays
We have initiated and have contact with the device but when we try to get values into our variables we have not got it correct.
Any idea how to do it in a simple way?
Any idea how to do it in a simple way?
I include some sample from our code:
--------------------------------------
public MainPage()
{
InitializeComponent();
button_Update.IsEnabled = false;
button_Stop.IsEnabled = false;
textMessage.Text = "Waiting to start";
}
private void button_Start_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
MyWearStart();
}
private void button_Update_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
MyWearUpdate();
button_Stop.IsEnabled = true;
}
{
InitializeComponent();
button_Update.IsEnabled = false;
button_Stop.IsEnabled = false;
textMessage.Text = "Waiting to start";
}
private void button_Start_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
MyWearStart();
}
private void button_Update_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
MyWearUpdate();
button_Stop.IsEnabled = true;
}
private void GetMydata(float value)
{
}
private async void MyWearUpdate()
{
string pressure = "1501";
string temp = "30C";
textMessage.Text = "Updating";
try
{
var tempResult = await termometer.Sensors[0].AddRouteAsync((source => source.Stream(data => GetMydata(data.Value<float>()) )));
var pressureResult = await barometer.Pressure.AddRouteAsync(source => source.Stream(data => data.Value<float>()));
// var result = await barometer.Pressure.AddRouteAsync
// source.Stream(data => Console.WriteLine("Pressure (Pa) = " + data.Value<float>())));
{
}
private async void MyWearUpdate()
{
string pressure = "1501";
string temp = "30C";
textMessage.Text = "Updating";
try
{
var tempResult = await termometer.Sensors[0].AddRouteAsync((source => source.Stream(data => GetMydata(data.Value<float>()) )));
var pressureResult = await barometer.Pressure.AddRouteAsync(source => source.Stream(data => data.Value<float>()));
// var result = await barometer.Pressure.AddRouteAsync
// source.Stream(data => Console.WriteLine("Pressure (Pa) = " + data.Value<float>())));
pressure = " <==== some pressure";
temp = "<==== some temperature";
}
catch (Exception e)
{
textMessage.Text = "Error";
}
temp = "<==== some temperature";
}
catch (Exception e)
{
textMessage.Text = "Error";
}
}
This discussion has been closed.
Comments
Read
task then start the newly created Task, see the documentation on Timers:I have put in this for the barometer when starting as suggested:
Björn
The received sensor data is handled in the "Stream" component. Your current code doesn't appear to be doing anything with the data.
We would also appreciate if you could give us a simple example on how to get the values from the stream into the variables in the code in in MyWearUpdate() at the where you see:
var pressure = " <==== some pressure";
var temp = "<==== some temperature";
----------------------
I do have a Setup, run and cleanup, in my code it is called MyWearStart(); MyWearUpdate() ( and MyWearClose() but this module has not been posted since the problem occur before it is called ).
We can implement that and see if it works for us, if not we can get back to you.
Stream
component's lambda function with whatever code you want applied to each data sample.