레이블이 ambiency인 게시물을 표시합니다. 모든 게시물 표시
레이블이 ambiency인 게시물을 표시합니다. 모든 게시물 표시

2015. 3. 6.

[Casual hacking] 아두이노 센서 키트, GPIO 앱으로 연동하기 1탄 : Laser, PIR 센서

 [Casual hacking] 아두이노 센서 키트 GPIO 앱으로 연동하기 1탄 : Laser, PIR 센서

GPIO 앱을 통해 여러 가지 프로젝트를 보여드린 바 있습니다!

초음파 센서로 'air button' 만들기

PIR 센서로 '신호등(traffic lights) 만들기

이번 포스팅에서는 시중에서 판매되는 여러가지 센서들을 GPIO 앱으로 연동하는 것을 보여드리려고 해요.

(문 앞의 레이저 센서?!)

(Bugs 보드에 손바닥?!)

사용된 센서 패키지를 소개해드리겠습니다!


이 중에서
- Laser sensor
- Sound sensor
- Tilt sensor
- Liquid level sensor
이 패키지에는 없지만,
- PIR sensor
를 NARAN 사무실에서 어떻게 사용하는 지 보여드리겠습니다!

우선 1탄에서는 Laser 센서와 PIR 센서의 사용을 보여드리겠습니다.

# 센서 연동 테스트




해당 센서들의 데이터 시트는 http://www.eleparts.co.kr/EPXDPVYB 에서 확인하실 수 있습니다!
(development resources를 확인하세요!)

  • PIR 센서 설정값
 PIR은 Interrupted - Pull up 을 활용합니다.

  • 레이저 센서 설정값
레이저 센서는 시리얼 통신을 이용해 데이터값을 받아야 하지만, 이 패키지의 센서는 그리 사양이 좋지 않다보니 제대로 데이터값이 넘어오지는 않네요.
그래서 Interrupted - Pull up 을 이용하기로 했습니다.

GPIO17, GPIO18 에 Interrupted를 설정해주세요.





# 센서들을 이용한 자동화 규칙 만들기

## Laser sensor


Laser 센서의 용도
- 사무실 입구에 있는 Hue 전등 색 바뀌기
- 출입문에 사람이 왔다갔다한 횟수


위의 완성된 룰 이미지를 보면,

"GPIO17에 연결된 센서가 Edge rising 이면,
입구의 Hue 두 개가 Random color 로 바뀐다"

입니다.

이렇게 사람이 지나가면 전등의 색이 바뀝니다!

레이저 센서(Laser sensor)가 있는 분들은 Hue 전등이 없더라도 다른 액츄에이터를 이용해서 써보세요!
아래의 룰 이미지를 공유하시면 저희 사무실에서 사용하는 것과 같이 똑같이 사용할 수 있습니다.



출입문 통과 횟수는 베타 버전의 앱을 테스트하면서 구현해봤습니다.
조만간 프로타 사용자분들이 사용해볼 수 있도록 열심히 노력할게요 :)


## PIR sensor


PIR 센서의 용도
- 버그보드에 포스트잇을 붙이고 터치를 하면 음악 재생
- 30초 후 음악 재생 정지


위의 완성된 룰 이미지를 보면,

"GPIO 18에 Interrupted Edge Rising이 일어나면,
Volumio(스트리밍 뮤직 플레이어)가 재생되고,
60초 후에 꺼져라"

입니다.

데모 영상을 보세요!





아주 간단하죠?

여러분도 아래의 룰 이미지를 공유받아서 직접해보세요!



여기까지 GPIO 앱으로 아두이노 센서 키트 연동하기 1편 이었습니다!

다음 2편을 기대해주세요 :)

2015. 2. 16.

[Advanced features] Ambiency Language : What is AMBLANG?

 [Advanced features] Ambiency Language : What is AMBLANG? 





1. Overview

* Amblang is a mini language for specifying filters and actuator input parameters.


###### The grammar
The context-free grammar of amblang is as follows.


  ````
  expr          ::= "{{" (expr | sym) [conv] "}}"
                    | "{{" [expr] conv "}}"
  sym           ::= identifier
                    | literal
  identifier    ::= \w [(\w | \d)+]
  conv          ::= "!" func
  func          ::= identifier "(" args ")"
  args          ::= arg [args]
                    | expr
                    | sym
                    | e
  literal       ::= number
                    | ('"' | "'") .* ('"' | "'")
  number        ::= ["-"] \d+ ["." \d+]
  ````

Expressions can be embedded in any kind of text. When evaluated, the result can be any type of object and will be accordingly put into the enclosing text.

###### Evaluation
An expression is evaluated into one of the following types.
* symbol
* number
* bool
* object

A symbol is not evaluated unless it's enclosed with double curly braces ({{}}). The value of a symbol is retrieved from the provided symbol table containing sensor data with corresponding names.
A literal is either a string enclosed with quotations (single or double) or a number (integer or float).

If the result is an object, it must be consumed by a converter function until the end of evaluation. Failing to do so, the original expression will be remained.


A converter function can be applied to any expression with zero or more arguments. When failed, the original expression will be remained but without the converter function itself.


2. Examples
---
---

Amblang is used in sensor filters and actuator inputs. In sensor filters, amblang must be evaluted into a bool-type result. For actuator inputs, amblang must produce values of a type the actuator expects; otherwise, the actuator will not be executed.


###### Sensor Filters

When specifying filters for sensor data, users can write a filter expression in amblang. All sensor data fields can be used in a expression, and more than one expression are allowed but must result in a single boolean value at the end.

Consider the following filter expression for the Email sensor.


  ````
      {{ sender!endswith("thenaran.com") }}
  ````

This will check if the first sender's domain is "thenaran.com." and get evaluated to a boolean value; true or false.


  ````
      {{ {{ receivers!len }}!gt(1) }}
  ````

This expression will be evaluated to true only if the number of receivers is greater than 1, meaning the email was sent to multiple recipients.
Specifying multiple expressions in more than one depth is also allowed.


  ````
      {{ {{ {{ receivers!len }}!gt(1) }}!and({{ sender!endswith("thenaran.com") }}) }}
  ````

This evaluates to true only if the email is from "thenaran.com" and sent to multiple recipients.


###### Actuator Inputs
Actuators consumes sensor data. However, from time to time, sensor data have different types and formats making direct feeding impossible. Amblang can be used to re-format any type of sensor data and assign to actuator inputs accordingly.

As an example, the Email application has an actuator which can send an email message with or without attachments.
The email's send actuator expects the following inputs.

* receivers : string
* subject : string
* message : string
* file : binary
* file name : string

Each input field has its type and it must be respected in order for a rule to succeed. For each field, amblang can be used for formatting and converting sensor data.

For instance, in a string field, an amblang expression must be evaluated into a string. If it fails to produce a corresponding input type, the expression leaves as it is written before evaluation. In other types of fields, the actuator will not be executed unless all inputs have appropriately-typed values.

Consider the following input expression for the Email actuator's subject field. The WebCam application is used as an example sensor, and the trigger is "snapshot available". 


  ````
      Snapshot taken at {{ time!strftime("%a, %d %b %Y %H:%M:%S +0000") }}
  ````

the message field,


  ````
      Checkout the snapshot below.
  ````

and the file field which expects a binary data,


  ````
      {{image}}
  ````

The "snapshot available" trigger produces two types of sensor data; timestamp and snapshot image file.
Each data is available under the symbols "time" and "image" respectively. The "time" data is an integer type so it must be converted to a string. In this example, the "strftime" converter is used to format the millisecond timestamp into a human-readable text.
The "image" data is a binary data so it can be directly fed to the file field.


Once a motion is detected on the webcam and the snapshot gets ready, an email with the above inputs is sent with the snapshot as an attachment file.


3. Recap
---
---
Amblang is a micro-programming language that defines sensor data filter and actuator input values. It is an advanced feature of possibilities that may require getting used to, but it is not a big deal for most users because Rules can be shared and applied with almost no effort.

This is only a part of Amblang and more will be shared in the coming weeks.


4. Rule Example
---
---


Try out now with a drag-and-drop of the below image file onto your Ambiency. All you need to do is drop the image file onto the app, you can see it applied instantly.

[Advanced features] Ambiency Language : 엠블랑(AMBLANG) 이란?

 [Advanced features] Ambiency Language : 엠블랑(AMBLANG) 이란? 

자동화 룰을 만들면서 조금 더 세세한 제어를 원하신 적이 계신가요?

자동화 룰을 조금 더 나에게 맞게 사용하고 싶은 분이 있다면,
엠블랑(AMBLANG)을 배워보세요!
조금 어렵지만 꽤 강력합니다.



'센서 필터(sensor filters)', '액츄에이터 인풋(actuator inputs)' 설정시 엠블랑을 사용하면 더 정확하게 룰을 만들 수 있습니다. 센서필터 화면 왼쪽 아래에 "Advanced" 버튼을 누르시면 엠블랑으로 필터 설정을 할 수 있고, 액츄에이터 화면에서는 바로 엠블랑을 활용하여 각 인풋 필드에 값을 설정 할 수 있습니다.


(Sensor app 필터(filters) 화면)

(Actuator app 인풋(inputs) 화면)



AMBLANG



1. Overview


  • 엠블랑(AMBLANG)은 엠비언시 앱의 ‘필터’와 액츄에이터의 인자값을 명시하기 위한 조그만 프로그래밍 언어입니다.


The grammer

엠블랑의 문법(the context-free grammar)은 아래와 같습니다.

  ````
  expr          ::= "{{" (expr | sym) [conv] "}}"
                    | "{{" [expr] conv "}}"
  sym           ::= identifier
                    | literal
  identifier    ::= \w [(\w | \d)+]
  conv          ::= "!" func
  func          ::= identifier "(" args ")"
  args          ::= arg [args]
                    | expr
                    | sym
                    | e
  literal       ::= number
                    | ('"' | "'") .* ('"' | "'")
  number        ::= ["-"] \d+ ["." \d+]
  ````
위의 문법을 사용한 표현식은 어느 텍스트에도 포함될 수 있습니다. 텍스트에 포함된 표현식이 도출될 때 그 결과는 객체의 어떤 타입으로도 도출될 수 있고 문자열이 될수도 있습니다.

Evaluation

하나의 표현식은 아래의 타입들 중 하나로 도출됩니다.
  • symbol
  • number
  • bool
  • object (객체)

symbol은 중괄호({{ }})로 둘러쌓여 있지 않으면 도출되지 않습니다. symbol value는 일치하는 항목의 센서데이터를 포함하는 symbol table 에서 얻을 수 있습니다. 표현식 내에서의 문자는 따옴표 혹은 쌍따옴표로 둘러 쌓여져 있어야 도출이 되고, 숫자는 정수 혹은 실수만 사용할 수 있습니다.

결과값이 객체라면, 표현식에서 도출이 완료될 때까지 변환되어 재가공되어져야 합니다. 재가공이 실패하게되면, 원래의 표현이 그대로 남게 됩니다.


2. Examples


엠블랑은 센서 필터(Sensor filters)와 액츄에이터 인풋(Actuator inputs)에 사용됩니다. 센서필터에서는 엠블랑은 bool-type 결과로 도출됩니다. 액츄에이터 인풋에서 사용되기 위해 엠블랑은 액츄에이터에서 요구되는 값으로 작성되어야 하며, 그렇지 않을 경우 액츄에이터가 제대로 실행이 되지 않을 수 있습니다.

Sensor Filters(센서 필터)

센서 데이터를 센서 필터에 구체적으로 쓰기 위해서 사용자는 엠블랑의 문법에 맞게 사용해야 합니다. 모든 센서 데이터 필드들은 한 가지 표현으로 사용되어야 하고, 한 개 이상의 표현식을 사용은 할 수 있지만, 한 가지의 boolean으로 사용되어야 합니다.

예로, 이메일 센서에서 사용되는 필터 표현식은 아래와 같습니다.

  ````
      {{ sender!endswith("thenaran.com") }}
  ````
처음 메일 송신자의 도메인이 “thenaran.com”인지를 체크하고, boolean value가 ‘true’인지 ‘false’인지를 도출하게 됩니다.

  ````
      {{ {{ receivers!len }}!gt(1) }}
  ````
위 표현식은 수신자의 숫자가 1보다 커야지만 ‘true’ 값으로 도출하고, 이메일이 다수의 수신자에게 보내졌다는 것을 의미합니다.

1 depth 이상에서 여러 표현식들을 구체화하는 것 또한 가능합니다.

  ````
      {{ {{ {{ receivers!len }}!gt(1) }}!and({{ sender!endswith("thenaran.com") }}) }}
  ````
위 표현식은 “thenaran.com” 도메인으로부터 오고, 여러 수신자에게 보내질 때만 ‘true’ 값으로 도출됩니다.

Actuator Inputs(액츄에이터 인풋)

액츄에이터는 센서 데이터를 사용합니다. 센서 데이터가 다른 타입을 가지고 있어서 바로 적용하지 못하는 포맷인 경우가 있습니다. 엠블랑은 센서 데이터의 타입을 재가공하여 사용할 수 있게 해주며, 액츄에이터 인풋에서 요구하는 타입으로 맞춰서 값을 줄 수 있습니다.

한 예로 메일 앱이 액츄에이터로 사용될 때 첨부파일이 있는 경우 혹은 없는 경우로 메일을 보내는 경우가 있습니다.
메일의 ‘메일 송신 액츄에이터’는 아래의 인풋 데이터 필드를 지원합니다.
  • receivers : string
  • subject : string
  • message : string
  • file : binary
  • file name : string

각 액츄에이터 인풋 필드는 자동화 룰이 실행되기 위해서 필요한 값을 받게 되는데, 엠블랑은 센서데이터를 변환하여 액츄에이터 인풋 필드에서 사용될 수 있게 만들 수 있습니다.
이때 변환되는 최종값은 인풋 필드에서 요구하는 타입에 맞아야 룰이 실행 될 수 있습니다.
예를 들어, string 필드에서 엠블랑 문법을 통해 string으로 도출해야 합니다. input type(string이어야 하는 경우)을 string으로 만들지 못한다면, 원래의 input type으로 쓰여지게 됩니다. 다른 필드 타입의 경우, 모든 인풋 데이터가 적절한 타입으로 변환되지 않는다면 액츄에이터가 제대로 실행되지 않습니다.

웹캠(WebCam)앱이 센서로 사용되어 trigger가 ‘snapshot 사용’인 경우의 이메일 액츄에이터 제목 필드 부분의 인풋 표현식을 보겠습니다.

  ````
      Snapshot taken at {{ time!strftime("%a, %d %b %Y %H:%M:%S +0000") }}
  ````
메세지 필드(message field),

  ````
      Checkout the snapshot below.
  ````

바이너리 데이터가 쓰여져야되는 파일 필드(file field),

  ````
      {{image}}
  ````
"snapshot 사용” trigger는 센서 데이터에서 두 개의 타입을 만드는데, ‘타임 스탭프(time stamp)’와 ‘스냅샷 이미지 파일(snapshot image file)’입니다.
각 데이터는 개별적으로 “time”과 “image”로 사용이 가능하고, “time” 데이터는 integer(정수)이기 때문에 string으로 변환되어져야 합니다. 이 경우 “strftime” 변환기가 사람이 읽을 수 있는 글자로 “time” 데이터를 천분의 일초(milisecond)로 변환합니다.


일단 웹캠에 움직임이 감지되면(motion detected), 위 인풋 값들이 쓰여진 이메일 앱이 첨부파일로 스냅샷을 함께 보내게 됩니다.



3. Recap

엠블랑은 센서 데이터 필터와 액츄에이터 인풋 값 정의에 사용되는 미니 프로그래밍 언어 입니다.
조금 복잡하기 때문에 전문가 분들만 사용하시겠지만, 복잡한 룰이라도 공유 받아 사용하는데는 전문지식이 필요없기 때문에 큰 걱정은 안 하셔도 될 겁니다.

아직 다 엠블랑의 기능을 보여드리진 못 했습니다. 앞으로 천천히 룰도 공유하면서 엠블랑을 더 깊게 알려드리도록 하겠습니다.



4. Rule Example




아래의 룰 이미지를 여러분의 엠비언시(ambiency) 페이지에 드래그 앤 드랍(drag & drop)하면, 룰이 공유되어 엠블랑(Amblang)의 사용예제를 직접 보실 수 있습니다.


2015. 2. 15.

[Casual hacking] GPIO app project 2 : how to build Air Button using ultrasonic sensor

[Casual hacking] GPIO app project 2 : how to build Air Button using ultrasonic sensor 



This is the second project using the GPIO app.
Please note the following to build an Air Button using an ultrasonic sensor.

First of all, ultrasonic sensor adopts serial communication called UART.
If you would like to check out the specification of the sensor, you can do so by clicking the link below.
(Please note the data sheet or details from the product page of your purchased goods)

Product information from ultrasonic sensor: HG-C40U


From here on, please follow the instructions below.


1. Get your breadboard ready




Like in the picture, only TxD, RxD, GND, and 5V are connected.
An LED has also been pinned to be notified whether the settings are working properly.



2. Configure UART from the GPIO app
Please configure your settings as shown in the guideline of UI of GPIO app.
  • Baud rate : 38,400 bps
  • Data bit : 8 bit
  • Stop bit : 1 bit
  • Buffer size : 100
    • The buffer size means the number of letters that can be delivered at one transfer.
  • Register all values &  Set !
  • As a result, 'Read data’ of ultrasonic sensor is retrieved.
  • /x32/x37/x03/x02/x5e/x31/x37/x32/x38/x03/x02/x5e.. so on. Data like /x03/x02 repeats and meaningful data follows from the third.
  • (note that this is limited to HG-C40U specification and data may differ depends on your ultrasonic models.)


I will also pin a LED to provide me a feedback of whether the ultrasonic sensor has been properly placed.


3. Test the ultrasonic sensor


To test whether the ultrasonic sensor has been placed properly, I will use the rules below.

Like in the clip below, tests can be made with the two automation rules.



Lets go over with how to configure the first Rule.

“If the distance reading on ultrasonic is less than 10cm, turn on the LED."


- Check out the configuring process of the first Rule in .gif!



<How to configure a sensor app>
1. select GPIO app
2. select UART serial
3. UART Read
4. (check the green checkbox)
5. select and register filter : click '+ Advanced'
 Test True : {{{{{{data!split("\x03\x02^")}}[1]!to_int}}!le(100)}}
This works by parsing /x03/x02 and making use of the second data in list(=[1]). This is the value retrieved from ultrasonic sensor.
(This may be a bit difficult step to some of us.. in short, le(less than and equal to) 100mm. Try testing by changing the numbers yourself!)

If you’d like to understand more about how to register code in filter values and build the rule for yourself, please try out the link(blog) below.

<How to configure an actuator app>
1. select GPIO app 
2. select Write Digital
3. select GPIO pin$
4. (check the green checkbox), Set '1’(turn on the LED)



Lets check out how to setup the second Rule.

“If the distance reading on ultrasonic is more than 10cm, turn off the LED."

- Check out the configuring process of the second Rule in .gif!



<How to configure a sensor app>
1. select GPIO app
2. select UART serial  
3. UART Read  
4. (check the green checkbox)
5. select and register filter : click '+ Advanced'
  Test True : {{{{{{data!split("\x03\x02^")}}[1]!to_int}}!ge(100)}}
(ge(greater than and equal to) 100mm.)

<How to configure an actuator app>
1. select GPIO app
2. select Write Digital
3. select GPIO pin$
4. (check the green checkbox), Set '0’(turn off the LED)


4. Build an Air button!



Lets make use of the rules we created above for testing and create an air button.
Using the button and the Volumio app, I can 'Play music', 'Stop music', 'Volume up', 'Volume down.'

I’ve marked the heights for the buttons using a ruler and some Post-it.
… and this’s what my desk looks like :)

# Marking buttons





Heights for Air Button

         ~ 10cm : volume up
11cm ~ 20cm : volume down
21cm ~ 30cm : play music
31cm ~ 40cm : stop music

# Create automation rules



Please note the gif above for creating the first rule.

This’s been the guideline of creating an Air Button using ultrasonic wave.

Try building a button of different purpose.

Control digital devices and appliances using an Air Button next to yo ur bed.
“I wish I could turn on and off the bedside lights with Air Button."
“Turn on the monitors and notebook cooler with Air Button on my desk!"
More IoT experience to come using the GPIO app! :)

[Casual hacking] GPIO 앱 프로젝트 2 : 초음파 센서 에어 버튼(Air button) 만들기!

 [Casual hacking] GPIO app PROJECT 2 : 초음파 센서 Air button 만들기! 


GPIO 앱을 이용한 두 번째 프로젝트!
초음파 센서를 이용한 에어 버튼(Air button) 만들기 입니다.

우선 초음파 센서는 UART라는 시리얼 통신을 이용하죠.
우선 사용한 초음파 센서 사양은 아래의 링크를 통해 확인 가능합니다!
(구입하신 전자제품 쇼핑몰에 대부분 데이타 시트 및 상세 정보 등이 있으니 참고하세요)

초음파센서 제품 가이드 : HG-C40U

자 그럼 기본적인 초음파 센서를 숙지했다고 가정하고 설명을 시작해볼게요~


1. 브레드보드 셋팅하기



그림처럼 TxD, RxD, GND, 5V 만을 설정해주었습니다.
또한 제대로 셋팅했는지 알기 위해 LED를 설치해놨습니다.


2. GPIO 앱에서 UART 설정하기

제품 가이드에 나와있던 것처럼 GPIO 앱 UI에서도 똑같이 설정해주면 됩니다!


  • Baud rate : 38,400 bps
  • Data bit : 8 bit
  • Stop bit : 1 bit
  • Buffer size : 100
    • 버퍼 사이즈는 한 번에 받을 글자 사이즈를 의미해요.
  • 값들을 모두 입력해주고  Set !
  • 그러면 'Read data'에 초음파 센서로부터 데이터가 넘어오게 됩니다.
  • /x32/x37/x03/x02/x5e/x31/x37/x32/x38/x03/x02/x5e.... 같은 데이터가 반복되게 됩니다. 여기서 /x03/x02/ 가 반복되고 유용한 초음파 거리 값은 그 바로 뒤 2번째에 나옵니다.
    나중에 이 데이터를 이용해서 버튼을 만들 수 있어요!
  • (단, 저희가 가지고 있는 HG-C40U 사양에 해당하는 내용이니, 여러분의 초음파 센서와 데이터가 다를 수 있습니다!)



자 그리고 초음파 센서가 제대로 설정됐는지 확인하기 위해 LED 핀도 설정을 함께 해줄게요!


3. 초음파 센서 테스트하기

아래의 두 가지 룰로 초음파 센서가 제대로 셋팅됐는지 확인해 보겠습니다!

이 두 가지 자동화 규칙으로 아래의 영상처럼 테스트를 해볼 수 있습니다.



우선 첫 번째 Rule 설정과정부터 확인해볼게요!

"초음파 거리가 10cm 이하가 되면, LED 가 켜져라"

- 첫 번째 룰 설정 .gif 로 보기!


<센서(sensor) 앱 설정 스텝>
1. GPIO app 선택  
2. UART serial 선택  
3. UART Read  
4. (녹색박스 체크)
5. 필터 선택 및 입력 : '+ Advanced' 클릭
 Test True : {{{{{{data!split("\x03\x02^")}}[1]!to_int}}!le(100)}}
(필터에 입력하는 값이 어렵죠..
/x03/x02 를 파싱해서 리스트의 2번째(=[1]) 데이터를 사용하는 겁니다. 위에서 말했듯이 그 값이 초음파 센서가 감지한 거리이기 때문이죠!
그리고 그 데이터를 숫자로 바꾼 후 le(less and equal) 100mm 이하거나 같다는 의미입니다. 직접 숫자를 바꿔서 테스트 해보세요!)


필터 값에 입력하는 코드를 자세히 알고, 직접 만들어보고 싶다면 아래의 링크를 참고해주세요!
'AMBLANG(엠비언시 언어) 자세히 알기'

<액츄에이터(actuator) 앱 설정 스텝>
1. GPIO app 선택  
2. Write Digital 선택  
3. GPIO pin$ 선택  
4. (녹색박스 체크), Set '1'(LED를 켜라)


이제 두 번째 Rule 설정과정을 볼게요.

"초음파 거리가 10cm 이상이 되면, LED가 꺼져라"

- 두 번째 룰 설정 .gif로 보기!


<센서(sensor) 앱 설정 스텝>
1. GPIO app 선택  
2. UART serial 선택  
3. UART Read  
4. (녹색박스 체크)
5. 필터 선택 및 입력 : '+ Advanced' 클릭
  Test True : {{{{{{data!split("\x03\x02^")}}[1]!to_int}}!ge(100)}}
(ge(greater and equal) 100mm 라는 의미입니다. 100mm보다 크거나 같거나가 되겠네요...)

<액츄에이터(actuator) 앱 설정 스텝>
1. GPIO app 선택  
2. Write Digital 선택  
3. GPIO pin$ 선택  
4. (녹색박스 체크), Set '0'(LED를 꺼라)


4. Air button 만들기!


자 이제 위의 테스트를 응용해서 에어 버튼(air button)을 만들어볼까요?
버튼의 용도는 Volumio 앱을 이용해서 'Play music', 'Stop music', 'Volume up', 'Volume down' 만들어보겠습니다!

자 우선 자로 에어 버튼을 만들기 위해 버튼의 위치를 만들어 볼게요!
... 제 책상에서 테스트 해봤어요 :)

# 버튼 설치




에어 버튼(air button) 위치

         ~ 10cm : volume up
11cm ~ 20cm : volume down
21cm ~ 30cm : play music
31cm ~ 40cm : stop music

# 자동화 룰 설정


첫 번째 룰 설정 방법만 gif 를 참고해보세요!


자 이렇게 해서 초음파(Ultrasonic wave)를 이용한 에어 버튼(air button)을 만들어봤습니다.

여러분은 다른 버튼을 만들어보세요!

초음파 거리를 이용해서 리모콘이 있던 제품, 리모콘이 없던 제품 또한 제어가 가능합니다!
"침대 옆에 에어 버튼(air button)을 만들어 전등을 껐다 켰다 하고 싶다"
"출근하고 에어 버튼(air button)을 누르면 모니터와 노트북 쿨러가 켜져라!"
GPIO  앱 프로젝트를 이용한 사물인터넷 체험은 계속됩니다! :)

2015. 2. 6.

[Ambiency guide] 엠비언시 센서 필터(Filters) & 액츄에이터 인풋(Input) 사용하기!

 [Advanced features] 엠비언시 센서 필터(Filters) & 액츄에이터 인풋(Input) 사용하기! 


센서 앱과 액츄에이터 앱을 연결하여 자동화 규칙을 생성하는 엠비언시(Ambiency).
이 엠비언시 앱을 멋지고 유용하게 사용하기 위해선 조금의 연습이 필요해요.

그리고 우리 생활에서 불필요한 것들을 자동화하여 편하게 만들 수 있는 것들은 얼마든지 있지만,
구체적으로 실현하기 위해서는 꼭 배워야할 기능이 있습니다.

바로 '센서 앱 필터(Filters)' & '액츄에이터 앱 인풋(Input)' 기능입니다!



What is filter?


data -> information


필터는 우리가 기존에 엑셀 시트에서 찾고 싶은 정보들을 거르기 위해 필터를 하는 것과 똑같은 개념으로 생각하시면 되요!
많은 정보들 중 나에게 필요한 정보만 걸러서, 그 정보를 가지고 자동화 규칙을 만드는 것입니다!


"나에게 메일이 오면, 내 책상의 스탠드가 깜빡여라!"

이 룰의 경우 나에게 메일이 오는 환경에 맞춰 스탠드의 상태가 변하는 액션이 정해졌네요.
하지만 문제가 있습니다!

나에게 오는 스팸메일부터 중요하지 않은 메일까지 모두 알림을 준다는거죠!
이럴 때 필터를 사용해서 중요한 메일만 반응하여 스탠드를 깜빡거리게 할 수 있습니다.

1. 필터 선택



2. 필요한 필터값 채우기

* '보내는 이(sender)'가 "taehyun" 이라는 이름을 포함할 때,
* '메일 본문(message)'에 "meeting' 이라는 단어를 포함할 때,
이 두 가지 경우를 모두 만족할 때만 알람을 주게 만들었습니다!


자 이렇게 해서 센서 앱에 필터를 넣음으로써 구체적인 상황을 만들어 줬습니다!

자 그렇다면 이제 액츄에이터 앱에 '인풋(Input)' 사용법을 알아볼까요?


What is Input?


Use information


인풋(Input)은 센서 앱에서 받은 정보들을 사용하기 위한 과정이라고 할 수 있습니다!
물론 센서 앱에서 필요한 정보들을 필터링하여 받고 나서 꼭 액츄에이터 앱에서 받을 필요는 없습니다.
받지 못하는 액츄에이터 앱도 있을 것이구요.
아래와 같은 상황에서는 필요하겠죠?
"내 방의 웹캠에 움직임이 감지되면, 나에게 메일로 시간과 사진을 찍어서 보내라"

위와 같은 룰의 경우 웹캠에 움직임이 감지되는 환경에 맞춰 웹캠이 사진을 찍어 메일로 보내라는 액션이 정해졌네요.

이 경우 조심해야되는 경우가 있습니다!
받고 싶은 정보는 우선 센서 앱에서 걸러져서 오기 때문에, 센서의 Trigger에 따라 액츄에이터로 넘어오는 값이 달라질 수 있는 것이죠!

ex) Trigger : motion detected vs snapshot available

위와 같이 Trigger에 따라 사용할 수 있는 액츄에이터 input 정보가 다르네요!
그럼 하나씩 해보겠습니다.

1. 인풋 선택
녹색 체크박스를 체크하면 아래와 같이 액츄에이터 인풋(Actuator Input) 화면이 나옵니다.


2. 필요한 인풋 채우기

* 받는 이(Receivers)를 woojin@narantech.com 으로 설정
* 메일 제목(Subject)에 "Warning! motion detected!!"를 입력
* 첨부 파일(File)에 감지된 사물의 이미지를 첨부
* 첨푸 파일명(File Name)에 "my room.png" 를 입력
이렇게 해서 센서 앱으로부터 나온 정보들을 액츄에이터 인풋 값으로 입력해봤습니다.

결과를 한번 볼까요?


네 이렇게 해서 원하는 정보들을 활용하여 룰을 완성해봤습니다.
이렇게 조금만 신경을 쓴다면 자신에게 맞는 정말 유용한 자동화 룰을 만들 수 있습니다.

이렇게 만들어진 유용한 룰을 다른 사람들과도 공유해 보세요!
공유 방법은 아래의 포스팅에 나와있습니다! 참고하세요 :)
[Share rules] Getting started - how to share rules


물론 조금만 신경을 쓰는 것조차 귀찮으신 분들은 아래의 이미지를 공유할 수 있습니다!
(아래의 이미지를 다운 받거나, drag&drop 해보세요!)