Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing result data BMP180 #10

Closed
survivingwithandroid opened this issue Dec 5, 2016 · 2 comments
Closed

Parsing result data BMP180 #10

survivingwithandroid opened this issue Dec 5, 2016 · 2 comments

Comments

@survivingwithandroid
Copy link

Hello!!

Thanks for your great work!
I'm using your library to access to BMP180 sensor in raspberry pi. It works smoothly but i've a small problem. The data returned is like:
{
type:..
Unit:...
(temperature data)
}
{
type:...
Unit:...
(pressure data)
}
How can I parse the result and retrieve only the pressure object or the temperature?
Using data.value it returns always a couple of results.
Can you help me?!
Thanks in advance!
Best Regards.

@Vuzi
Copy link
Owner

Vuzi commented Dec 5, 2016

The returned data should be pretty much like :

{
  type: 'Light',                                    // The type of the value of the sensor
  unit: 'Lux',                                      // The unit used
  unit_display: 'Lux',                              // The displayable unit
  value: 819,                                       // The raw value, exprimed in the specified unit
  date: 'Sun Feb 14 2016 15:22:00 GMT+0000 (UTC)',  // The js date of the fetch
  timestamp: 1455463320449,                         // The timestamp of the previous date
  sensor_name: 'light_sensor',                      // The name of the sensor (so you can use the same callback for multiple sensors)
  sensor_type: 'TSL2561'                            // The type of the sensor
}

with the value field only containing either the temperature or the pressure (for the BMP180). If you need to known which type of value is currently in your handler, you can test the type of the resul :

   if(data.type === "Temperature") {
     ....
   } else if(data.type === "Humidity") {
     ...
   }

@survivingwithandroid
Copy link
Author

Thank you very much!!
It works!!

@Vuzi Vuzi closed this as completed Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants