Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use raspberry pie to monitor temperature and humidity at home

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

I would like to share with you how to use raspberry pie to monitor temperature and humidity at home. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. let's learn about it!

Hardware requirement

WIFI Wireless Router

Raspberry Pi B+

DHT11 temperature and humidity sensor and 4.7k ohmic resistance

A piece of bread

Some DuPont lines between female and male

Raspberry pie is running.

First of all, your raspberry pie is up and working properly.

For more information, please refer to the official Quick start document: https://www.raspberrypi.org/help/quick-start-guide/

Update the system

Sudo apt-get updatesudo apt-get dist-upgrade-ysudo reboot

Enter the raspberry pie SSH, download and compile the chip library

Determine the raspberry pie chip model, mine is the raspberry pie Blossom CPU is Broadcom BCM2836, so my next is: t http://www.airspayce.com/mikem/bcm2835/bcm2835-1.46.tar.gz

Note: actually support 2836, query history through cpuinfo is actually 2709, you can see: http://bbs.21ic.com/forum.php?mod=viewthread&tid=1180900.

download

Wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.46.tar.gz

Installation

Tar xzvf bcm2835-1.46.tar.gzcd bcm2835-1.46./configuremakesudo make checksudo make install

Download and install Node.js:

Because Node.js is installed on embedded devices, raspberry pie uses ARMv7 chips. When using Node.js, you need to pay attention to the Node.js version. Since armv7 bin package has been provided for node4.0 and above, we still use node-v0.12.7.tar.gz because of compatibility problems.

download

Wget http://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz

Compile Node.js

Tar xzvf node-v0.12.7.tar.gzcd node-v0.12.7./configuremakesudo make install

This process takes about 2 hours, and there may be an error to exit, so just continue to execute the unfinished command.

Download related dependency packages

Npm install node-dht-sensor express ejs

8. Hardware equipment connection

To learn about the GPIO arrangement of raspberry pie, you can refer to this:

Https://cache.yisu.com/upload/information/20210521/354/248119.png

DHT11 temperature and humidity sensor

Https://cache.yisu.com/upload/information/20210521/354/248121.jpg

9. Connection method:

1. Connect the VCC to the board sub 3.3v

2. A 4.7K resistor needs to be placed between the GND,DATA and the VCC of the GND connection board.

3. DATA connects to GPIO port

Note: please operate when the raspberry pie is powered off.

Create a Node.js project accessed by WIFI

Pi@raspberrypi ~ / app $find../views./views/interface.ejs./app.js./js./public./public/pictures./public/css./public/js./public/js/interface.js./public/js/jquery-1.8.3.min.jsapp.jsvar sensorLib = require ('node-dht-sensor'); var express = require (' express'); var ejs = require ('ejs'); var app = express (); app.set (' views', _ dirname +'/ views') App.set ('view engine',' ejs') app.use (express.static (_ _ dirname +'/ public')) var DHT11_GPIO = 21; / / GPIO port var DHT11 = 11; / / Sensor model sensorLib.initialize (DHT11, DHT11_GPIO); app.get ('/ interface', function (req, res) {var readout = sensorLib.read () / / console.dir (readout) res.render ('interface', {temperature: readout.temperature.toFixed (2), humidity: readout.humidity.toFixed (2)}); var server = app.listen (3000, function () {console.log (' Listening on port% dashes, server.address () .port);})

Interface.js raspberry pie temperature:. C humidity:%

Start the project

Pi@raspberrypi ~ / app $sudo node app.js Listening on port 3000

Visit the page

Enter in the browser:

Http://192.168.8.24:3000/interface raspberry pie temperature: 20.00. C humidity: 38.00%

The above is all the contents of the article "how to use raspberry pie to monitor temperature and humidity at home". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report