2014年1月12日 星期日

Measuring Soil Moisture

Soil Moisture Sensor can be used to detect the moisture of soil if there is water around the sensor, let the plants in your garden reach out for human help. They can be very easy to use, just insert it into the soil and then read it. With the help of this sensor, we will know soil state.

Soil Moisture Sensor
Reference : Grove Moisture Sensor

Compare of adding the water before and after
 
Dry soil                  Humid soil

Changes in the soil moisture during a three day period
Sensor A : Value from 480 to 310 (-35%)
Sensor B : Value from 380 to 280 (-26%)
Sensor C : Value from 500 to 440 (-12%)

Compare of adding the 100ml water before and after
Sensor A : Value from 310 to 700 (+126%)
Sensor B : Value from 280 to 520 (+86%)
Sensor C : Value from 440 to 700 (+59%)
Add water tool

2014年1月2日 星期四

Arduino UNO + CC3000 WiFi Module

This demo is CC3000 module for the WiFi communication, uses the examples code "EchoServer.ino", it connects to the access point, get a connection with DHCP.

Board : Arduino Uno
Module : CC3000 WiFi Module
On the CC3000 shield, I use the following pin connections.
  • PIN 1 - GD to Arduino GND
  • PIN 2 - VD to Arduino 3.3V
  • PIN 3 - CS to Digital 10
  • PIN 4 - DO(MISO) to Digital 12
  • PIN 5 - DI(MOSI) to Digital 11
  • PIN 6 - CK(CLK) to Digital 13
  • PIN 7 - IQ(IRQ) to Digital 3
  • PIN 8 - EN(VBEN) to Digital 5
Library & Examples code : Adafruit_CC3000 librar

Demo : 

To run the sample sketches, you'll have to edit them to include the SSID and password of your access point.
#define WLAN_SSID     "myNetwork"      // cannot be longer than 32 characters!
#define WLAN_PASS     "myPassword"

Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2).
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

Here's a sample of the Serial Monitor output of buildtest.
Hello, CC3000!

Free RAM: 1059

Initializing...
Started AP/SSID scan



Connecting to Steve_AP...Waiting to connect...Connected!
Request DHCP

IP Addr: 192.168.0.109
Netmask: 255.255.255.0
Gateway: 192.168.0.1
DHCPsrv: 192.168.0.1
DNSserv: 168.95.1.1

NOTE: This sketch may cause problems with other sketches
since the .disconnect() function is never called, so the
AP may refuse connection requests from the CC3000 until a
timeout period passes.  This is normal behaviour since
there isn't an obvious moment to disconnect with a server.

Listening for connections...





2013年12月30日 星期一

Comparison of three kinds of soil moisture sensor

Three kinds of soil moisture sensor
Chip : Arduino Duemilanove ATmega 328
Module : Moisture Sensor

Demo
/*******************************************************
EX_07 : Soil Moisture Sensor
2013/12/24 SteveChang, PMP (sown813@gmail.com)
********************************************************/
int MoistureSensorPin1 = A0;  // select the input pin for the potentiometer
int MoistureSensorPin2 = A1;
int MoistureSensorPin3 = A2;

int SensorValue1 = 0;  // variable to store the value coming from the sensor
int SensorValue2 = 0;
int SensorValue3 = 0;

void setup()
{
  Serial.begin(57600);  
}

void loop()
{  
  // read the value from the sensor:
  SensorValue1 = analogRead(MoistureSensorPin1);
  SensorValue2 = analogRead(MoistureSensorPin2);
  SensorValue3 = analogRead(MoistureSensorPin3);
  delay(60000);
  
  Serial.print(SensorValue1);
  Serial.print(",");
  Serial.print(SensorValue2);
  Serial.print(",");
  Serial.println(SensorValue3);
}

2013年12月17日 星期二

Using an Arduino's PWM to control a DC motor

I using an Arduino's PWM to control speed of the motor.

Chip : Arduino Leonardo
Module : LCD KeyPad Shield (SKU: DFR0009)
Transistors : NPN TIP122
Motor : DC 3~6V

Demo

PWM Library
Arduino/Wiring SoftPWM Library
Code
/*******************************************************
Ex_06 : Using PWM to control a DC motor
2013/12/18 SteveChang, PMP (sown813@gmail.com)
********************************************************/

// Motor Control library
#include "SoftPWM.h"
#include "SoftPWM_timer.h"

//Sample using LiquidCrystal library
#include "LiquidCrystal.h"
 
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 
// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;

// LCD Backlit Control
int BacklitControl = 10;
static int LCDBacklit;

// PWM Status
int PWM_Status = 0;

// Button define
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

#define fadePin 2

// read the buttons
int read_LCD_buttons()
{
  adc_key_in = analogRead(0);      // read the value from the sensor 
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
  if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 
// For V1.1 us this threshold
/*
  if (adc_key_in < 50)   return btnRIGHT;  
  if (adc_key_in < 250)  return btnUP; 
  if (adc_key_in < 450)  return btnDOWN; 
  if (adc_key_in < 650)  return btnLEFT; 
  if (adc_key_in < 850)  return btnSELECT;  
*/
 
// For V1.0 comment the other threshold and use the one below:

  if (adc_key_in < 50)   return btnRIGHT;  
  if (adc_key_in < 195)  return btnUP; 
  if (adc_key_in < 380)  return btnDOWN; 
  if (adc_key_in < 555)  return btnLEFT; 
  if (adc_key_in < 790)  return btnSELECT;   

  return btnNONE;  // when all others fail, return this...
}
 
void setup()
{
  lcd.begin(16, 2);              // start the library
  lcd.setCursor(0,0);
  lcd.print("Push the buttons"); // print a simple message
  pinMode(BacklitControl, OUTPUT);
  digitalWrite(BacklitControl, LOW);
    
  // Initialize
  SoftPWMBegin();
  // Create and set pin 13 to 0 (off)
  SoftPWMSet(fadePin, 0);
  // Set fade time for pin ? to 300 ms fade-up time, and 700 ms fade-down time
  SoftPWMSetFadeTime(fadePin, 300, 700);    
}
  
void loop()
{  
  lcd.setCursor(0,1);            // move to the begining of the second line
  lcd_key = read_LCD_buttons();  // read the buttons
  SoftPWMSetPercent(fadePin, PWM_Status);
  delay(15);
  
  switch (lcd_key)               // depending on which button was pushed, we perform an action
  {
     case btnRIGHT:
       {
          lcd.print("RIGHT ");
          break;
       }
     case btnLEFT:
       {
          lcd.print("LEFT   ");
          break;
       }
     case btnUP:
       {
          PWM_Status += 20;
          if(PWM_Status > 100)
             PWM_Status = 100;
          lcd.print("Status    ");
          lcd.print(PWM_Status);
          lcd.print("%     ");
          delay(500);
          break;
       }
     case btnDOWN:
       {
          PWM_Status -= 20;
          if( PWM_Status < 0 )
              PWM_Status = 0;              
          lcd.print("Status    ");
          lcd.print(PWM_Status);
          lcd.print("%     ");
          delay(500);
          break;
       }
     case btnSELECT:
       {
          lcd.print("SELECT");
          LCDBacklit = LCDBacklit == HIGH ? LOW : HIGH;
          digitalWrite(BacklitControl, LCDBacklit);
          delay(500);
          break;
       }
       case btnNONE:
       {
          lcd.print("NONE     ");
          break;
       }
   }
}

2013年12月13日 星期五

Temperature Compared DHT11 and Thermistors with Weather Bureau (2013/12/12)

昨天凌晨因 Windows Update 所以 03:30~06:50 左右的資料是不見了。
另外, 我有試著把資料做 零時校準, 也就是大家所量到的值, 都以 00:00 齊頭, 意外的發現, 熱敏電阻 100Ω是最接近氣象局的數據。
2013/12/12 All sensors 


2013/12/12 All sensors level correction with Weather Bureau


-------------------- Detailed analysis --------------------
2013/12/12 Humidity Compared DHT11 level correction with Weather Bureau
The bottom line is the default Humidity value 45%, top line is level correction to 61%.


2013/12/12 Temperature Compared DHT11 with Weather Bureau
No uses level correction.


2013/12/12 Temperature Compared Thermistor 100Ω with Weather Bureau
The default value is 25.22℃, level correction to 19.4℃, all value add -5.82℃.


2013/12/12 Temperature Compared Thermistor 200Ω with Weather Bureau
The default value is 18.84℃, level correction to 19.4℃, all value add 0.56℃.


2013/12/12 Temperature Compared Thermistor 1KΩ with Weather Bureau
The default value is 17.04℃, level correction to 19.4℃, all value add 1.96℃.


2013/12/12 Temperature Compared Thermistor 10KΩ with Weather Bureau
The default value is 21.32℃, level correction to 19.4℃, all value add -1.92℃.


2013/12/12 Temperature Compared Thermistor 100KΩ with Weather Bureau
The default value is 16.53℃, level correction to 19.4℃, all value add 2.87℃.

2013年12月12日 星期四

Temperature Compared DHT11 and Thermistors with Weather Bureau (2013/12/11)

第一次 DHT11 量到的溫度與氣象局發佈是一樣的, 不過濕度就有些落差了,熱敏電阻則是以 200Ω 最為接近。
發覺氣象局的資格都是翌日中午過後才會發佈, 網站只保留最近 30天, 昨天半夜 3點 Windows Update, 結果重開機, 12/12 號會有幾個小時資料不見。

2013/12/11 All sensors 
-------------------- 以下細部分析 --------------------
2013/12/11 Humidity Compared DHT11 with Weather Bureau


2013/12/11 Temperature Compared DHT11 with Weather Bureau


2013/12/11 Temperature Compared  - Thermistors with Weather Bureau


2013/12/11 Temperature Compared  - Thermistor(100Ω) with Weather Bureau


2013/12/11 Temperature Compared  - Thermistor(200Ω) with Weather Bureau


2013/12/11 Temperature Compared  - Thermistor(1KΩ) with Weather Bureau


2013/12/11 Temperature Compared  - Thermistor(10KΩ) with Weather Bureau


2013/12/11 Temperature Compared  - Thermistor(100KΩ) with Weather Bureau

2013年12月10日 星期二

Temperature Compared DHT11 and Thermistors with Weather Bureau (2013/12/10)

昨日量測數據, 與氣象局發佈之數據相比較, 網站歷史資料都是每 1Hr 一筆, 即時資料約 15min一筆, 但更新時間不固定, 有時 1~2hr 才會更新。

2013/12/10 Temperature Compared DHT11 with Weather Bureau

2013/12/10 Humidity Compared DHT11 with Weather Bureau


2013/12/10 Temperature Compared Thermistors with Weather Bureau

2013年12月8日 星期日

Auto Pump

做了一個抽水馬達的實驗 情境是~ 
  1. 待機狀態時 LED 慢速閃爍。
  2. 水位過低 LED 高速閃爍 10 秒 ( 主要用於防止開關彈跳現象 )。
  3. 起動 Pump, LED 恆亮, 每次起動 5 秒鐘。
  4. 無窮迴圈。
可應用範圍
  1. 低水位偵測到 並閃爍警告 or 起動馬達加水。
  2. 土壤濕度不足警告 & 起動馬達加水。
  3. 滿水位偵測到 並閃爍警告 or 停止馬達加水。

[實驗結果]

2013年12月7日 星期六

Compared DHT11 with Thermistors

假日主要實驗了 DHT11 (兩塊模組), 及四個熱敏電阻量測, 以及改善軟體功能。
這兩天會做熱敏電阻量測, 及低水位幫浦 實驗, 當偵測水位過低時起動沈水馬達加水。

2013/12/07 All sensors
-------------------- 以下細部說明 --------------------
軟體改善功能
  1. 加入了 Auto Save 功能, 程式每1分鐘會自動儲存一次, 避免軟硬体當機, 資料流失。
  2. 加入了 Watch Dog 功能, 程式每1分鐘會去檢查連線是否正常, 如有斷線, 會自動重新連線。
  3. 修改曲線顏色, 讓圖表顯示更明顯。
  4. 加入 ini 設定功能, 可隨時修改 ColumnHeader , 以利往後隨時要量測任何東西, 可以隨時修改。
DHT11模組
兩塊模組的溫度變化差不多, 但濕度就有點差距了。
氣象局網站 2013/12/06~2013/12/07 溫度(16.8℃~26.7℃) , 濕度 (37%~74%)

2013/12/06~2013/07 Two DHT11 ( Temperature + Humidity )


2013/12/06~2013/07 Two DHT11 ( Temperature )
氣象局網站 2013/12/06~2013/12/07 溫度(16.8℃~26.7℃) 


2013/12/06~2013/07 Two DHT11 ( Humidity )
氣象局網站 2013/12/06~2013/12/07 濕度 (37%~74%)

熱敏電阻
因計算公式出了錯, 及硬體也有問題, 所以量測變化並無太大差異, 此部份問題皆已改善, 過兩天會有新的報表。
2013/12/06 Compared DHT11 with Thermistors (Before Improve)


2013/07 Compared DHT11 with Thermistors (Improved)

2013年12月4日 星期三

Improve conditions for measurements

我彷造氣象觀測箱環境,, 讓它不直接照到陽光, 並保持通風, 效果有比較好點, 以往過白天溫度會飆高到40℃~50℃,改良後,白天量測約 25℃~28℃, 與 氣象局的溫度量測值差不多, 波形也比較正常些了
  1. 亮度變化不會太快飽和。
  2. 溫度,空氣濕度變化不會太大。
  3. 土壤濕度變化也不會太大。
高雄氣象站 日期: 2013/12/04
時間 溫度(°C) 濕度(%)
01:00 18.2 66
02:00 18.0 68
03:00 17.7 68
04:00 17.3 70
05:00 16.7 72
06:00 16.7 69
07:00 16.8 69
08:00 18.0 62
09:00 20.2 59
10:00 22.0 56
11:00 23.3 54
12:00 23.3 56
13:00 23.7 52
14:00 23.6 47
15:00 23.8 38
16:00 23.1 51
17:00 22.2 55
18:00 21.6 57
19:00 21.0 53
20:00 20.3 53
21:00 19.5 56
22:00 19.1 57
23:00 19.0 56
24:00 18.8 58

Waveform comparison


Measurement Environmental

2013年12月2日 星期一

After four days of observation

經過四天的觀察, 有得到一些心得與想法
  • 土壤濕度四日無明顯差異,四天不澆水白天還會上昇,晚上則下降,似乎量到的非土壤濕度(有可能是電導度),至於白天為何會上昇,個人認為與日照昇溫有關,即鐵片吸熱後,而影響到量測的結果,固考慮之後盆栽需要遮陽。
  • DHT11溫濕度量測到,溫度與濕度的相對變化,即溫度昇,濕度降,濕度明明顯的不穩定高頻。
  • 熱敏電阻我似乎買太大了,以致於量測數據變化不明顯,不過該上昇及下降是都有變化,應該要找合適形號再量測一次。
  • 溫度方面,DHT11白天量到近50℃高溫,似乎麵包下面的鐵板吸熱,影響到整體量測數據,想打造一個 氣象觀測箱,來做量測。
  • 四天內軟體crash一次,藍芽當一次,原因不明,不知道是否與高溫晒有關。
  • 軟體缺少 AutoSave , 及 WatchDoc 機智 ,以至於 crash 後,一段時間的記錄遺失。
目前想到的改善流程有~
  1. 打造一個合適穩定的量測環境(室外量測平台),但這部份要做的工程就比較大些,我沒有電踞....。
  2. 將所有溫濕度感測器同時接上(目前有四顆不同形號的 DHT11),並做差異分析,找出最穩定的型號。
2013/11/29~12/02 All sensors


2013/11/29~12/02 Soil moisture


2013/11/29~12/02 Temperature


2013/11/29~12/02 DHT11( Temperature + Humidity ) Sensor


2013/11/29 All sensors


2013/11/30 All sensors


2013/12/01 All sensors


2013/12/02 All sensors


2013年11月29日 星期五

The first cake comes out of the oven.

Yellow Line - Brightness
Red Line - Temperature
Blue Line - Humidity

自家頂樓量測

將量測工具架設自家頂樓陽台, 希望這幾天別下雨 XD



[量測結果]