久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 8995|回復: 1
打印 上一主題 下一主題
收起左側

基于arduino的智能農業系統設計

[復制鏈接]
跳轉到指定樓層
樓主
ID:117823 發表于 2016-5-1 18:06 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
       這是幫同學做的畢業設計,但后來他說讓我用51單片機做了,這個方案就摒棄了。
       愛上arduino是去年上半年,一個偶然的機會從淘寶店里買了塊arduino開發板,就使勁花時間和精力去學習。在我看來arduino開發系統是單片機嵌入式系統中最簡單的,畢竟國外都是給小朋友和藝術家玩的,我們大朋友也可以用來玩玩,應付些簡單的設計要求還是沒有問題的。如果涉及工業生產化,這個還沒有到這個境界。
       現在的物聯網比較火,國內最早起步的yeelink,樂為聯網,還有些小的社區,貝殼物聯,智能創客,當然也有大的企業在做,阿里,qq,微信,移動,機智云的,魚龍混珠。國外的沒有使用過,就不太清楚,有名的有谷歌的,亞馬遜的,IBM等的。我只能說現在還處于探索階段,鹿死誰手還未可知。
      在大數據時代我們能夠做什么,也許可以做一點點。以下是我的構想。
      智能農業無非是在傳統農業上加入入網功能,進行數據分析處理存儲,很簡單的一件事。說起來容易做起來難,吹逼的人大有人在,實施起來還是有些麻煩。
     整體設計也就一個arduino單片機,一個時鐘模塊DS1302,一個溫濕度傳感器AM2301,一個加熱ntc裝置,一個電風扇作為均勻加熱。花了半天時間完成。通過串口輸入特定字符串可以達到控制溫度,調節鬧鐘的功能。因為已經送人了,所以沒有拍圖。

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <LiquidCrystal.h>
  4. #include <DS1302.h>
  5. #include <Wire.h>
  6. #include <AM2321.h>
  7. AM2321 ac;
  8. uint8_t bell[8]  = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
  9. uint8_t note[8]  = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
  10. uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
  11. uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
  12. uint8_t duck[8]  = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
  13. uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
  14. uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
  15. uint8_t retarrow[8] = {    0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
  16. LiquidCrystal lcd(A1, A0, 13, 12, 11, 10);
  17. char buflcd[16];
  18. long previousMillis = 0;  
  19. long interval = 1000;
  20. const int  heat_pwm= 3;
  21. const int motor_pwm = 5;
  22. int val_pwm;
  23. int set_temperature=25;
  24. int sensorPin = A3;
  25. int sensorValue = 0;
  26. int kp=-1,ki=0,kd=-1;
  27. int last_p,now_p;
  28. int last_d,now_d;
  29. int now_i;
  30. void pid()
  31. {
  32.   now_p=ac.temperature-set_temperature*10;
  33.   now_d=now_p-last_p;
  34.   now_i=now_d-last_d;
  35.   last_p=now_p;
  36.   last_d=now_d;
  37.   val_pwm=val_pwm+kp*now_p+kd*now_d+ki*now_i;
  38.   if(val_pwm>255)
  39.   val_pwm=255;
  40.   else if(val_pwm<0)
  41.   val_pwm =0;
  42.   analogWrite(heat_pwm, val_pwm*4/5);
  43.   analogWrite(motor_pwm, val_pwm);
  44. }

  45. void AM2320_DATA()
  46. {
  47. if(ac.read())
  48. {
  49.    sensorValue = analogRead(sensorPin);
  50.   snprintf(buflcd, sizeof(buflcd), "%2d.%dC %2d.%d%s %d   ",
  51.            ac.temperature/10,ac.temperature%10,ac.humidity/10,ac.humidity%10,"%",sensorValue);
  52.            
  53.    lcd.setCursor(0,0);
  54.    lcd.print(buflcd);     
  55. }
  56. }

  57. void lcd_init()
  58. {
  59.   lcd.begin(16,2);
  60.   lcd.createChar(0, bell);
  61.   lcd.createChar(1, note);
  62.   lcd.createChar(2, clock);
  63.   lcd.createChar(3, heart);
  64.   lcd.createChar(4, duck);
  65.   lcd.createChar(5, check);
  66.   lcd.createChar(6, cross);
  67.   lcd.createChar(7, retarrow);
  68. }
  69. namespace {

  70. // Set the appropriate digital I/O pin connections. These are the pin
  71. // assignments for the Arduino as well for as the DS1302 chip. See the DS1302
  72. // datasheet:
  73. //
  74. //   [url=http://datasheets.maximintegrated.com/en/ds/DS1302.pdf]http://datasheets.maximintegrated.com/en/ds/DS1302.pdf[/url]
  75. const int kCePin   = 8;  // Chip Enable
  76. const int kIoPin   = 7;  // Input/Output
  77. const int kSclkPin = 6;  // Serial Clock

  78. // Create a DS1302 object.
  79. DS1302 rtc(kCePin, kIoPin, kSclkPin);
  80. void ds1302_init()
  81. {
  82.   rtc.writeProtect(false);
  83.   rtc.halt(false);
  84. }

  85. String dayAsString(const Time::Day day) {
  86.   switch (day) {
  87.     case Time::kSunday: return "Sunday";
  88.     case Time::kMonday: return "Monday";
  89.     case Time::kTuesday: return "Tuesday";
  90.     case Time::kWednesday: return "Wednesday";
  91.     case Time::kThursday: return "Thursday";
  92.     case Time::kFriday: return "Friday";
  93.     case Time::kSaturday: return "Saturday";
  94.   }
  95.   return "(unknown day)";
  96. }

  97. void printTime() {
  98.   // Get the current time and date from the chip.
  99.   Time t = rtc.time();
  100.   // Format the time and date and insert into the temporary buffer.
  101.   snprintf(buflcd, sizeof(buflcd), "%2d-%d-%d %d:%d:%d   ",
  102.            t.yr-2000, t.mon, t.date,
  103.            t.hr, t.min, t.sec);

  104.   // Print the formatted string to serial so we can see the time.
  105.   lcd.setCursor(0,1);
  106.   lcd.print(buflcd);
  107. }

  108. void edit_time()
  109. {
  110.   /* 串口數據緩存 */
  111. String comdata = "";
  112. int numdata[7] ={0}, j = 0, mark = 0;
  113.   while (Serial.available() > 0)
  114.     {
  115.         comdata += char(Serial.read());
  116.         delay(2);
  117.         mark = 1;
  118.     }
  119.     /* 以逗號分隔分解comdata的字符串,分解結果變成轉換成數字到numdata[]數組 */
  120.     if(mark == 1)
  121.     {
  122.         Serial.print("You inputed : ");
  123.         Serial.println(comdata);
  124.         for(int i = 0; i < comdata.length() ; i++)
  125.         {
  126.             if(comdata[i] == ',' || comdata[i] == 0x10 || comdata[i] == 0x13)
  127.             {
  128.                 j++;
  129.             }
  130.             else
  131.             {
  132.                 numdata[j] = numdata[j] * 10 + (comdata[i] - '0');
  133.             }
  134.         }
  135.         if((numdata[0]>2000)&&(numdata[0]<2100))
  136.         {
  137.         /* 將轉換好的numdata湊成時間格式,寫入DS1302 */
  138.         Time t(numdata[0], numdata[1], numdata[2], numdata[3], numdata[4], numdata[5], Time::kSaturday );
  139.         rtc.time(t);
  140.         }
  141.         else
  142.         {
  143.            if((numdata[0]<60)&&(numdata[0]>10))
  144.            set_temperature=numdata[0];
  145.         }
  146.     }
  147. }

  148. }  // namespace


  149. void setup() {
  150.    Serial.begin(115200);
  151.   // set up the LCD's number of columns and rows:
  152.   lcd_init();
  153.   ds1302_init();
  154. }

  155. void loop() {
  156. unsigned long currentMillis = millis();
  157. if(currentMillis - previousMillis > interval)
  158. {
  159.    previousMillis = currentMillis;
  160.    printTime();
  161.    AM2320_DATA();
  162.   }
  163.    edit_time();
  164.    pid();
  165. }
復制代碼

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:117823 發表于 2016-5-1 18:08 | 只看該作者
這個是程序安裝包,有2個,最新的為1.1版本的。

周義龍智能農業系統.zip

4.36 KB, 下載次數: 33, 下載積分: 黑幣 -5

評分

參與人數 1黑幣 +100 收起 理由
admin + 100 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 午夜欧美一区二区三区在线播放 | 免费在线黄 | 欧美激情精品久久久久 | 999免费网站 | 中文字幕国产 | 日韩一区在线播放 | 国产精品网址 | 免费看国产一级特黄aaaa大片 | 日本三级做a全过程在线观看 | 久久黄网 | 日韩欧美中文字幕在线观看 | 欧美日韩高清在线一区 | 欧美一区二区三区在线 | 日韩在线视频一区 | 国产福利二区 | 中文字幕亚洲欧美日韩在线不卡 | 91成人 | 欧美精品一区二区三区在线播放 | 久久国产精品无码网站 | 一区二区日韩 | 亚洲综合婷婷 | 久久一区二区免费视频 | 国产高清久久久 | 国产欧美精品区一区二区三区 | 精品美女久久久 | 成人午夜影院 | 欧美jizzhd精品欧美巨大免费 | 国产精品国产精品 | 久久国产欧美日韩精品 | 亚洲97 | 亚洲精品在线看 | 福利片一区二区 | 欧美视频一区 | 波多野吉衣在线播放 | 国产十日韩十欧美 | 久久精品久久久久久 | 中文字幕日韩专区 | 毛片网站在线观看 | 成人中文字幕在线 | 国产片侵犯亲女视频播放 | 日日做夜夜爽毛片麻豆 |