Using a Seeed Grove TH02 Temp/humidity sensor on teensy 3.2

Status
Not open for further replies.

ceremona

Well-known member
Heya,

I am trying to wrangle getting a http://www.seeedstudio.com/wiki/Grove_-_Tempture&Humidity_Sensor_(High-Accuracy_&Mini)_v1.0 sensor working with a teensy 3.2 over the i2c bus. I replaced all the references from Wire.h to i2c_t3.h and the sample code compiled without complaints. But what I run the sample code nothing is printing to the serial monitor (and yes, my usb serial stuff is working fine with other code, etc).

I have read through some threads regarding some of the bewildering nuances of porting code over from AVR to teensy stuff and it's pretty much over my level of C code sophistication. The TH02 code seems fairly compact but I can't see clearly what else I might change in the libraries or sample code to make the sensor talk to the teensy properly. Anybody have any ideas?

Any help would be appreciated.

Thanks.
 
I would recommend using Wire.h, at least to get started.

I installed their library and compiled the example program without error. I don't have the actual hardware for testing, but this looks like it ought to work.

Code:
/*
 * Demo name   : TH02_dev demo 
 * Usage       : DIGITAL I2C HUMIDITY AND TEMPERATURE SENSOR 
 * Author      : Oliver Wang from Seeed Studio
 * Version     : V0.1
*/

#include <TH02_dev.h>
#include "Arduino.h"
#include "Wire.h" 
 
void setup()
{  
  Serial.begin(9600);        // start serial for output
  while (!Serial) ;   // added this: wait for serial monitor to open
  
  Serial.println("****TH02_dev demo by seeed studio****\n");
  /* Power up,delay 150ms,until voltage is stable */
  delay(150);
  /* Reset HP20x_dev */
  TH02.begin();
  delay(100);
  
  /* Determine TH02_dev is available or not */
  Serial.println("TH02_dev is available.\n");    
}
 

void loop()
{
   float temper = TH02.ReadTemperature(); 
   Serial.println("Temperature: ");   
   Serial.print(temper);
   Serial.println("C\r\n");
   
   float humidity = TH02.ReadHumidity();
   Serial.println("Humidity: ");
   Serial.print(humidity);
   Serial.println("%\r\n");
   delay(1000);
}

When I run it here on a Teensy 3.2 without anything connected to SDA or SCL, I get this:

Code:
****TH02_dev demo by seeed studio****

TH02_dev is available.

When I run it on a Teensy 3.2 that has pullup resistors on SDA and SCL, but no sensor, I get this:

Code:
****TH02_dev demo by seeed studio****

TH02_dev is available.

Temperature: 
-50.00C

Humidity: 
-24.00%

Temperature: 
-50.00C

Humidity: 
-24.00%

Temperature: 
-50.00C

Humidity: 
-24.00%

Sure looks like this code ought to work.

What is it actually doing on your Teensy when you run it? Try this one with the while (!Serial) line added....
 
Thanks for your help on this Paul! With the while(!Serial) line added and reverting back to the native Wire.h include, the ball moves a little further forward. I get:

****TH02_dev demo by seeed studio****

TH02_dev is available.

But then still nothing prints from the loop: section of the code.

Is there something weird about the i2c stuff where you have to keep hammering on a DTR or something for each read statement in the loop?
 
I'm also curious to know when/why one should consider using the Wire.h library vs the i2c_t3 stuff when using the Teensy hardware?
 
errr. Ok, maybe it's still not totally working. I do now get the temp and humidity output in the serial console but no actual temperature/humidity changes updates (like say when I breathe on the sensor, etc).

It just sort of perpetually prints -50C and -24%

The weird thing is that if I have the pins connected SDA0 --> sda0 SCL0 --> scl0 I only get a print update one or two times in the console from the "loop:" section and then nothing else. If I cross connect SDA0 --> scl0 and SCL0 --> sda0 (as I did on accident), I get infinite updates but no actual real data updates in both cases.
 
Maybe something isn't connected properly. That's the same result I saw when I ran the example with pullup resistors, but no sensor.

Could you post photos of how you've actually connected the wires?
 
Status
Not open for further replies.
Back
Top