Coder Social home page Coder Social logo

Comments (5)

riatzukiza avatar riatzukiza commented on July 20, 2024

I've tried this lib, an example off node-rpio, and the adafruit dht lib, and I am not able to get a reading off of this sensor, I think that it may just be broken.

from node-rpio.

riatzukiza avatar riatzukiza commented on July 20, 2024

I got another sensor and tried it, the example as it exist in the rep provides all NaNs, I changed a bit and I got:

Read failed:
    chk = 0, chksum = NaN\
    humidity: 27.6 temperature:80.NaN (0 = NaN)

Where the numbers fluctuate quite wildly, but the temperature dec value is usually NaN.
Here are the significant changes I made:

rpio.open(pin, rpio.OUTPUT);
rpio.write(pin, rpio.HIGH);
rpio.msleep(500);
rpio.write(pin, rpio.LOW);
/*
 * The datasheet says 18us, but we need to account for the JavaScript function
 * call overhead.  Trial and error suggests this is a working value.
 */
rpio.msleep(20);

rpio.write(pin, rpio.HIGH);

rpio.usleep(80);
rpio.write(pin, rpio.LOW);
rpio.mode(pin, rpio.INPUT);

rpio.usleep(100);

/*
 * Switch to input mode and read as fast as possible into our buffer.
 */
rpio.readbuf(pin, buf);

from node-rpio.

atrovato avatar atrovato commented on July 20, 2024

Any news on this topic ?

from node-rpio.

atrovato avatar atrovato commented on July 20, 2024

Solution is here :

`

/*
 * Initiate the MCU sequence.
 */
rpio.open(pin, rpio.OUTPUT, rpio.PULL_UP);
rpio.sleep(1);
rpio.write(pin, rpio.HIGH);
rpio.msleep(10);
rpio.write(pin, rpio.LOW);

/*
 * The datasheet says 18us, but we need to account for the JavaScript function
 * call overhead.  Trial and error suggests this is a working value.
 */
rpio.msleep(20);
rpio.write(pin, rpio.HIGH);

/*
 * Switch to input mode and read as fast as possible into our buffer.
 */
rpio.mode(pin, rpio.INPUT);
rpio.usleep(100);
rpio.readbuf(pin, buf);
rpio.close(pin);

`

from node-rpio.

jperkin avatar jperkin commented on July 20, 2024

I rewrote the dht11 example in 049e187 but forgot about this ticket, if there are still issues with the code let me know, it worked pretty well for me across a range of devices though.

from node-rpio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.