CM2302 Code

I am trying to make a CM2302 work in Simple IDE, but I am having no success. There is a sample code in the Simple IDE library learn folder for the DHT22 and the code says it is compatible with the CM2302, but this code does not display anything. The following is the code.

* @brief This Propeller C library was created for the DHT22/CM2302
* temperature and humidity sensor module.

//#define _TEST

#ifdef _TEST
#include "simpletools.h"
#include <propeller.h>

#include "dht22.h"

int main() {

#ifdef _TEST

while(1) {
int t, h, c;
c = dht22_read(2);
t = dht22_getTemp(FAHRENHEIT);
h = dht22_getHumidity();

print("chk = %d, temp = %.1f, hum = %.1f\r", c, t / 10.0, h / 10.0);



Can someone please help.


  • Use the code mode to display your c code so it looks a little better.

    At the top of the program there is //#define _TEST
    Remove the two slashes at the beginning so that the test code will work: #define _TEST

    Run the code and it should work.

  • Mike, thank you, the code was the sample sent, they need to fix that.
Sign In or Register to comment.