Final Project - Application

Wire configuration:

The following records were set 1,2,3,4 sequence defined network Cables
Limit switches (far and near): [Bown, Orange, Blue, Green]
Motor drive [12,34] [+, -]: Bown, Orange] [Blue, Green}
Sensing line:
Blue / blue: Vcc / Gnd
Orange / Orange White: Luminosity A0 / D0

I/O List:

Limit switch: (slave) (travel of go and back limits )
5,4,3,2
Motor drive: (slave)
13,12
11,10
9,8
7,6
Sensor: (master)
Temperature and humidity: 2
Moisture: a0, a1, a2, a3
Sensor: (slave)
Luminosity: A0
Moisture: a0, a1, a2, a3
Communication Communication
maset I2C: A4, A5
slave: A4, A5
master Bluetooth: 10, 11
Bluetooth Information Agreement
DATA[8]={'a', humidity_1, humidity_2, humidity_3, humidity_4, Lightval, temperature, moisture}

Firmware

Using two satshakit, main function:
Master board:

1. The temperature and humidity sensor
2. The breeding tube humidity
3. Statistics give a mobile phone
4. Operational judge sent to "slave" execution
slave board:
1. Motor Control
2. Limit switch sensing
3. Photometric Detection sent to "master"

我使用兩片satshakits,完成控制的工作,
"master"主要負責:
1.感應環境溫濕度
2.養殖管濕度
3.統計資料送給手機
4.運算判斷發送給"slave"執行
"slave"負責:
1.馬達控制
2.極限開關感應
3.光度偵測發送給"master"

A special feature is do not use delay instruction in the program, and use the time difference operates. When the program began operating, the time duration to move forward, this value is recalled mill (). Use predicate, perform an action or function call when the time difference is greater than the set. In the MCU fast timing, almost we can do different things at the same time.
比較特別的是程式內都不使用delay()指令,而使用時間差進行動作。當程式開始運作,時間持續地前進,使用mill()將這數值取出。使用判斷式,當時間差大於設定時執行動作或呼叫函式。在MCU快速的計時下,幾乎可以同時做不同事情。
在藍芽通訊部分如week15,但是我將資料數值限制在0~100的整數間,收發將會容易很多。發送與接收端都不需為了只有1byte,而做資料拆解與組合的動作。
其餘功能定義如程式內註解。

Sketch

Interface and Application

In 10'th week15'th week16'th week, we ues app inventor2 finiah assignment.
The main continuation 15'th week produced humidity sensors and Bluetooth communications. Adds more area about sensors values.
1.Bluetooth communication:ListPicker and Button
2.Humidity display: Label and TextBox
3.Luminosity display: Label and TextBox
4.Environment display: Label and TextBox
5.Other element: Notifier, BluetoothClient,Clock


After the interface use is complete, switch to the "blocks" editing program.
Below this process are:
1. initialization process
2. declare global variables
3. Bluetooth communication made address
4. Select the correct address to connect
4. Disconnect Ready

使用介面完成後,切換到"blocks"編輯程式。
下面這段處理的是:
1.初始化過程
2.宣告全域變數
3.藍芽通訊取得地址
4.選擇正確地址進行連接
5.斷開連線功能


The main function here, when that timing, it will send the number "11" to satshakit, declare a local variable to undertake the first received bit. If the information received, and is 'a', the representative of normal communication, each successive bit read into the corresponding spaces. It is displayed on the UI interface. Upon completion of waiting for the next call timing. I am here to set the frequency of once per second. Adjustable receive frequency.
主要功能在這邊,當計時作用時,會發送數字"11"到satshakit ,宣告一個區域變數承接第一個接收位元。若收到資料,且是'a'時,代表通訊正常,連續將每個位元讀出放入相對應的空格內。顯示在UI介面上。完成後等待下一次計時呼叫。我這邊設定的頻率是每秒一次。可調整接收頻率。


Phone screen about receiving data.
接收資料時的手機畫面。


Verification

Individual control board with the power to make the connection. Comprising: sensors, limit switches, motor driver board. All circuits tested first in the table. And repeatedly modify the code to achieve functional needs. As can be seen from the following video to complete the initial operation of the process. And move to large systems, connect the power supply and wiring.
將各個控制板與電源做連接。包含:感測器、極限開關、馬達、驅動板。全部電路先在桌上進行試驗。並反覆修改程式碼,達到需求的功能性。可以由下面影片看出以完成初步的運作過程。並移到大系統中,接上電源供應器及配線。


Troubleshooting:

  • satshakit In the experiment many exceptions, is often found can burn, but the process is performed only once last. Presumably no oscillator start-up, can not lead to continuous operation of the program.
    satshakit在實驗中很多異常,常發現是可以燒錄,但程是只執行一次即止。推測是震盪器沒有起振,導致無法連續運作程式。
  • satshakit Another exception can not be burned, as shown warning the Arduino appears. IC may be burned or shorted.
    satshakit另一種異常是無法燒錄,Arduino出現如下圖之警告。可能是IC燒毀或短路。

  • week15 transfer value is greater than 1byte, so data transfer to be done dismantling. And adjust the light of the week is just the value is transmitted within 1byte relatively simple. Therefore, the information here will be limited to the 1byte can send and receive data structures by successive agreements.
    week15傳輸數值大於1byte,所以傳輸需做拆解資料。而week調整光線之數值則正好是1byte內而傳輸較簡易。所以這邊將資料限制在1byte內即可依協定的資料結構連續發送與接收。
  • Repeated testing and rewriting programs.
    反覆測試及改寫程式。
  • Tools:

  • Arduino IDE
  • APP inventor 2
  • File:

  • Smart_Farm2_master.ino
  • Smart_Farm2_slavr.ino
  • Smart_Farm.apk
  • Reference:

  • WIKI:I²C
  • Master Reader/Slave Sender
  • Wire Library
  • 多台 Arduino 間的通訊 - 透過 I2C #1
    • Fab Academy

      The Fab Academy is a Digital Fabrication Program directed by Neil Gershenfeld of MIT's Center For Bits and Atoms and based on MIT's rapid prototyping course, MAS 863: How to Make (Almost) Anything. The Fab Academy began as an outreach project from the CBA, and has since spread to Fab Labsaround the world. The program provides advanced digital fabrication instruction for students through an unique, hands-on curriculum and access to technological tools and resources.
    • Fablab Tainan

      Fab Lab Tainan was founded at Dec. 2013 at Tainan, Taiwan. It is the first Fab Lab at Southern Taiwan. Supported by Tainan City Government, this Lab hope could open for local citizen. The background photo of web page is the roundabout in front of Tainan train station.
    • Who Am I

      I'm Jia-Hao Chang from Fablab Tainan.I'm senior staff of Association of Digital Culture, Taiwan (ADCT).In this years, I have participated the project of digital curriculum.My career is to empower people employing digital manufacturing technology or tools toimprove their problem.