DHT22 Bonescript

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
FooLingYu2
 
Posts: 3
Joined: Thu Oct 16, 2014 2:12 pm

DHT22 Bonescript

Post by FooLingYu2 »

Hi Adafruit community!

I'm trying to read data from my DHT22 Humidity/Temperature sensor using Bonescript. Being new to Bonescript, I am having trouble getting started with having my Beaglebone Black Rev C, running Debian, to communicate with the DHT22 using Bonescript.

So far I have:

Code: Select all

var b = require('bonescript');
var pin = "P8_19";
b.pinMode(pin, b.INPUT);
I have my sensor hooked up so that the data is connected to P8_19, but I don't know where to go from here. All I know is that I definitely want to read data from the sensor to P8_19 on the Beaglebone Black.

I have tried slightly modifying sample node.js code generously provided by Andrew Rohne (https://gist.github.com/KE8P/5024198) thinking I could easily go to Bonescript later on. This code works for him if you want to see it yourself on his blog (http://www.ke8p.us/raspberrypi/raspberr ... re-monitor):

Code: Select all

var sys=require("sys");
var exec=require("child_process").exec;
var child;
var http=require("http");
var Stdout;
 
child=exec("Adafruit_DHT 22 P8_19",function(error, stdout,stderr){
        Stdout=stdout;
});
 
http.createServer(function(request,response){
        response.writeHead(200,{"Content-Type":"text/plain"});
        response.write(Stdout);
        response.end();
}).listen(8888);
When I try it out go to 192.168.7.2:8888, the web page shows up, but it is completely blank. Any advice on coding in Bonescript to simply get Humidity and Temperature readings in my command prompt from my DHT22 sensor? The web server was not necessary for my purposes, but knowing how to get the data in my command prompt from the DHT22 through Bonescript may lead to me getting both to work as well.

For the record, I have already successfully been getting readings from the DHT22 with python through Adafruit's_Python_DHT directory, so no faulty sensor issues.

Any advice is welcome! Thanks in advanced for the help!

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”