×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÉèÖÃLinuxϵͳÒÔÖ§³ÖÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢

ÉèÖÃlinuxϵͳÒÔÖ§³ÖÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢

Ëæ×ſƼ¼µÄÉú³¤ £¬ÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯³ÉΪÏÖ´úÅ©ÒµµÄÖ÷ҪƫÏò¡£Linux×÷ΪһÖÖ¿ªÔ´²Ù×÷ϵͳ £¬ÔÚÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯ÁìÓò¾ßÓÐÆÕ±éµÄÓ¦Óᣱ¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃlinuxϵͳÒÔÖ§³ÖÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢ £¬²¢ÌṩһЩÏà¹ØµÄ´úÂëʾÀý¡£

Ò»¡¢×°ÖÃLinuxϵͳ

Ê×ÏÈ £¬ÎÒÃÇÐèҪѡÔñÒ»¸öÊʺϵÄLinux¿¯Ðаæ¾ÙÐÐ×°Öᣳ£¼ûµÄLinux¿¯ÐаæÓÐUbuntu¡¢CentOSµÈ £¬¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóÑ¡ÔñºÏÊʵİ汾¡£

¶þ¡¢×°ÖÃÐëÒªµÄÈí¼þºÍ¹¤¾ß

ÔÚLinuxϵͳÉϾÙÐÐÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢ £¬ÐèҪװÖÃһЩÐëÒªµÄÈí¼þºÍ¹¤¾ß £¬ÈçPython¡¢Node.jsµÈ¡£¿ÉÒÔʹÓðü¹ÜÀí¹¤¾ß£¨ÈçAPT¡¢YumµÈ£©À´×°ÖÃÕâЩÈí¼þ¡£

ÒÔUbuntuϵͳΪÀý £¬×°ÖÃPythonºÍNode.js¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ sudo apt-get update

$ sudo apt-get install python nodejs

Èý¡¢×°Öô«¸ÐÆ÷ºÍµç»ú¿ØÖÆÄ£¿é

ÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢Öг£Ê¹ÓÃÖÖÖÖ´«¸ÐÆ÷ºÍµç»ú¿ØÖÆÄ£¿é £¬ÈçÎÂʪ¶È´«¸ÐÆ÷¡¢¹âÕÕ´«¸ÐÆ÷¡¢Ë®Î»´«¸ÐÆ÷ÒÔ¼°µç»ú¿ØÖÆÄ£¿éµÈ¡£Æ¾Ö¤ÏêϸÐèÇó £¬Ñ¡ÔñÊʺϵĴ«¸ÐÆ÷ºÍµç»ú¿ØÖÆÄ£¿é¾ÙÐÐ×°Öá£

ÔÚLinuxϵͳÉÏ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýGPIO£¨Í¨ÓÃÊäÈëÊä³ö£©À´¿ØÖÆ´«¸ÐÆ÷ºÍµç»ú¿ØÖÆÄ£¿é¡£GPIOÊÇÒ»ÖÖÓÃÓÚÔÚÅÌËã»úºÍÍⲿװ±¸Ö®¼ä´«ÊäÊý×ÖÐźŵÄͨÓýӿÚ¡£ÏêϸµÄGPIOÒý½Å±àºÅºÍʹÓÃÒªÁì¿ÉÒԲο¼Ïà¹ØÎĵµ¡£

ËÄ¡¢±àдÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯³ÌÐò

ÔÚÉèÖúÃLinuxϵͳºÍ×°ÖÃÐèÒªµÄÈí¼þºÍÓ²¼þÖ®ºó £¬ÎÒÃÇ¿ÉÒÔ×îÏȱàдÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯³ÌÐòÁË¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄʾÀý´úÂë £¬ÓÃÓÚ¶ÁÈ¡ÎÂʪ¶È´«¸ÐÆ÷µÄÊý¾Ý²¢¿ØÖƵç»ú¿ØÖÆÄ£¿é£º

import time
import Adafruit_DHT
import RPi.GPIO as GPIO

sensor = Adafruit_DHT.DHT11
pin = 4
motor_pin = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(motor_pin, GPIO.OUT)

while True:
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    if humidity is not None and temperature is not None:
        print('Temperature: {0:0.1f} ¡ãC'.format(temperature))
        print('Humidity: {0:0.1f} %'.format(humidity))
        if temperature > 25:
            GPIO.output(motor_pin, GPIO.HIGH)
        else:
            GPIO.output(motor_pin, GPIO.LOW)
    else:
        print('Failed to read sensor data')

    time.sleep(2)

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëʹÓÃÁËAdafruit_DHT¿âÀ´¶ÁÈ¡ÎÂʪ¶È´«¸ÐÆ÷µÄÊý¾Ý £¬Ê¹ÓÃRPi.GPIO¿âÀ´¿ØÖƵç»ú¿ØÖÆÄ£¿é¡£Æ¾Ö¤ÏÖÕæÏàÐÎ £¬Äã¿ÉÄÜÐèÒªÐÞ¸ÄÒý½Å±àºÅºÍ´«¸ÐÆ÷ÀàÐÍ¡£

Î塢ʹÓÃÔÆƽ̨¾ÙÐÐÔ¶³Ì¼à¿ØºÍ¿ØÖÆ

ΪÁËʵÏÖÔ¶³Ì¼à¿ØºÍ¿ØÖÆ £¬¿ÉÒÔʹÓÃÔÆƽ̨À´´î½¨Ò»¸öÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯ÏµÍ³¡£³£¼ûµÄÔÆƽ̨ÓÐAWS¡¢AzureµÈ £¬¿ÉÒÔƾ֤ÏÖʵÐèÇóÑ¡ÔñºÏÊʵÄƽ̨¡£

ÔÚÔÆƽ̨ÉÏ £¬¿ÉÒÔʹÓÃÖÖÖÖ´«ÊäЭÒ飨ÈçMQTT¡¢HTTPµÈ£©½«´«¸ÐÆ÷Êý¾Ý´«Êäµ½ÔÆ¶Ë £¬²¢Í¨¹ýÍøÒ³»òÊÖ»úAppµÈ·½·¨¾ÙÐÐʵʱ¼à¿ØºÍÔ¶³Ì¿ØÖÆ¡£

×ܽá

±¾ÎÄÏÈÈÝÁËÔõÑùÉèÖÃlinuxϵͳÒÔÖ§³ÖÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢ £¬²¢ÌṩÁËÒ»¸ö¼òÆӵĴúÂëʾÀý¡£Ï£Íû±¾ÎÄÄÜΪ¿í´óÅ©Òµ¿Æ¼¼Ï²»¶ÕߺͿª·¢ÕßÌṩһЩ²Î¿¼ºÍ½è¼ø¡£Í¨¹ýºÏÀíʹÓÃLinuxϵͳºÍÏà¹Ø¹¤¾ß £¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÍƶ¯ÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯µÄÉú³¤¡£

ÒÔÉϾÍÊÇÉèÖÃLinuxϵͳÒÔÖ§³ÖÖÇÄÜÅ©ÒµºÍÅ©Òµ×Ô¶¯»¯¿ª·¢µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ