Editing GreenHouse Monitor Program
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
= What = | = What = | ||
− | + | This is an arduino program intended to monitor the environment in a green house. It has a simple command driven interface. It is designed to run with [[Python Smart Terminal]] Documentation on the construction of a Smart Terminal extension to support the green house monitor and save its data to a csv file are also part of this project and the documentation here. | |
− | |||
− | |||
− | This is | ||
− | |||
− | |||
− | |||
− | |||
= Source Code = | = Source Code = | ||
Still working on where I will keep the source. It is open source, email me in the meantime: [[User:Russ_hensel]] The code is pretty straight forward, the heavy lifting is all left to the [[Python Smart Terminal]]. There is nothing very fancy or special about the arduino program, get the source, read it. Email me if there are issuses. Also look at this wiki's category SmartTerminal (link at bottom of this page). | Still working on where I will keep the source. It is open source, email me in the meantime: [[User:Russ_hensel]] The code is pretty straight forward, the heavy lifting is all left to the [[Python Smart Terminal]]. There is nothing very fancy or special about the arduino program, get the source, read it. Email me if there are issuses. Also look at this wiki's category SmartTerminal (link at bottom of this page). | ||
− | = | + | = = |
+ | |||
+ | = Commands = | ||
Commands are single letter strings, in some cases followed by numbers. All end with a <cr>. All envoke responses all of which also end with <cr> | Commands are single letter strings, in some cases followed by numbers. All end with a <cr>. All envoke responses all of which also end with <cr> | ||
Line 19: | Line 14: | ||
|Command Purpose | |Command Purpose | ||
|Send | |Send | ||
− | | | + | |Response |
|Comment | |Comment | ||
<!--------------------------------> | <!--------------------------------> | ||
Line 34: | Line 29: | ||
|ok | |ok | ||
|Data is held in arduino memory, access with further commands. | |Data is held in arduino memory, access with further commands. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<!--------------------------------> | <!--------------------------------> | ||
|-valign="top" | |-valign="top" | ||
Line 46: | Line 34: | ||
|t | |t | ||
|33.0 60.0 | |33.0 60.0 | ||
− | |In this version there are 2 sensors | + | |In this version there are 2 sensors. |
<!--------------------------------> | <!--------------------------------> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
Line 93: | Line 76: | ||
** Opening the comm port and logging the data to a csv file. | ** Opening the comm port and logging the data to a csv file. | ||
− | Lets get an overview of the methods ( for the detail read the code | + | Lets get an overview of the methods ( for the detail read the code ): |
* __init__() builds the class, gathers references to other objects in the application, and finally defines some instance variables for data processing later | * __init__() builds the class, gathers references to other objects in the application, and finally defines some instance variables for data processing later | ||
* add_gui() builds gui components and returns a reference to the GUI components, for Tkinter this is a frame, for Kivy it will probably be a layout. | * add_gui() builds gui components and returns a reference to the GUI components, for Tkinter this is a frame, for Kivy it will probably be a layout. | ||
− | Now a complexity of the application is that it is running in 2 different threads. When the application starts up it has a single thread that after a bit of time creates the gui and runs its main method. I call that the GUI thread. The GUI thread starts another thread, ( the class SmartTerminalHelper ) which has its own methods and attributes. In a multi threaded application you have to be careful what calls what. Calls between the threads are particularly tricky once both are running. For the more difficult issues of this type communication between the threads is managed by pushing data into queues which are thread safe and allow the threads to communicate safely with each other. All this is in the code. The GHCSVProcessing class is a bit complicated since parts of it run in one thread, parts in the other. How do you tell what is what. There are two ways one is to reason it out, one is to read the comments, this discussion should help. Init is called from the GUI thread which is the one that is "in charge" of the application. It also calls __add_gui__ which since it adds to the GUI will create objects that are also executed in the GUI thread. | + | Now a complexity of the application is that it is running in 2 different threads. When the application starts up it has a single thread that after a bit of time creates the gui and runs its main method. I call that the GUI thread. The GUI thread starts another thread, ( the class SmartTerminalHelper ) which has its own methods and attributes. In a multi threaded application you have to be careful what calls what. Calls between the threads are particularly tricky once both are running. For the more difficult issues of this type communication between the threads is managed by pushing data into queues which are thread safe and allow the threads to communicate safely with each other. All this is in the code. The GHCSVProcessing class is a bit complicated since parts of it run in one thread, parts in the other. How do you tell what is what. There are two ways one is to reason it out, one is to read the comments, this discussion should help. Init is called from the GUI thread which is the one that is "in charge" of the application. It also calls __add_gui__ which since it adds to the GUI will create objects that are also executed in the GUI thread. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | *find_and_monitor_arduino( self ) | ||
+ | *set_time() | ||
+ | *process_temp_line() | ||
+ | *process_humid_line() | ||
+ | *cb_find_and_monitor_arduino() | ||