DHT11, DHT22, CM2302 Humidity and Temperature Sensor Object

Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on print
Table of Contents

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. 


  #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:

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. 

Programming Language
Tools and Operating System
Document Author
Source Code Author
Table of Contents
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Copyright © 2021 Parallax Inc. All Rights Reserved
Designed and Made in California, USA