Introduction: Intel Edison With Grove LCD, Temperature Sensor and Infrared Sensor

Grove LCD、Temperature sensor 與 Infrared sensor

分別是以I2C、ADC、GPIO作為傳輸介面

使用上也相當的簡單

mraa library中有完整的使用方式

Grove的官方資料與範例也相當齊全

所以實作上並不會太困難

Step 1: Grove LCD

此部分需要 import pupm_i2clcd

建議以下寫法(使用Python)

import pyupm_i2clcd as lcd

myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)

myLcd.setCursor(1,0)
myLcd.write('Temperature ')

myLcd.write(str(temperature))

.....

Step 2: Temperature Sensor

此部分需要import math

建議寫法如下

B = 3975

a_pin = mraa.Aio(0)

while True:

pin_value = a_pin.read()

resistance = (1023.0 - pin_value)*10000.0/pin_value
temperature = 1.0/(math.log10(resistance/10000.0)/B+1/298.15)-273.15

需要注意的是數字記得加入小數點 以免計算出來只有整數

Step 3: Infrared Sensor

此處需要import mraa

程式碼如下

detect = mraa.Gpio(7)
detect.dir(mraa.DIR_IN)

while True:

people = detect.read()

if(people):

myLcd.setColor(255, 0, 0)

myLcd.setCursor(0,0)

myLcd.write('People coming....')

else:

myLcd.setColor(0, 255, 0)

myLcd.setCursor(0,0)

myLcd.write('Nobody here....')

Step 4: Mix All Together

import mraa

import time

import pyupm_i2clcd as lcd

import math

B = 3975

detect = mraa.Gpio(7)

detect.dir(mraa.DIR_IN)

a_pin = mraa.Aio(0)

while True:

people = detect.read()

pin_value = a_pin.read()

resistance = (1023.0 - pin_value)*10000.0/pin_value

temperature = 1.0/(math.log10(resistance/10000.0)/B+1/298.15)-273.15

myLcd.setCursor(1,0)

myLcd.write('Temperature ')

myLcd.write(str(temperature))

if(people):

myLcd.setColor(255, 0, 0)

myLcd.setCursor(0,0)

myLcd.write('People coming....')

else:

myLcd.setColor(0, 255, 0)

myLcd.setCursor(0,0)

myLcd.write('Nobody here....')

time.sleep(1)

Comments

author
DIY Hacks and How Tos (author)2015-08-22

Nice Edison project.

About This Instructable

983views

2favorites

License:

Bio: Hi, I'm David. I'm a Taiwanese student. Major in Electronic Computer Engineering in National Taiwan University of Science and Technology.
More by Da-WeiL:DBZ's Damp-proof Case Improvement (Intel IoT)Intel Edison with Grove LCD, temperature sensor and  infrared sensor
Add instructable to: