---
title: DHT11, DHT22, CM2302 Humidity and Temperature Sensor Object
description: "[![](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302.jpeg)](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302.jpeg)[![](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302-Indoor-Outdoor.jpg)](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302-Indoor-Outdoor.jpg) ##### Description The…"
url: "https://obex.parallax.com/docs/quick-bytes/propeller-2/dht11-dht22-cm2302-humidity-and-temperature-sensor-object/"
updated: "2026-09-29"
category: Propeller 2
---

# DHT11, DHT22, CM2302 Humidity and Temperature Sensor Object

[![](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302.jpeg)](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302.jpeg)[![](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302-Indoor-Outdoor.jpg)](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302-Indoor-Outdoor.jpg)

##### Description

The jm_dhtxx.spin2 object wakes and reads data from the DHT11, DHT22 and CM2302 Humidity and Temperature Sensors. In the top file, configure the S_TYPE for the sensor you are using (DHT11 or DHT22). The CM2302 should be set as DHT22 since they use the same communication protocol. 

```spin2
con

  #true,  ON, OFF
  #false, NO, YES

  S_TYPE = dht.DHT22                                            ' set sensor type
```

To use the sensor, I modified the example to have a second instance of the jm_dhtxx object to use with a second sensor, with one inside a conditioned sunny office and another one outdoors on a cold, storm day. The Parallax Serial Terminal showed the following data for the two sensors:

![](/qbi/DHT11, DHT22, CM2302 Humidity And Temperature Sensor Object - Parallax_files/CM2302-Indoor-Outdoor.jpg)

The CM2302 sensor packaging and response time is designed for measuring ambient environments commonly found inside and outside, provided it can be kept dry. For interest, I conducted some informal tests to see the sensor’s response to rapidly changing humidity and temperature with ice, a heat gun, compressed air and steam. 

[DHT11, DHT22, CM2302 Humidity and Temperature Sensor Object](https://www.youtube.com/embed/wTeYnjcTfTI?feature=oembed)

##### Parts Used

- [P2 Edge Module](https://www.parallax.com/product/p2-edge-module/)
- [P2 Edge Breadboard](https://www.parallax.com/product/p2-edge-module-breadboard/)
- [CM2302 Temperature and Humidity Sensor](https://www.parallax.com/product/cm2302-digital-temperature-humidity-sensor/)

##### Source Code

- [DHTxx-Archive.zip](/qbi/downloads/jm_dhtxx_demo-Archive-Date-2022.05.22-Time-13.21.zip)

##### Programming Language

- [Spin 2 and PASM](https://www.parallax.com/propeller-2/get-started/spin2/)

##### Tools and Operating System

- [Propeller Tool for Windows](https://www.parallax.com/propeller-2/programming-tools/)

##### Additional Resources

- [Propeller 2 Spin Documentation](https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit)
- [CM2302 Datasheet](https://www.parallax.com/package/cm2302-temperature-humidity-sensor-datasheet/)

##### Document Author

- Ken Gracey

##### Source Code Author

- Jon McPhalen
