Temperature & Humidity Sensor Wiring & Example Code

The CM2302 Temperature and Humidity Sensor can take a reading of temperature and relative humidity for use by a microcontroller such as the Propeller.

Schematic and Wiring

           

Quick Code Example

The example code below displays the temperature and relative humidity in the BlocklyProp Terminal.  BlocklyProp uses integer math; the Temp & Humidity value block provides a value that is 10 times larger than the sensor reading. 

To display the sensor readings as floating-point values, use the Terminal print multiple block.  Click its gear icon, drag in text and floating point number blocks, and then click specify digits box:

Here is the complete code listing:

Save and run the project to display the data in the BlocklyProp Terminal: