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

ÔÚLinuxÉÏʹÓÃVisual Studio Code¾ÙÐÐÖÇÄܼҾӿª·¢µÄÍƼöÉèÖÃ

ÔÚlinuxÉÏʹÓÃvisual studio code¾ÙÐÐÖÇÄܼҾӿª·¢µÄÍƼöÉèÖÃ

ÖÇÄܼҾÓÊÇָͨ¹ýÍøÂçÅþÁ¬ºÍ¿ØÖƶà¸ö¼Ò¾Ó×°±¸µÄÖÇÄÜϵͳ £¬Ëü¿ÉÒÔÌṩÖÖÖֱ㵱ºÍÌñ¾²µÄ¹¦Ð§ £¬ÈçÖÇÄÜÕÕÃ÷¡¢ÖÇÄÜÃÅËø¡¢ÖÇÄÜοصÈ¡£ÔÚ¿ª·¢ÖÇÄܼҾÓÓ¦ÓóÌÐòʱ £¬Ñ¡ÔñÒ»¸öºÏÊʵĿª·¢ÇéÐκÜÊÇÖ÷Òª¡£Visual Studio CodeÊÇÒ»¿îÇáÁ¿¼¶ÇÒ¹¦Ð§Ç¿Ê¢µÄ´úÂë±à¼­Æ÷ £¬ËüÖ§³ÖÔÚLinuxÉϾÙÐÐÖÇÄܼҾӿª·¢ £¬²¢ÇÒÌṩÁ˸»ºñµÄ²å¼þºÍ¹¦Ð§ £¬Ê¹¿ª·¢±äµÃÔ½·¢¸ßЧºÍ±ã½Ý¡£

ÒÔÏÂÊÇÔÚlinuxÉÏʹÓÃvisual studio code¾ÙÐÐÖÇÄܼҾӿª·¢µÄÍƼöÉèÖãº

ÏÂÔغÍ×°ÖÃVisual Studio Code

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÏÂÔز¢×°ÖÃVisual Studio Code¡£¿ÉÒÔ»á¼û¹Ù·½ÍøÕ¾ https://code.visualstudio.com/ £¬Ñ¡ÔñÊʺÏÄãLinuxϵͳµÄ×°Öðü £¬²¢Æ¾Ö¤¹Ù·½Ö¸ÄϾÙÐÐ×°Öá£

×°ÖÃC++ºÍPython²å¼þ

ÖÇÄܼҾӿª·¢Í¨³£ÐèҪʹÓõ½C++ºÍPython±à³ÌÓïÑÔ £¬Òò´ËÎÒÃÇÐèҪװÖÃÏà¹ØµÄ²å¼þÀ´Ö§³ÖÕâÁ½ÖÖÓïÑԵĿª·¢¡£ÔÚVisual Studio CodeµÄÀ©Õ¹ÊÐËÁÖÐËÑË÷²¢×°ÖÔC++”ºÍ”Python”²å¼þ¡£×°ÖÃÍê³Éºó £¬ÎÒÃǾͿÉÒÔÔÚVisual Studio CodeÖбàдºÍÔËÐÐC++ºÍPython´úÂëÁË¡£

ÉèÖô®¿ÚͨѶ

ÖÇÄܼҾÓ×°±¸Í¨³£»áͨ¹ý´®¿Ú¾ÙÐÐͨѶ £¬Òò´ËÎÒÃÇÐèÒªÉèÖÃVisual Studio CodeÀ´Ö§³Ö´®¿ÚͨѶ¡£Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖô®¿ÚͨѶÏà¹ØµÄ¿â¡£ÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁî×°ÖÃÒÀÀµ¿â£º

sudo apt-get install libboost-system-dev libboost-thread-dev

µÇ¼ºó¸´ÖÆ

È»ºó £¬·­¿ªVisual Studio Code £¬µã»÷×ó²àµ¼º½À¸µÄÀ©Õ¹°´Å¥ £¬ËÑË÷²¢×°ÖÔPlatformIO IDE”²å¼þ¡£×°ÖÃÍê³Éºó £¬µã»÷”PlatformIO”°´Å¥ £¬Ñ¡Ôñ”Initialize Project” £¬È»ºóÑ¡ÔñÄãµÄÏîÄ¿Îļþ¼Ð £¬Visual Studio Code»á×Ô¶¯ÎªÄãµÄÏîÄ¿½¨ÉèÒ»¸öÉèÖÃÎļþ”platformio.ini”¡£

ÔÚ”platformio.ini”ÎļþÖÐ £¬ÎÒÃÇÐèÒªÉèÖô®¿ÚµÄ¶Ë¿ÚºÅºÍ²¨ÌØÂÊ¡£ÕÒµ½ÒÔÏÂÁ½ÐдúÂë £¬½«ÆäÖеĶ˿ںźͲ¨ÌØÂÊÐÞ¸ÄΪÄãµÄÏÖʵÉèÖãº

monitor_port = /dev/ttyACM0
monitor_speed = 115200

µÇ¼ºó¸´ÖÆ

ÉèÖÃÍê³Éºó £¬ÎÒÃǾͿÉÒÔͨ¹ýVisual Studio CodeÀ´ÅþÁ¬ºÍµ÷ÊÔÄãµÄÖÇÄܼҾÓ×°±¸ÁË¡£

ʹÓÃGit¾ÙÐа汾¿ØÖÆ

°æ±¾¿ØÖÆÊÇÈí¼þ¿ª·¢ÖкÜÊÇÖ÷ÒªµÄÒ»¸ö»·½Ú £¬Ëü¿ÉÒÔ×ÊÖúÎÒÃÇ×·×ÙºÍÖÎÀí´úÂëµÄ±ä»»¡£ÔÚVisual Studio CodeÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÄÚÖõÄGit²å¼þÀ´¾ÙÐа汾¿ØÖÆ¡£Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖÃGit²¢ÉèÖÃÓû§ÐÅÏ¢¡£ÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁîÀ´×°ÖÃGit£º

sudo apt-get install git

µÇ¼ºó¸´ÖÆ

È»ºó £¬ÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁîÀ´ÉèÖÃÓû§ÐÅÏ¢£º

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

µÇ¼ºó¸´ÖÆ

ÉèÖÃÍê³Éºó £¬ÎÒÃÇ¿ÉÒÔÔÚVisual Studio CodeÖз­¿ªÏîÄ¿Îļþ¼Ð £¬Í¨¹ýµã»÷×ó²àµ¼º½À¸µÄÔ´´úÂëÖÎÀí°´Å¥À´¾ÙÐа汾¿ØÖÆ¡£

ÒÔÉϾÍÊÇÔÚlinuxÉÏʹÓÃvisual studio code¾ÙÐÐÖÇÄܼҾӿª·¢µÄÍƼöÉèÖá£Í¨¹ýºÏÀíÉèÖÃVisual Studio Code £¬ÎÒÃÇ¿ÉÒÔ»ñµÃ¸ü¸ßЧºÍ±ã½ÝµÄ¿ª·¢ÌåÑé¡£×£ÄúÔÚÖÇÄܼҾӿª·¢µÄõ辶ÉÏÈ¡µÃÀֳɣ¡

´úÂëʾÀý£ºÔÚPythonÖÐʹÓÃAdafruit_DHT¿â¶ÁÈ¡DHT11´«¸ÐÆ÷µÄÎÂʪ¶ÈÊý¾Ý¡£

import Adafruit_DHT

sensor = Adafruit_DHT.DHT11
pin = 4

humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

if humidity is not None and temperature is not None:
    print('Temperature={0:0.1f}C  Humidity={1:0.1f}%'.format(temperature, humidity))
else:
    print('Failed to read data from DHT11 sensor')

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëʹÓÃAdafruit_DHT¿âÀ´¶ÁÈ¡ÅþÁ¬ÔÚGPIO 4Òý½ÅÉϵÄDHT11´«¸ÐÆ÷µÄÎÂʪ¶ÈÊý¾Ý¡£Í¨¹ýŲÓÃAdafruit_DHT.read_retryº¯Êý £¬ÎÒÃÇ¿ÉÒÔ»ñÈ¡´«¸ÐÆ÷·µ»ØµÄÎÂʪ¶ÈÖµ £¬²¢½«Æä´òÓ¡³öÀ´¡£ÈôÊǶÁȡʧ°Ü £¬Ôò»áÊä³öÏìÓ¦µÄ¹ýʧÐÅÏ¢¡£

×¢ÖØ£ºÔÚÔËÐÐÒÔÉÏ´úÂë֮ǰ £¬ÐèÒªÏÈ×°ÖÃAdafruit_DHT¿â¡£¿ÉÒÔÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁîÀ´×°Öãº

pip install Adafruit_DHT

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇÔÚLinuxÉÏʹÓÃVisual Studio Code¾ÙÐÐÖÇÄܼҾӿª·¢µÄÍƼöÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ