Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Can I use a GY-21 temperature/humidity sensor with the Pro2?
#3

Hi,

I couldn't manage to get it working with the HTU21 configuration option, so I investigated a bit more myself and came across an Arduino library for reading from the GY-21 sensors - available at https://github.com/JonasGMorsch/GY-21

I then modified the WeatherDuino code to read from this sensor, and it all works well. Thank you for writing code that is very clear and easy to modify.

In case anyone else wants to modify their code similarly (or in case you want to include this in the main WeatherDuino code release), the modifications I did are below:

1. Add the following to Routines.ino:
 
Code:
​​​​​​​#if (TH_SENSOR0 == 3)
// ----- Read temperature from GY21 ---------
void read_GY21()
{
GY21 sensor;
T_ExtS0 = sensor.GY21_Temperature() * 100.0;
H_ExtS0 = sensor.GY21_Humidity() * 100.0;
}
#endif

2. Add the following at line 19 in Process_IDx.ino:
 
Code:
#if (TH_SENSOR0 == 3)
    read_GY21();
  #endif

3. Add the following in the include list at the top of the main file:
Code:
#include <GY21.h>

4. Update the Config file to set the TH_SENSOR0 variable to the new value of 3 for the GY-21 sensor
 
Code:
#define TH_SENSOR0  3

5. Include the GY21.h file from the Github repo above to the Arduino libraries folder.

And then it should all work!
​​​​​​​
Best regards,

Robin
Reply


Messages In This Thread



Users browsing this thread: 1 Guest(s)