본문 바로가기

Coding Diary/C,C++,C#

Smart Farm(스마트 팜) 중간 점검

요즘 c# 코딩이 점점 재밌어진다...

 

처음 카티아를 만난 그날 같은....

 

/////////////////////////본론/////////////////////////////

 

예전부터 아버지가 농사를 시작하시고 나서부터는 자동화시키면 좋을 듯한 것들을

 

항상 마음에 두고 있었는데 이 기회에 하게 됐다..(솔직히 기분 너무 좋음)

 

이번 프로젝트는 MCU와 같이 RS232통신을 해봄과 농사에 관련 되있음에 깊~~~~은 뜻이 있다./

 

먼저 프로토콜부터 시작해보자

 

Protocol

그 두 상대방간 합의된 약속...... 솔직히 프로토콜의 의미를 찾아보곤 처음에는 이해하기 어려웠지만

직접 해보면 또 바로 이해되니까

 

먼저 서버와의 통신을 위해 프로토콜을 정하기로 했다..

 

차마 못 보여주는 내 심정을 이해 해주시길,,,,,

 

내가 서버를 통해서 받을 값과 어떠한 상황일 때 보내 줄 것인지를 사전에 약속을 하고 키워드를 정했다...

 

(이게하면서 느낀 건데... 왜 프로토콜이 중요한 지 알거 같다... 

 

클라이언트에서 보내는 프로토콜을 알면... 정보를 가로챌 수 있다..)

 

다음 단계

 

Pseudo Code

지금까지 프로젝트를 하면서 항상 순서도와 슈도코드 작성을 해왔다....

 

이 작업을 나는 기계 쪽에서는 그리고자 하는 모델의 크기를 미리 정해놓고

 

가변 값들을 정해 놓고 작업하는 거랑 비슷해서 나름 어렵지 않았다(그냥 나 잘났다고 얘기 중~~)

 

슈도코드의 내용은 대략 아래와 같다

 

Smart Farm

Client
must have 2 forms
one for choosing item(vegitable)
other for logging and ..average`s graph

when it is loaded the client and server has already connected 
after it has connected through the selection of user the whole settings come upon from the server
we have 3 items -cucumber, pepper, tomato -

b4 we have done the timers will b instead of real    time


class VEGETABLE
{	
      3parts value:

from the MCU
from the Server
to Server & MCU

}

through the word that Client send the Msg, Server`s sending information will confirm
cucumber_click => “cucumber”
pepper_click => “pepper”
tomato_click => “tomato”

In every hour => “현재온도 : {0}, 현재습도 : {0}, 현재조도 : {0}, 현재토질 : {0}

UI list
vegetable(selected)`s picture
current Temperature & range for vegetable
current Humidity & range for vegetable
current illuminance & range for vegetable
current Earth & range for vegetable
4 buttons
vegetable`s characteristic

here is 4 buttons:
발아 적온 click =>”seed”
생육 적온 click =>”breed”
개화 적온 click =>”flower’
발육 적온 =>”fruit”
button_click => get the information from the Server
according to the  button click range of each values` confirm
(these buttons are controlled by user)

button_click => get the information from the Server


////////////////////////////////////////////////////////////////////////////////////////////////////////////

from the MCU
every minutes
lux = values //조도센서
tem = values //온도센서
hum = values //습도 센서
FW = 1, 0 //화재경보 센서
according to the protocol(file that attached)
	
STem=MTem //take the value from the MCU and send to Server
SHum=MHum //take the value from the MCU and send to Server
SLux=MLux //take the value from the MCU and send to Server
SWat=MWat //take the value from the MCU and send to Server

 

그냥 매시간 마다 현재 온도 습도 조도 토수분량을 서버로 보내 서버에서 저장하도록 하고

 

MCU에서는 각 센서에서 값을 받아와 클라이언트로 전송한다. 

 

그리고 서버로 받은 정보 중 필요한 값을 MCU에 값을 전송하여 직접 각 기기들을

 

컨트롤 할 수 있게 한다...

 

여기까지가 앞부분의 내용이다

 

다음 내용은 다음 시간에....

 

UI작도와 값 설정을 알아보자