rwaldron / johnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.
http://johnny-five.io
Other
13.26k stars 1.76k forks source link

Support for Grove Temp & Humidity I2C sensor #1039

Closed dougseven closed 8 years ago

dougseven commented 8 years ago

I would like to add support for the Grove - Temperature & Humidity Sensor that is included in the Grove Indoor Environment Kit for Intel® Edison. It utilizes a TH02 sensor that can meet measurement needs of general purposes. The C driver for the TH02 is here

rwaldron commented 8 years ago

Looks pretty straight forward!

rwaldron commented 8 years ago

@dougseven I have another user that's reporting issues with the Grove Temp & Humidity sensor; they reported it was a BMP180, but a photograph of their hardware reveals that it's actually this component. I'd like to implement the controller driver for this today.

dougseven commented 8 years ago

I had started looking into it, but haven't had time to work on it. I can look at it more today.

rwaldron commented 8 years ago

Do you mind if I just take over?

dougseven commented 8 years ago

Go for it - happy to help (test, etc.)

rwaldron commented 8 years ago

Excellent—I will call on you to do so :)

rwaldron commented 8 years ago

@dougseven ready for testing—update to latest version

dougseven commented 8 years ago

I'm going to try a different board with the official Yocto image, but using "latest" for johnny-five and edison-io with ubiLinux and Node v4.3.1 gets this:

NOTE: I have previously run a johnny-five app on this board in this configuration.

root@ubilinux:~/iot-labs/azure-iot# node iot-starter-kit.js NOTICE


This OS image is no longer supported. Please upgrade to IoTKit Image with libmraa0 support. https://github.com/intel-iot-devkit/mraa/#installing-on-your-board


/root/iot-labs/azure-iot/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:48 if (Pin.IO.getPlatformType() === 2) { ^

TypeError: Cannot read property 'getPlatformType' of undefined at Object. (/root/iot-labs/azure-iot/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:48:11) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (/root/iot-labs/azure-iot/node_modules/edison-io/lib/edison.js:1:80) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) root@ubilinux:~/iot-labs/azure-iot# uname -a Linux ubilinux 3.10.17-yocto-standard-r2 #7 SMP PREEMPT Thu Feb 26 09:57:06 UTC 2015 i686 GNU/Linux root@ubilinux:~/iot-labs/azure-iot#

rwaldron commented 8 years ago

Weird, that should only happen if the native bindings are missing 0_o

dougseven commented 8 years ago

I set up a new Edison with the official Yocto image. I get some very radical readings using the sample for the TH02 - 80-degree swings (in Celsius).

  celsius           :  102
  fahrenheit        :  215.6
  kelvin            :  375.15
--------------------------------------
Hygrometer
  relative humidity :  52
--------------------------------------
temperature
  celsius           :  102.375
  fahrenheit        :  216.275
  kelvin            :  375.525
--------------------------------------
Hygrometer
  relative humidity :  52.1875
--------------------------------------
temperature
  celsius           :  102.375
  fahrenheit        :  216.275
  kelvin            :  375.525
--------------------------------------
Hygrometer
  relative humidity :  52.1875
--------------------------------------
temperature
  celsius           :  22
  fahrenheit        :  71.6
  kelvin            :  295.15
--------------------------------------
Hygrometer
  relative humidity :  12.375
--------------------------------------
temperature
  celsius           :  22
  fahrenheit        :  71.6
  kelvin            :  295.15
--------------------------------------
Hygrometer
  relative humidity :  12.375
--------------------------------------

Other times it would start, read a couple times and then stop reading/outputing to the console:

root@edison:~/iot-labs/basic# node th02.js 
1458718176636 Device(s) Intel Edison  
1458718176653 Connected Intel Edison  
1458718176676 Repl Initialized  
>> temperature
  celsius           :  NaN
  fahrenheit        :  NaN
  kelvin            :  NaN
--------------------------------------
Hygrometer
  relative humidity :  -24
--------------------------------------
temperature
  celsius           :  -50
  fahrenheit        :  -58
  kelvin            :  223.14999999999998
--------------------------------------
Hygrometer
  relative humidity :  -24
--------------------------------------

That is where it would stop and nothing more would happen. I can stop it (Ctrl+C twice) and run it again, or another simple sample. Not sure what is happening or how to debug it. I tried it with multiple Grove - Temperature&Humidity Sensor (High-Accuracy &Mini).

rwaldron commented 8 years ago

Interesting, I will have a closer look and double check that the initialization operations are correct.

rwaldron commented 8 years ago

Well, I missed the status check :\

rwaldron commented 8 years ago

And of course, I don't have my TH02 with me (I'm in Boston until tomorrow). I have a fix for this, but I just need to double check it against actual hardware, so I should have something by Saturday

dougseven commented 8 years ago

If it's in a branch I can pull then I can test it tonight. No rush though.

rwaldron commented 8 years ago

@dougseven I completely forgot to ping you on this; you can pull and run the last round of work from master