Software
The software on the device consists of an Arduino-end .ino firmware for data collection and valve-related actions; it responds to serial input and works on a passive "request-respond" mode, where each action is referred to a specific command. In addition, there's a .py file running on the host computer that is actively sending out commands to the Arduino in data collection and valve actions. Upon collection, the python script will then further analyze and store the data. The python script is also responsible for communication with the syringe pump interface and integrating syringe actions into the workflow. Please note that .ino files follow C++ grammar.
In the Arduino firmware, two external libraries are included for temperature sensor output reading: OneWire and DallasTemperature. Please make sure that you have installed both libraries correctly before proceeds to upload the file. In the firmware, actions are packed into a series of functions: valve_on(int ValveInControl) and valve_off(int ValveInControl) for solenoid valve control; temp_read(), gas_read(), co2_read(), o2_read() and h2_read() are responsible for data collection, note here gas_read() means to obtain current water level, which equals to the amount of gas produced. Additionally, three global variables are declared, their values change each time as valve status refreshes, 0 for off and 1 for on. Sensor readings and valve status are put together by thread_report() to generate an eight length float array. When printed, it should look something like the following:
To turn on the valves, simply send a + valve number via serial to Arduino Mega 2560, and b + valve number to turn off the respective valve. Similarly, the python script on the host computer requires matplotlib to function. Please make sure it is set up before running.