CN106940577A - A kind of Greenhouse Monitoring system based on Android platform - Google Patents

A kind of Greenhouse Monitoring system based on Android platform Download PDF

Info

Publication number
CN106940577A
CN106940577A CN201710280129.6A CN201710280129A CN106940577A CN 106940577 A CN106940577 A CN 106940577A CN 201710280129 A CN201710280129 A CN 201710280129A CN 106940577 A CN106940577 A CN 106940577A
Authority
CN
China
Prior art keywords
short message
greenhouse
slave computer
mobile phone
chip microcomputer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710280129.6A
Other languages
Chinese (zh)
Inventor
龙建明
熊刚
胡启迪
牛甲
党灵杰
王佳伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yangling Vocational and Technical College
Original Assignee
Yangling Vocational and Technical College
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yangling Vocational and Technical College filed Critical Yangling Vocational and Technical College
Priority to CN201710280129.6A priority Critical patent/CN106940577A/en
Publication of CN106940577A publication Critical patent/CN106940577A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05DSYSTEMS FOR CONTROLLING OR REGULATING NON-ELECTRIC VARIABLES
    • G05D27/00Simultaneous control of variables covered by two or more of main groups G05D1/00 - G05D25/00
    • G05D27/02Simultaneous control of variables covered by two or more of main groups G05D1/00 - G05D25/00 characterised by the use of electric means

Abstract

The invention discloses a kind of Greenhouse Monitoring system based on Android platform, host computer is the smart mobile phone of compatible GSM network, 4.1.2 versions based on Android operation system write mobile phone application software with JAVA language design, the software is set up by gsm module with slave computer and is connected, carried out data transmission in the form of SMS short messages, for receiving the information of slave computer transmission, and greenhouse environment information is shown on mobile phone, parameter bound can be set in mobile phone and directly control performs equipment;Slave computer gathers the ambient parameter at greenhouse scene by measuring apparatus, then after single-chip microcomputer is analyzed and is handled, is shown on Liquid Crystal Module;Enter line overrun judgement to default ambient parameter, and automatically control execution equipment and the state of transfiniting is adjusted, user is notified in time.The present invention improves the regional greenhouse observation and control technologies of Yang Ling, reduces production cost and person works' intensity, improves the level of production.

Description

A kind of Greenhouse Monitoring system based on Android platform
Technical field
The present invention relates to agriculture field, and in particular to a kind of Greenhouse Monitoring system based on Android platform.
Background technology
With the development and application of the science and technology such as automatic technology, computer technology, communication technology, and agriculture project Technology is continued to develop, and radio network technique is gradually applied in agricultural production.Since the new century, China scientific research personnel and Experts and scholars are on the basis of the introduction of foreign advaced technology, by long-term effort, in the light of greenhouse, heat, wet, gas, fertilizer Etc. many research work are carried out in terms of key element regulation and control, application technology, Based Intelligent Control, while installing heater additional in inside greenhouse Structure, irrigation mechanism, controlling organization, fertilizing mechanism, ventilating mechanisms etc. perform equipment, have gradually formed greenhouse with Chinese characteristics Industrial system, achieves objective achievement.Local governments at various levels using greenhouse engineering as developing modern agriculture point of penetration, one after another Agricultural modernization Demonstration Garden is established, the development of China's industrialized agriculture is greatly promoted.
Yangling Agricultural Hi-tech Industry Demo Zone, is the unique agriculture high and new technology industrial development zone being included in hi-tech development zones sequence, Occupy critical role in National agricultural development.The agricultural development of Yang Ling district facilities is rapid, industrialized agriculture warmhouse booth fruits and vegetables Significantly, the plantation enthusiasm of peasant is very high, and greenhouse gardening area expands rapidly, at the same time also produces new ask for planting benefit Topic.
For the service condition of industrialized agriculture monitoring system, on-site inspection, Da Zhai have been carried out in Yangling Area Da Zhai town 15688 mu of town cultivated area, including Meng Zhai, western gurry, Zhai Xi villages, East Village Deng13Ge villages of stockaded village, 16734 people, since 2009 Since developing industrialized agriculture, land bank of Liao10Ge villages is set up, circulate 11000 mu of soil, wherein circulate into 2723 mu of cooperative society, Industrialized agriculture greenhouse 1483 is built, 2244.5 mu, middle 222, canopy, sets up cooperative society 31, including demonstration society 13 by 478.7 mu It is individual, including 1 Kiwi berry cooperative society and 12 fruits and vegetables cooperative societies, natural 418, the canopy of wherein 12 fruits and vegetables cooperative societies of investigation, standard 692, canopy, wherein, the Nong Xin fruits and vegetables cooperative society in Zhai Xi villages has the quasi- canopy of 137 coordinates, Lao Qin people fruits and vegetables people cooperative society to have 94 coordinates accurate Canopy, ranks among the best.Using the two cooperative societies as emphasis respondent, investigation industrialized agriculture greenhouse-environment monitoring means and equipment, Industrialized agriculture greenhouse-environment monitoring in Da Zhai town partly uses electronics Hygrothermograph, few mainly using based on simple Hygrothermograph Using intelligent environment monitoring system, it is that artificial control shutter is realized that environment regulation is then mostly.
Beijing, which is then used, using the peasant household of intelligent environment monitoring system sends to obtain the production of great achievement development in science and technology Co., Ltd Greenhouse intellectual monitoring modulator, the modulator can monitor warmhouse booth humiture, light in real time by government-funded construction The information such as illumination, air dew point, user can realize the unattended of greenhouse, using more convenient by mobile phones enquiring.The tune Device and sensor etc. are controlled, only 3 measuring nodes, unit price is expensive more than 10,000 yuan, it is not strong that wish is installed by peasant household.
Found by on-site inspection, the Yang Ling agriculture practitioner of most facilities still uses traditional thermometer, humidity Meter realizes heating, cooling, humidification, dehumidifying and ventilation to control to gather the epidemic disaster value in greenhouse by manual adjustment mode Ambient parameter processed.The production model of such low mechanization has that low monitoring accuracy, high cost, labor intensity are big, it is cumbersome to regulate and control, The drawbacks such as inefficiency, reduction peasant automates industrialized agriculture, information-based enthusiasm, so as to influence the economic effect of peasant Benefit.
The content of the invention
To solve the above problems, the invention provides a kind of Greenhouse Monitoring system based on Android platform.
To achieve the above object, the technical scheme taken of the present invention is:
Greenhouse Monitoring system based on Android platform, including slave computer and host computer, the host computer are compatibility GSM The smart mobile phone of network, the 4.1.2 versions based on Android operation system write mobile phone application software with JAVA language design, The software is set up by gsm module with slave computer and is connected, and is carried out data transmission in the form of SMS short messages, for receiving bottom The information that machine is sent, and greenhouse environment information is shown on mobile phone, at the same can also by mobile phone arrange parameter bound and Directly control performs equipment;Slave computer is sensed using single-chip microcomputer as control core by temperature sensor, humidity sensor, illumination The ambient parameter at the measuring apparatus such as device collection greenhouse scene, then after single-chip microcomputer is analyzed and is handled, shown on Liquid Crystal Module Out;Single-chip microcomputer enters line overrun judgement to default ambient parameter simultaneously, and automatically controls execution equipment to state progress of transfiniting Regulation, sends sound and light alarm, SMS alarm, user is notified in time.
The SMS short messages set it to Text modes using English short message.
The system is divided into manually and automatically controlled two parts, is broken down or staff automatically controlling part When rule of thumb judging that greenhouse needs regulation, be switched to manual mode, manually opened sprinkling irrigation, drip irrigation, ventilation, light filling plus Heat etc. performs equipment.
The invention has the advantages that:
It can realize and the ambient parameters such as greenhouse temperature, humidity, illumination are detected, controlled and alarmed, to improving Yang Ling Regional greenhouse observation and control technology, reduction production cost and person works' intensity, the raising level of production are significant.
Brief description of the drawings
Fig. 1 is the system block diagram of the embodiment of the present invention.
Fig. 2 is the system hardware block diagram of the embodiment of the present invention
Fig. 3 is power circuit design drawing in the embodiment of the present invention
Fig. 4 is TC35i hardware circuit schematic diagrames in the embodiment of the present invention.
Fig. 5 is TC35i modules and interface microcontroller circuit diagram in the embodiment of the present invention.
Fig. 6 is embodiment of the present invention repeat circuit and interface microcontroller circuit diagram.
Fig. 7 is embodiment of the present invention medium temperature chamber environmental monitoring system main program flow chart.
Fig. 8 is the initialization subroutine flow chart of gsm module in the embodiment of the present invention
Fig. 9 is aerial temperature and humidity data acquisition routines flow chart in the embodiment of the present invention
Figure 10 is phone processing subroutine flow chart in the embodiment of the present invention.
Figure 11 is slave computer short message processing subroutine flow chart in the embodiment of the present invention.
Figure 12 is phone pairing subroutine flow chart in the embodiment of the present invention.
Figure 13 is bound setting subroutine flow chart in the embodiment of the present invention.
Figure 14 is short message control relay subroutine flow in the embodiment of the present invention.
Figure 15 is transmission APP data SMS subroutine flow charts in the embodiment of the present invention.
Figure 16 is embodiment of the present invention repeat circuit control mode switching subroutine flow chart.
Figure 17 is the judgement subroutine flow chart that transfinited in the embodiment of the present invention.
Figure 18 is serial ports interrupt service subroutine flow chart in the embodiment of the present invention.
Embodiment
In order that objects and advantages of the present invention are more clearly understood, the present invention is carried out with reference to embodiments further Describe in detail.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not used to limit this hair It is bright.
As shown in figure 1, the embodiments of the invention provide a kind of Greenhouse Monitoring system based on Android platform, including under Position machine and host computer, the host computer are the smart mobile phone of compatible GSM network, the 4.1.2 versions based on Android operation system Mobile phone application software is write with JAVA language design, the software is set up by gsm module with slave computer and is connected, with SMS short messages Form carry out data transmission, greenhouse environment information and is shown on mobile phone, simultaneously by the information for receiving slave computer transmission It can also control to perform equipment by mobile phone arrange parameter bound and directly;Slave computer passes through using single-chip microcomputer as control core The ambient parameter at the measuring apparatus such as temperature sensor, humidity sensor, optical sensor collection greenhouse scene, then by single-chip microcomputer After analysis and processing, shown on Liquid Crystal Module;Single-chip microcomputer enters line overrun judgement to default ambient parameter simultaneously, and certainly Dynamic control performs equipment and the state of transfiniting is adjusted, and sends sound and light alarm, SMS alarm, user is notified in time.The SMS is short Message sets it to Text modes using English short message.
According to system architecture, this control system has two kinds of mode of operations, i.e., manual and automatic two parts pass through conversion The artificial conversion of switch, particular hardware structured flowchart is as shown in Figure 2.
During manual mode operation, part power-off is automatically controlled, staff carries out hand according to crop demand and artificial experience Dynamic control, manual mode includes mode conversion switch, operation button, equipment indicating lamp and related auxiliary element;
When automatic control mode works, manual control part power-off, single-chip microcomputer is run according to the parameter set, the part It is divided into host computer and slave computer, the next machine monitoring greenhouse, overload alarm, receives the functions such as host computer instruction, including micro-control Device module processed, power module, soil moisture detection module, ambient temperature and humidity detection module, soil moisture detection module, illumination are strong Spend detection module, LCD MODULE etc..
The system main control chip uses a kind of high-performance of macrocrystalline company production, the single-chip microcomputer STC89C52 of low-power consumption;Temperature Room plastic shed soil temperature sensor uses the DS18B20 that DALLAS companies of the U.S. produce, and soil humidity sensor, which is used, has DO The sensor of output, can control the humidity of soil with wide scope, and by potentiometer regulation control respective thresholds, humidity is less than setting During value, DO output high level, during higher than setting value, DO output low levels;Directly it is connected when using with single-chip processor i/o mouthful;Air Temperature Humidity Sensor selects DH11 type digital temperature-humidity sensors;Optical sensor uses the illumination sensing exported with DO Device, using sheet type photo resistance, low and high level is exported when light changes, operating voltage 3.3V-5V can with adjustable potentiometer Regulation detection light luminance, is directly connected when using with single-chip processor i/o mouthful;This control system is used with Chinese word library 128X64 type LCD LCD screens, the screen has 128*64 dot matrix, and gsm communication module is directly using the 12V power supplys carried, monolithic Machine system uses the 5V power supplys of designed, designed, as shown in Figure 3.
Host computer uses the TC35i type gsm modules that Siemens Company produces with slave computer communication module.Module transmitting electricity Flow for 300mA (average), peak point current 2.5A;The SMS of Text and PDU forms is supported, can be real by AT orders or cut-off signals Now restart and fault recovery, the message sending function of the system can be met completely.TC35i hardware circuit schematic diagrames are as shown in Figure 4.
TC35i module performances are stable, reliable operation, when using by MAX232 and the serial ports of single-chip microcomputer connect, circuit Figure is as shown in Figure 5.
Select Omron main officer of Tibet UN photoelectrical couplers G3MB-202P that slave computer is carried out into electrical isolation with performing equipment, with list The connection circuit of piece machine is as shown in Figure 6.
Slave computer software system part slave computer selects 51 kernel single-chip microcomputers as hardware platform, is designed using C language, A welcome interface can be shown by having at the beginning, and the interface is shown using 12864 type LCD displays, can be entered in this period The operation of the system initialization of some non-display classes of row, next just enters major cycle part,
The total duration that slave computer completes a major cycle is about 3 seconds, and wherein the total duration of blind area is no more than 0.5 second, is surpassed Limit judges that subprogram is arranged in the rearmost position of major cycle.
The initialization subroutine of gsm module (Siemens TC351) as shown in figure 8, including
Query portion is mainly the connection status and current netted condition of inquiry gsm module, is worked respectively in module initialization Beginning and ending at.The connection status of enquiry module be single-chip microcomputer by send instruction " AT r n " realize, if connection Normally, gsm module can return to " OK ", and now program can carry out next step operation, otherwise play " EEROR ", and now program can be weighed Instruction is sent in recurrence until successful connection.The connection status of enquiry module is single-chip microcomputer by sending instruction " AT+CRGER n " come Realize, now gsm module can return to current log-on message, if in information comprising be successfully registered to network (including roaming shape State), then the initialization subroutine terminates, and otherwise program can repeat to send instruction until network registry success.During inquiry As a result can be reflected on 12864, when program for a long time fail by when, can according to prompt message check hardware connection.
Setting unit, including:
(1) advice method during short message arrival is set.Single-chip microcomputer by send instruction " AT+CNMI=2,1 r n " will be short The advice method that letter arrives is set as sending when serial ports is idle.
(2) gsm module is set to close echo function, the instruction that single-chip microcomputer is sent can be returned to single-chip microcomputer by the function to be used for Confirm whether instruction is correct, need not typically use.
(3) gsm module is set to open caller identification, the function can send caller ID when phone arrives to single-chip microcomputer, There is phone to match mechanism in the design, it is therefore necessary to open the function.
Ambient temperature and humidity detects subroutine flow chart, as shown in figure 9, the main points in DHT11 control process are as follows:
(1) first have to its at least 18ms low level of No. 2 pins one and then draw high 20-40us and start the sensor.
(2) if normal, DHT11 can return to 80us response signal, and expression has begun to gathered data.
(3) then DHT11 can draw high level, represent to have begun to transmit data when undercuting again.
(4) then DHT11 can represent a data 0 with a high level for continuing 26-28us, continue 70us high level Represent a data 1.
(5) single-chip microcomputer judges according to often and stores the data.
(6) DHT11 has 5 byte datas of transmission altogether, and first character section is humidity integer part, and second byte is humidity Fractional part, the 3rd byte is temperature integer part, and the 4th byte is temperature fractional part, and the 5th byte is check number According to, if preceding four bytes and represent that data are correct if equal to the 5th byte.
In the design, host computer is called to slave computer will realize two kinds of functions, be unblock short message telephone report respectively Alert function and the current greenhouse state of inquiry.Realize which kind of function whether be locked depending on warning function, when dialing Slave computer triggered alarm and successfully being sent to host computer and is called alarming short message before phone, and host computer is to bottom The phone that machine is dialed can immediately be hung up and be recovered short message telephone warning function, if not such a situation, slave computer can hung up The short message for including greenhouse current state information is sent after phone to host computer.
Must first go through before Single-chip Controlling gsm module sends short message transmission instruction " AT+CMGF=X r n " refer to Determine the transmission form of short message.Wherein X represents TEXT forms for 1, is 0 to represent PDU forms.
The process that Single-chip Controlling gsm module sends short message can be analyzed to 3 steps, and single-chip microcomputer first is sent out to gsm module Send destination number, the instruction being directed to for " AT+CMGS=" xxxxxxxxxxx " r n ", wherein x represent be target phone Number;Then single-chip microcomputer detect gsm module return character '>' after to gsm module send short message content, need exist for note Meaning, total character length of short message content is 140, and the step operating time is unsuitable long, and otherwise gsm module can be returned " EEROR " represents time-out;Last single-chip microcomputer sends 16 binary data 0x1A to gsm module, represents that short message writes end, now its Remaining transmission work is voluntarily completed by gsm module, and "+CMGS " can be returned after success and total number for sending short message quantity is represented According to, therefore need to detect the pass signal after end mark has been sent and complete the reset work of data buffer zone and correlated variables Make.The subprogram for sending different content short message is write for convenience, code redundancy is reduced, in programming by the first step and the Three steps are both designed as subprogram.Greenhouse environment information short message only can be to the transmission of the number of pairing, if also, number called Code non-present is with checking numbers, and slave computer will not carry out the operation of short message sending after short message is hung up, while can be pointed out on 12864 The number is illegal information.Specific procedure flow chart is as shown in Figure 10.
In the system designed by this paper, short message is that user realizes the Main Means controlled slave computer, the subprogram As shown in figure 11, its major function is exactly the content for parsing short message to flow.
System slave computer calls the trigger condition of the subprogram to receive character string "+CMTI " for microcontroller serial port, the word Symbol string is sent once only when gsm module receives a new short message to single-chip microcomputer.In other words, when microcontroller serial port connects Prove that be possible to user have sent control information to slave computer when receiving the character string;The subprogram first can short message reading it is interior Hold, the process be sent from single-chip microcomputer to gsm module " AT+CMGR=X r n " instructions realize.It may be mentioned here that, Serial ports is the unique passage that data are transmitted between gsm module and single-chip microcomputer in the design, all instruction, return information and The data such as short message content are required to by Serial Port Transmission;If short message is read successfully, gsm module can return to one to single-chip microcomputer “OK”.In serial ports interruption subroutine, reading manner has been set, it is ensured that short message content and confirmation can be read solid In fixed internal buffer, the buffering area is used exclusively for receiving gsm module data, and is all of gsm module transmission The common area of data, therefore, after short message has been read, in order to protect the short message content read to be not modified, it is necessary to temporarily When close interrupt to stop receiving data, after corresponding operating has been performed according to short message content again recover reception.Here will be unslow The reason for data for rushing area are shifted has at 2 points, one is the available ram space of single-chip microcomputer inner high speed is extremely limited;Secondly It is that effective short message is to notify that single-chip microcomputer completes the custom instruction of certain operation, it is necessary to single-chip microcomputer is immediately performed nothing but, performs The meaning just not existed afterwards is, it is necessary to which deletion at once, in order to avoid influenceing operation below, therefore need not be preserved for a long time.If Short message reads failure, then system can provide prompt message and retain this short message, waits user's processing.
Short message just calls corresponding subprogram to be handled after reading successfully according to short message content.In the design, control The format setting for instructing short message is TEXT English modes, and the first letter of short message is used for the operation of execution needed for identifying, afterwards For the data required for the operation.The system slave computer is responsible for that following five kinds of operations will be completed according to short message content, as follows respectively:
(1) phone matching operation:The operation is used for changing phone number for control system, is only one with numeral The instruction that character is taken the lead, because correct phone number must take the lead for 1, and conventional short message is generally to use Numeral is as beginning, therefore the instruction is designed as simple telephone number.
(2) bound sets operation:The operation is used for initialization system and judges that greenhouse environment parameter is in the threshold of normal range (NR) Value, therefore take English word Limit initial L as the initial of the instruction, it is the data needed for given threshold afterwards.
(3) Control is operated:The operation is used for the on off state of each relay of remote control, therefore takes English word Relay initial R, as the initial of the instruction, is the data of each relay status needed for identifying afterwards.
(4) APP data manipulations are sent:The operation is used for sending the specified format comprising greenhouse environment information to host computer Short message, host computer parses the short message by APP softwares and includes the result of parsing on APP software interfaces, therefore takes English Literary word Send initial S, as the instruction, can be the telephone number of empty or target afterwards.
(5) relay control mode handover operation:Slave computer inherently possesses automatic according to greenhouse environment parameter information The on off state of the related relay of control, can mutually be rushed under conditions of allowing slave computer to automatically control with the control operation of user It is prominent, thus user's control automatically control two ways with slave computer can not be while using.The operation is exactly for switching system pair The control mode of relay, therefore it is to use as the initial of the instruction, afterwards to take English word Control initial C To represent the data for the control mode that user needs.
If the short message content initial read not more than one of five kinds, system judges the short message as invalid short message, Point out user's messaging format illegal.Success short message reading and perform just delete the short message after corresponding operating after return to main flow.
Phone is used for the operation for being responsible for completing phone pairing with subroutine, and the only number by pairing is sent to system Short message is called and can complete default function.The process of phone pairing is as shown in figure 12.System slave computer is called The trigger condition of the subprogram is successfully that the initial character that short message content is judged after short message reading is character ' 1 ', the short message it is interior Appearance is needed to be stored among slave computer until next update, therefore number is stored to special array work as first by the subprogram In.In view of the data simply short message, phone arrive when be compared, and to host computer send short message, call when Use, frequency of use is not very high, in order to optimize the operational efficiency of SCM program, the array is carried out in programming Idata identify, such compiler compiling when can give priority in arranging for other variables inside single-chip microcomputer reading efficiency highest 00H~ In 7FH spaces, and internal RAM usage quantity when more than 127 (storehouse at least needs a byte) can normal compilation lead to Cross.It should be noted that the operation is only more than the single-chip microcomputer of the respective model of 128 bytes effectively to internal RAM quantity, such as STC89C52RC, the otherwise simply addressing system of change data, on the contrary efficiency is reduced, while 127 bytes can not be abolished Limitation.
Complete just to recover serial ports receive capabilities after number storage and delete short message.It is by single-chip microcomputer to delete short message operation Send to gsm module " AT+CMGD=x r n " and realize, what wherein x was represented is the groove position where short message to be deleted, operation Success after gsm module can return string " OK ", otherwise can return string " EEROR ", therefore delete short message before must first Open serial ports and receive interruption to guarantee to read the information that gsm module is returned, so as to carry out appropriate processing.
Afterwards just to the number call phone matched just now for testing whether successful matching, it is to pass through to call operation Single-chip microcomputer sends " ATDxxxxxxxxxxx to gsm module;R n " and realize, wherein x represent be destination number, the phone Automatically hung up after being set in lasting 10 seconds.It is noted here that following 2 points, first, in dialing command ';' easy quilt Ignore and cause mistake;Second, called mobile phone preferably waits slave computer to automatically hang up phone, because working as in actual test process In, the phone that the gsm modules of Siemens's TC35 models is dialed out has the very big vacation for being likely to occur a period of time after being hung up Death situation state, during which normally can not call and return normal data (in most cases returning to EEROR).
After by matching call test, the number can be shown on 12864 for a period of time, display operation can be later Repeated by button.The system does not extend through the reason for message search currently matches number function, according to above Mention, the number only matched can allow system normally to realize desired function, so if forget number, can only be under Confirmed or reset system (system is prefixed a default number in code) near the machine of position, the later stage will further be realized This function.
Related one data buffer zone of data sharing of gsm module is previously noted, therefore serial ports must be being resetted finally Main flow is returned to after data buffer zone and correlated variables, to ensure that operation below can be performed normally.
It is as shown in figure 13 that the bound of system medium temperature chamber environmental variance normal value sets process.System slave computer calls the sub- journey The trigger condition of sequence is successfully that the initial character that short message content is judged after short message reading is character ' L ', and short message one is matched with phone Sample, the short message content needs also exist for being stored among slave computer until next update, therefore is also required to special array and is deposited Storage, the array is divided into Up_Limit and Down_Limit, and length is 6 bytes, each two byte one environmental variance of correspondence A limits value.Its frequency of use is relatively fixed, and only needs to read once among each major cycle, therefore before the array Equally plus idate marks.
In the present system, 5 environmental variances are related to altogether, are respectively:Air themperature, air humidity, intensity of illumination, soil The saturation degree of temperature and soil moisture.Wherein intensity of illumination and soil moisture saturation degree are realized with peripheral circuit is crossed The setting of threshold value, what single-chip microcomputer was read is the switching value after being handled through peripheral circuit, therefore the two variables need not be existed Single-chip microcomputer inner setting bound.Wherein represent that current light intensity is weak when being responsible for the circuit output 1 of intensity of illumination, output 0 When represent that current light is sufficient;It is responsible for representing rich water in soil during the circuit output 0 of soil percent saturation, is represented during output 1 Water shortage in soil.
The bound of other three variables is in array according to air themperature, air humidity, the order row of the soil moisture Row.The upper lower limit value of short message sending is character type, generally needs to be converted into corresponding numerical value, but in a program There is LCD12864 to show the program of current context information, show, in this procedure change each environmental variance for convenience For corresponding character, according to the rules of arrangement of ASCII character, be present same magnitude relationship in numeral character corresponding with its, that is, exist Among internal memory, numerically, numeral 2 to 1 is big by 1, and corresponding character ' 2 ' is also bigger than character ' 1 ' by 1, therefore, in order to improve system operation Efficiency, can directly be contrasted with character, same result can be obtained in magnitude relationship.
Update after bound data, then shown that the data are confirmed on LCD, the function again may be by button Repeat, then delete short message after serial ports interruption is opened.It is last to be returned after serial data buffering area and correlated variables is resetted Return main flow.
Short message Control subprogram is used for handling remote control relay task, and its program circuit is as shown in figure 14. Design 5 environment adjusting devices altogether in the design, 5 relays of correspondence can be sprayed when ambient parameter transfinites, dripped Filling, heating, ventilation, light filling, adjust greenhouse environment parameter.
The function is realized for convenience, and the control end of all relays is continuously arranged in single-chip microcomputer in hardware design On same group of I/O port, thus, in programming, just can be very easily same by carrying out displacement operation to a char types data When control all relays.System slave computer calls the trigger condition of the subprogram to be successfully after short message reading, judges short message The initial character of content is character ' R '.In short-message instruction design, its data division is corresponding in turn to after arriving first is connected to single-chip microcomputer The relay of digit from high to low on I/O port, character ' 1 ' represents to open its corresponding relay, the expression closing correspondence of character ' 0 ' Relay.
What the character variable for being responsible for control relay can choose whether to be defined on single-chip microcomputer internal RAM can bit addressable locations. If it is, program function is to be assigned to phase after directly the switching information of relay is set by bit manipulation by short message content I/O port is closed, which needs in advance to be defined each in variable, and is carried out in the related position of program to which is The judgement operation of one, benefit is exactly to be easier to judge when writing program, and reduce the chance of error, the later stage has read to compare appearance Easily.If it is not, then being realized using displacement operation is carried out to variable, program is since the data bit of first short message content data Parsing, when being determined as character ' 1 ', by the minimum clearing of variable, otherwise puts 1, rear to carry out moving to left a bit manipulation, so circulation, Until parsing complete strips short message, this method code amount is relatively small, but needs the length of short-message instruction data division strict Also easily each relay institute attached device is obscured in the quantity of correspondence relay, programming process, the later stage reads relatively to be stranded It is difficult.Code efficiency is paid the utmost attention in the design, therefore takes latter approach.Complete after Control, recover serial ports and connect Receive, main flow is returned after deleting short message and resetting serial data buffering area and correlated variables.
APP data SMSs subprogram is sent to complete to send comprising data needed for APP renewal displays to host computer for sequence Short message, it is successfully after short message reading by the trigger condition that system slave computer is called, and the initial character for judging short message content is word Accord with ' S '.
Data division behind the short-message instruction can send number of target mobile phones for empty or APP data SMSs Code, in the design, gsm module regulation is only to having matched sending short message by mobile phone;Relevant Single-chip Controlling gsm module sends short message Process refer to X.1.3 in the part of current greenhouse environment information is sent to user, it differs only in short message content part. The target of the former transmission information is people, and the latter is host computer APP, therefore the latter only needs to consider that the information included in short message is In terms of no complete, organizational form is if appropriate for parsing, without the reading habit for considering user.
In the design, the environmental data information for APP that slave computer is sent to host computer has two kinds, and one kind is to work as to use Householder moves what is sent when carrying out inquiry current context information by APP, and another is when the next machine testing is abnormal to ambient parameter When send, in order to make a distinction, former short message is added character string " APP " at beginning and is identified, and latter is then added Character string " Warning!" be identified, facilitate host computer targetedly to handle note data part.User is actively The flow of short message is sent during inquiry, the flow difference that slave computer sends short message during with exception is that centre have invoked sense signals journey Sequence.When sensor subroutine is designed, it with the addition of and converted data to character type and exist among special array Code.Therefore, required data had been obtained in main flow when finding environmental abnormality, it is not necessary to which related sensor is called in repetition Subprogram.
Note data part is by according to air themperature, air humidity, the soil moisture, soil percent saturation and intensity of illumination Real data composition, and according to this order arranged.It should be noted that in order that host computer can be parsed correctly, Between each data specific character must be used to separate, the character can be any one ASCII character character, be kept away in selection Exempt from overlapping with significant character, and ensure that all separating characters are identical.In the design, selection is space as this point Every character.Complete after the short breath transmission of APP data, recover serial ports and receive, deleting short message and resetting serial data buffering area and phase Main flow is returned after closing variable.
The flow of relay control mode switching is as shown in figure 16, the trigger condition that the subprogram is called by system slave computer After success short message reading, the first character for detecting short message content is character ' C '.The data division character of short message content ' 1 ' represents system relay control being set as manual mode, alternatively referred to as captures control, character ' 0 ' represent by system after Electrical equipment control is set as automated manner, alternatively referred to as abandons control.
The specific implementation of the handoff functionality is realized by setting the value of specific indexed variable inside single-chip microcomputer , the actual work of subprogram is exactly that the variable is put into 1 or clear 0 according to the content of instruction note data part.Become in the design Measure clear 0 and represent automated manner, variable puts 1 and represents manual mode.The indexed variable can be used in single-chip microcomputer internal RAM can position seek Bit variable in the area of location, can also be directly using the unsigned char type variables of a byte.If using the former, to note Meaning can in bit addressable locations all positions can be addressed in the way of byte, program is in the process of running there is a possibility that bit variable Value is rewritten by other byte type variables, therefore in variable-definition it is important to note that being commonly used in single-chip microcomputer internal RAM resource Very nervous situation.All significant variables use unsigned char type variables in the design.
Because the selection of control mode has conclusive influence to whole system function, therefore, it is necessary to design a school Test mechanism.That is, slave computer must return to current control mode to reach confirmation after operation has been performed to host computer Purpose.What the return was realized again by short message, and the content of short message is not that the instruction sent by host computer is short Believe that content is determined, but determined by the value of relay control mode indexed variable, so may insure that what host computer received returns The content for returning short message is consistent with the control mode that slave computer is actual.When indexed variable is set as automatic, slave computer transmission content For " AT " short message to host computer, when indexed variable is set as manual, slave computer transmission content for " MT " short message to upper Machine.If host computer fails to successfully receive the return short message, need to resend instruction short message or carry out live confirmation.
After control mode switching success, it can show that currently selected control mode carries out live confirmation on LCD, should Function can repeat to realize by button.Final system slave computer can delete short message in the subprogram and reset serial data buffering Main flow is returned after area and correlated variables.
The judgement subprogram that transfinites is responsible for detecting in each parameter of current greenhouse with the presence or absence of exception, and according to abnormal feelings The corresponding environment adjusting device of condition selecting switch is adjusted.More than function can be realized by two kinds of thinkings, one kind be from The angle of each ambient parameter is set out, and another is the angle from environment adjusting device.
From the angle of ambient parameter be than a kind of more conventional thinking, that is, judge each ambient parameter value one by one Whether limitation is exceeded, if it is, opening corresponding environment adjusting device.This mentality of designing is applied to ambient parameter and adjustment There is one-to-one relation between equipment, when not occuring simultaneously mutually.When the corresponding pass between each ambient parameter and adjusting device System, which exists, occurs simultaneously, such as certain several ambient parameter corresponds to some adjusting device, or some ambient parameter needs several to adjust When this thinking progress programming is still taken when finishing equipment is adjusted, logical relation will become sufficiently complex.Such as, two Individual ambient parameter is required to open ventilation equipment, when having judged first parameter, must take into consideration when judging second parameter To it is preceding once judge after whether opened equipment, such as judge without this, then judge for the first time after opening equipment, may be because of Parameter is judged for the second time for normally pass hull closure, but what this result was clearly wrong.Situation above can be with common factor The increase of degree journey on logical complexity refers to the increase of several times, uses in this case from environment adjusting device angle Thinking carries out programming and is relatively adapted to.Thinking from environment adjusting device angle is exactly by the super of each ambient parameter in fact Limit situation is classified according to environment adjusting device, and so each class overrun condition just only corresponds to an a kind of adjusting device, originally Common factor situation has not just existed naturally.What is used in the design is exactly that this thinking carries out subroutine design, and flow chart is such as Shown in Figure 17, the classification situation of ambient parameter is as shown in table 1.
The ambient parameter of table 1 transfinites classification chart
The environment adjusting device of correlation can be automatically opened up after ambient parameter transfinites when the subprogram is detected, and upwards Position machine sends alarming short message and called, and short message telephone function will be locked after performing once, now need to pass through PC control unlocks this function.
Microcontroller serial port sends data division and used in inquiry mode, flow chart shown in Figure 18 only comprising single-chip microcomputer to serial ports Receive the processing of data.The data length that gsm module is once sent is not fixed, it is front and rear comprising one group " r n " (carriage returns Newline), 2 bytes when remainder is minimum, such as " 0K " can more than 100 bytes, such as short message content when most.No Cross the prefix information that the data sent every time are not entirely effective content, such as more than 60 byte of " r n " and short message Deng.It is known that the RAM resources inside single-chip microcomputer are very nervous, the byte of part only 128 of full blast, wherein also wrapping It is less workable for part containing special applications, user, register addressing is used even if having to take the second best, also no more than 256 words Section, therefore, the data that single-chip microcomputer is sent to gsm module also need not should not all be read into.For above reason, and tie The form of GSM returned datas is closed, the number that mode is sent to gsm module in 4 is used in microcontroller serial port interrupt service subroutine Which kind of according to being read out, using pattern, determined by R_mode scalar values.
(1) reading manner 0:The indiscriminate data for reading specified bytes quantity of the reading manner, that is, continuous reading The data for the forward fixed qty that gsm module is sent.By many experiments, the quantitative value takes 24 proper.It is this to read Effective information is all contained in front end in mode reading efficiency highest, the suitable data for reading gsm module transmission or total data is long Part data of the degree no more than 24, typically use the pattern when monolithic machine testing gsm module returns to confirmation.
(2) reading manner 1:Only read second and the 4th character ' data after n '.The reading manner is specially designed For short message reading content.In the short message content that gsm module is sent second character ' be intended to indicate that this is short before n ' The source address of letter, the headers such as time, reading state are sent, be the real content of short message afterwards, therefore from second character ' n ' start to read, after actual short message content again by two ' n ' one can be sent represent to read successfully or wrong letter Cease (" OK " or " ERROR "), in order to detect that it is whether correct that short message is read, also read by the information.
(3) reading manner 2:The reading manner only reads the data after character '+'.With the data one of character '+' beginning As all be notify category information, such as notifying messages arrive "+CMTI ", notify phone arrive "+CLIP " and caller ID Deng, it is noted herein that, caller ID is not necessarily started with "+86 ", and the situation is considered as in programming.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should It is considered as protection scope of the present invention.

Claims (3)

1. the Greenhouse Monitoring system based on Android platform, including slave computer and host computer, it is characterised in that the host computer For the smart mobile phone of compatible GSM network, the 4.1.2 versions based on Android operation system write mobile phone with JAVA language design Application software, the software is set up by gsm module with slave computer and is connected, and is carried out data transmission in the form of SMS short messages, is used for The information that slave computer is sent is received, and greenhouse environment information is shown on mobile phone, while mobile phone arrange parameter can also be passed through Bound and directly control perform equipment;Slave computer gathers greenhouse scene using single-chip microcomputer as control core by measuring apparatus Ambient parameter, then after single-chip microcomputer is analyzed and is handled, shown on Liquid Crystal Module;Single-chip microcomputer is to default environment simultaneously Parameter enter line overrun judgement, and automatically control execution equipment the state of transfiniting is adjusted, send sound and light alarm, SMS alarm, Notify user in time.
2. the Greenhouse Monitoring system as claimed in claim 1 based on Android platform, it is characterised in that the SMS short messages Using English short message, and set it to Text modes.
3. the Greenhouse Monitoring system as claimed in claim 1 based on Android platform, it is characterised in that the system is divided into Manually and automatically control two parts, part is broken down or staff rule of thumb judges greenhouse automatically controlling When needing regulation, manual mode, manually opened execution equipment are switched to.
CN201710280129.6A 2017-04-25 2017-04-25 A kind of Greenhouse Monitoring system based on Android platform Pending CN106940577A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710280129.6A CN106940577A (en) 2017-04-25 2017-04-25 A kind of Greenhouse Monitoring system based on Android platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710280129.6A CN106940577A (en) 2017-04-25 2017-04-25 A kind of Greenhouse Monitoring system based on Android platform

Publications (1)

Publication Number Publication Date
CN106940577A true CN106940577A (en) 2017-07-11

Family

ID=59464755

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710280129.6A Pending CN106940577A (en) 2017-04-25 2017-04-25 A kind of Greenhouse Monitoring system based on Android platform

Country Status (1)

Country Link
CN (1) CN106940577A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048829A (en) * 2022-07-01 2023-05-02 荣耀终端有限公司 Interface calling method, device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536393A (en) * 2014-12-05 2015-04-22 浪潮集团有限公司 Short-message-based monitoring, alarming and controlling system of greenhouse
CN205375251U (en) * 2016-03-04 2016-07-06 张万军 Warmhouse booth control system based on it is intelligent
CN205656523U (en) * 2016-04-22 2016-10-19 安徽京师方圆信息技术有限公司 Vegetable greenhouse monitoring system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536393A (en) * 2014-12-05 2015-04-22 浪潮集团有限公司 Short-message-based monitoring, alarming and controlling system of greenhouse
CN205375251U (en) * 2016-03-04 2016-07-06 张万军 Warmhouse booth control system based on it is intelligent
CN205656523U (en) * 2016-04-22 2016-10-19 安徽京师方圆信息技术有限公司 Vegetable greenhouse monitoring system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048829A (en) * 2022-07-01 2023-05-02 荣耀终端有限公司 Interface calling method, device and storage medium
CN116048829B (en) * 2022-07-01 2023-10-10 荣耀终端有限公司 Interface calling method, device and storage medium

Similar Documents

Publication Publication Date Title
CN103505847B (en) A kind of running body-building system realizing exercise guidance based on data monitoring
CN1949814B (en) Domestic protection environment monitoring warning system based on wireless sensor network
CN205161283U (en) Intelligence planter
CN104318708A (en) Embedded intelligent security protection system of ARM-based Linux operating system
CN102032951A (en) Air quality detector
CN105444336A (en) Air conditioner control method and air conditioner
CN104767791A (en) Agricultural product storage and transportation control system based on wireless sensor network
CN104503310A (en) Greenhouse environment and soil information remote monitoring device and use method thereof
CN110545529A (en) Warmhouse booth environmental monitoring and management service system
CN106940577A (en) A kind of Greenhouse Monitoring system based on Android platform
CN202870546U (en) Novel intelligent insect forecast lamp programmable control system
CN106407800A (en) A hook method and a terminal device
Zhou et al. Application of WeChat mini-program and wi-fi soc in agricultural IoT: A low-cost greenhouse monitoring system
CN204348063U (en) Warmhouse booth wireless digital humiture display device
Davande et al. Smart wireless sensor network for monitoring an agricultural environment
CN203350752U (en) A universal monitor
CN201607806U (en) Distributed comprehensive earthquake situation and secondary disaster situation collecting system on site of earthquake
CN106124699A (en) A kind of intelligent air quality Real-Time Evaluation device and control method thereof
CN106839298A (en) Display device, system and method based on widget
CN107341398A (en) Program assessment method and device
CN109828627A (en) A kind of Intelligent agricultural monitoring system of greenhouse
CN203287044U (en) Environmental state embedded detection module
Qun et al. Greenhouse data monitoring system
CN205910615U (en) Remote interaction monitored control system based on android mobile phone APP
CN109041212A (en) A kind of localization method and wearable device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20170711