Hardware and Software Components of an Oysters' Gape Measurement System

Corresponding Author: Ali Abu-El Humos, Department of Computer Science, Jackson State University, Jackson, USA Abstract: In this work, the hardware and software used in developing a bivalve gape measurement system is explored. This system employs the Hall-effect phenomenon to accurately measure and report the gape of a bivalve. The system uses a Hall Effect sensor (Symmetry Electronics’ H2425) and a small magnet in which both are glued to the exterior of the shells of a bivalve. Consequently, the Hall Effect sensor reports the distance of the magnet, hence the gape opening, to a microcontroller that records and transmits the data to a ground station. This system has been designed to operate in the field as well as in a laboratory environment. In a laboratory setting, this system uses Wi-Fi or Bluetooth to transmit its data. In the field however, due to the lack of availability of power, two setups have been established. The first setup does not transmit data, instead, it saves the data in an SD card within the system’s enclosure. This setup is fully submersible. The battery, microcontroller and SD card reader are all submerged alongside the bivalve. This experiment shows that the system can work for as long as 29 days with a single battery charge. Therefore, each month the battery of this system will have to be replaced if data collection is to continue. The second field system is one that wields cellular network to communicate its data. This is a viable solution since most reefs exist close enough to the shore where cellular signal is available. Additionally, the system includes a solar collector panel for charging the battery during the day and constantly keeping the system transmitting at night. The laboratory system as well as the underwater field system are both fully operational and have been producing gape data for several months. The cellular system is currently being tested and data from all systems will be made available under the MBRACE project data repository.


Introduction
The Mississippi Based RESTORE Act Center of Excellence (MBRACE) is a consortium of four research universities: Jackson State University (JSU), Mississippi State University (MSU), the University of Mississippi (UM) and the University of Southern Mississippi (USM), where USM takes the lead in the research. MBRACE sponsored four projects in studying the importance of the environmental condition of oysters in the Mississippi Gulf Oyster Reefs with each university being assigned a specific project. JSU's team was tasked with the responsibility of developing biosensors for the measurement of Bivalve Valve Movement (Mbrace, 2018).
To some, oysters are merely just a delicacy and to others they are a source of rare pearls. Oysters have supported civilizations for millennia, from Romans to California railroad workers to the thousands of workers employed as oyster dredgers in Britain (Beck, 2011). It was only a few decades ago that the enormous and vital contribution of oysters to the ecosystem was finally recognized. Since then, scientist have tried to study the behavior and life cycle of oysters in order to better understand just how important these mostly static creature are to marine life and the entire global ecosystem. Newell (1988), shows that the adverse ecological changes that were observed at the Chesapeake Bay could largely be attributed to overharvesting of the American Oysters. Oysters play a significant role in cleaning carbon-based substances and phytoplankton from the water, which if left to accumulate will be devastating to the ecosystem. Oysters are ecosystem engineers, not only do they clean the marine ecosystem, but as a foundation species, their massive reefs also provide an essential habitat for a variety of fish and invertebrates . Over the years, oyster habitats have been subjected to overharvesting and climate/environmental factors that have led to critical levels of devastation with very high mortality events experienced in the summer (Malham et al., 2009). An estimated 85% of oyster reefs have been lost in comparison to historic abundances (Blomberg, 2018). In recent years, efforts to restore oyster reef habitat have increased to aid in amending damage. In order to meet these goals, it is imperative that the life cycle of these organisms and the conditions necessary for them to thrive and reproduce are understood.
In the present research, we make use of the advances in electronic and computer technology (microcontroller and sensor) to build a resilient, low-cost, low-power and multifunctional sensor system that can measure and record the gape of oysters both in the field and in the laboratory. The field sensor has two distinct setups: the surface deployment and the submerged deployment where data is transmitted through Wi-Fi to a webserver. The collected data can also be stored in an SD card. With the laboratory deployment, data is transmitted through Bluetooth to a designated lab server. The second laboratory installation is a submerged setup that stores data on SD card. This system is battery powered.
The rest of this paper is structured in the following manner. Section 2 describes a summary of the related work. Section 3 identifies associated system architecture and presents a concise review of the state of the art connected Hall effect sensor, microcontrollers and sensor calibration. Section 4 discusses the software aspect of the project, detailing the node code with and without temperature. It also explores the Wemos sequential code. Section 5 summarizes the results of the research. It gives a detailed review of the data retrieved from the gaping of the oyster. Section 6 is the conclusion of the paper. Finally, it considers limitations and ultimately presents ideas for future research.

Related Work
According to Payton's study (Bernard, 2016), valve opening activity in many bivalve species is closely related to physiological processes such as respiration, nutrition and reproduction, which are modulated by environmental factors. Research shows that valve opening duration of oysters follow the tidal cycle which aligns with the synodic moon cycle and anomalistic moon cycle. The influence of tidal and photoperiod on the valve opening behavior did not fully explain the behavior of oysters as conditions like favorable temperatures and abundance of food still seemed to have a strong influence as seen in the spring and summer seasons (Bernard, 2016). Oysters' valve opening becomes more active near the coldest periods of the year (around March) and conversely closed their valves and start to become inactive towards mid-September. The variations in valval opening was most indicative of the oysters feeding habits and periods of increased valve movements were also associated with increased shell growth (Bernard, 2016).
Measurement of the shell gape in bivalves using Sensor technology was introduced in Wilson's (2005). Utilizing the Hall effect, this method consists of a Halleffect sensor, a type of magnetic sensor with the ability to convert magnetic fields into a measurable voltage output. This output is directly proportional to the strength of the magnetic field passing through the sensor and can therefore continuously record the movement of a magnet relative to the sensor (Wilson, 2005). By attaching a magnet and Hall-sensor to either valve, the shell gape of bivalves can be observed continuously, without intrusion (Clegg, 2014). So far this method has been applied to mussels, scallops and cockles (Wilson, 2005) with much success, although Hall-effect sensor applications do have limitations (Clegg, 2014). The limitations surrounding sampling frequency have been previously addressed (Wilson, 2005), concluding that decreasing the sampling rate can overestimate the length of gape events and generate erroneous profiles and adduction behavior (Clegg, 2014).
To measure valve opening, a high-frequency noninvasive valvometry was used. This equipment consists of a pair of lightweight electrodes glued on each half of the shell and an electromagnetic current was generated between them. These electrodes were insubstantial enough not to cause any interference to the bivalve's behavior and the changes in the electromagnetic current corresponded to the gaping activity of the animal. These were measured every 1.6 sec and data was recorded and transmitted through cellular and Internet network (Bernard, 2016). Similarly, attached electro-coils to both siphon sides of each valve and monitored and measure using the strength of the electromagnetic field which was determined by the distance between the valves (Bernard, 2016). In this case, the electrodes where held in place by light-curing dental resin cement and the data was stored in a memory card which was housed in a submerged control unit. Data was measured once a minute and the raw electrical signals were amplified and stored for later conversion in to distance measurement. A separate system called the Data Storage Tag Conductivity and Temperature logger (DST CT) was used to measure temperature and salinity every 30 minutes (Bernard, 2016). These factors believed to play a very important role in the behavior and reproductive habits of bivalves.

System Architecture Overview
The system architecture comprises three units: one particular Microcontroller Unit, an Arduino Nano -ATmega328P, another Microcontroller Unit, the Wemos -ESP8266 and six Hall-effect sensors, HAL 2425. The block diagram of this system is shown below in Fig. 1.
Each sensor system has six (6) analog inputs of the ATmega328P which are connected to six (6) Hall effect sensors. The Hall effect sensor is placed on one side of the shell of the oyster and a magnet on the other side. The system is configured in such a way that it reads six sensors and transfers the data to a repository server and then sleeps for 90 ms. Next, the system wakes up, reads the sensors and sends the data to the server and sleeps for another 90 ms. This cycle continues until the battery voltage drops to 10V.
The data collected by the sensor system is transmitted through a network to the repository server, Mbrace.XYZ. The gateway is responsible for transmitting sensor data from the sensor system through a local transit network to the remote base station that provides WAN connectivity and subsequently transmits to web-server for data logging. Lastly, data visualization is the final stage of the whole process. The data collected by the server is accessed by the users and displayed through a user interface such as mobile apps and desktop display.
The Arduino Nano is the central engine of the sensor system. The Arduino is a microcontroller based on ATmega328p technology and is widely used in robotics embedded systems and lightings and electronic projects where automation is an essential part of the system. It is the most accessible way of automating electronic projects, making it possible to control devices (Electronics, 2017).
Another microcontroller used in this project is the ESP8266 Wi-Fi Module designed by the Chinese company, Espressif Systems (2018). It is an extremely affordable and versatile wireless System-on-Chip (SoC) that can perform the task of a wireless communication adapter for the sensor unit (Espressif Systems, 2018 andGeekstips, 2018). ESP8266 is a complete Wi-Fi sensor that incorporates a 32-bit processor, some RAM and depending on the vendor, between 512KB and 4MB of flash memory. This allows the chip to either function as a wireless adapter that can extend other systems with Wi-Fi functionality, or as a stand-alone unit that can autonomously execute elementary applications (Espressif Systems, 2018).
Lastly, this project uses the Hall-effect sensors in which the sensors and magnets are attached directly to either valve of the oysters to capture raw gape data from the animal. The Hall-effect is an ideal sensing technology. The Hall element is constructed from a thin sheet of conductive material with output connections perpendicular to the direction of current flow (TDK Micronas, 2016 andElectronics, 2018). When subjected to a magnetic field, it responds with an output voltage proportional to the magnetic field strength (Symmetry, 2017). The voltage output is very small (μV measurements in particular) and requires additional electronics to achieve useful voltage levels. When the Hall element is combined with the associated electronics, it forms a Hall-effect sensor (Honjo, 2006).

Energy Budget and Power Consumption
In this study, we adopted several strategies to maximize the lifetime of the battery thus optimizing power consumption. One of such techniques was to disengage the LED on the microcontroller (ATmega328P) resulting in more than 50% power savings. Another method adopted to optimize the battery power was to utilize a low power library code which causes the system to sleep between readings. This forces the sensors to power down between readings. Again, a more efficient SD card (one that consumes less power) was used in this project. The code was tweaked to make possible minimal writing to the SD card. Lastly, the supply voltage terminal of the HAL 2425 was connected to the Nano (D1-D6) instead of the usual direct connection to the supply voltage (Vin). With this approach, the power supply to the sensors can be shut down whenever the Nano sleeps.
At the end of this project, a 5000mAh battery was able to last for 29 days, though the goal was to last for between 2 to 4 months on a single charge.

Sensor Load Calculation
Battery lasted for 29 days with a cut off voltage of 10V. To calculate the hours DC battery will last: / Battery life in hours rating in mAH load in Amps  (1) Convert 29 days to hours 29*24 = 696 hours Battery rating = 5000 mAH Substituting these values into Equation 1 above, we have: 696H = (5000*10-3) AH/I I = (5000*10-3AH)/696H = 0.007183A, I = 7.183mA The sensor load is 7.183mA

Sensor Calibration and Linearization Steps
Sensors often exhibit nonlinear transfer characteristics hence require calibration and linearization. The choice of an adequate linearization method is critical for the overall performance of the sensor system (Lopez-Martin and Carlosena, 2013). Sensors are used to convert physical quantities of interest into electrical signals. Many sense elements are inherently nonlinear. In essence, their outputs are not linearly proportional to the physical quantity they are measuring. As the physical quantity of interest changes, the output changes nonlinearly (Vemuri and Tong, 2016).
The calibration and linearization of the Hall-effect sensor define the accurate readings and actual gape distance. The goal of calibration is to minimize any measurement uncertainty by ensuring the accuracy of test equipment. Calibration quantifies and controls errors or uncertainties within measurement processes to an acceptable level (Tempcon Instrumentation, 2016) The sensor provides an improved linearization output by incorporating a flexible compensation function with 16 programmable calibration points. The set-point linearization in general allows to linearize a given output characteristic by applying the inverse compensation curve (TDK Micronas, 2016).
In this work, Micronas HAL/HAR 24xy Programming Environment was used to calibrate and linearize the HALL 2425. To calibrate the sensors custom settings were set with magnetic range that is fitting for sensor receptiveness. A magnet was placed on the proper polarity side of the calibration machine. After that, the Arduino IDE was initiated with appropriate calibration code to perform the calibrations steps with two-point calibration method. For the linearization, in the Micronas HAL/HAR 24xy Programming Environment, the measurement file was loaded with extrapolation which results in writing setpoints and providing linearized values.

Low Power Code
The purpose of this code is to make sure that the sensors use the minimum power consumption so that data can be received for a maximum timeframe. There are four (4) data collection speeds that supports eight (8) sensors. These speeds are 1 = 10 HZ; 2 = 1 HZ; 3 = 1 min and 4 = 1 hour that takes reading overtime. The code runs within a loop which reads certain bytes of data with the given data collection speeds and adds these to data array. When the array is full, it writes the data on a file on the SD card. Otherwise it goes back to the loop to collect the required bytes of data.

The Node Code
The node code has been used in two different ways, one is the node code with temperature and the other one is the node code without temperature. The node code with temperature (pseudo code shown in Fig. 2) sends six bytes of data for the sensors and one byte of data for the temperature upon request. It uses a 5V I2C bus and a X5 water temperature. While including the libraries, the pins must be declared and set to "high". Next, the implementation of mapped analog function from the Arduino Nano. This function specializes in re-mapping a number in range, from one range to another. After reading data from all the sensors, including temperature, it returned the data in array format.
For the node code without temperature, the software follows the same structure and procedure as previously mentioned in the node code with temperature except the fact that, it does not contain a temperature sensor.

Wemos Sequential Software
In this code, Wemos requests data to the Nano and receives six bytes of data in return and creates an array. The interrupt is set for 100 milliseconds. With every interrupt, a new request is sent and new bytes of data were received. With this procedure, the array becomes increasingly substantial and gets assembled amongst each other. When the array size reaches maximum capacity, which is 78 bytes, it sends data to the MBRACE.XYZ server. The sending of request to the Nano continues until the array is full.

Mobile App for Visualization
To facilitate the visualization of the data received from the sensors, a user-friendly application was developed with the Swift environment that support the iOS devices. To view the data in the application, the host needs to be connected. With the selection of the desired date and sensor number in the application, data received from the selected sensor will be visualized on the application screen.

Gape Data Visualization
Two sensor systems, A and B, were deployed in the field on August 10, 2018. The oysters in the field generated continuous data that was collected and transmitted to a repository server. Two sets of MATLAB programs were developed to retrieve data from Mbrace.XYZ. The first program was designed in such a way that it collects live gape data while the second code retrieves old gape data as shown in Fig. 3.
In this paper, we present four sets of graphs for the sensor systems, two graphs for sensor set A and two graphs for sensor set B. The duration of data readings is 24 h-between the periods of 7:00 PM to 6:59 PM.

Sensor A Graphs
The graphs show continuous gaping activities for six oysters for a duration of 24 h. The variations in colors in the graphs represent each oyster. However, one of the six oysters, indicated by the purple line, exhibited a different behavior from the other five animals where continuous recording of the valve movements were observed. The flat lining indicated at the beginning of the day was due to inactive behavior of the oyster. The oyster with purple lining in Fig. 4 and 5 demonstrated unique behavior from the other five oysters. It may have been due to response to the environment with unusual activities during the 24 h period under review and perhaps there was a short circuit on the HAL 2425 sensor.
The portions of the graphs that display long periods where the line is flat (i.e., the shell is open), interspersed with sporadic spikes indicates shell closure of a short duration.

Sensor B Graphs
Likewise, sensor B has six oysters. Figure 6 shows data for only 5 h against the usual 24 h. This was due to the system being installed at 2:00 PM, so data readings were between 2:00 PM to 6:59 PM. From this graph, little spikes can be observed during the five hours under observation compared to the graphs in Fig. 7. This was an indication that the animals were reacting to the environment. In Fig. 7 can be observed in one of the oysters in Fig. 7 indicated by sky blue lining, resulting in heavy noise. This was an indication that the oyster was responding to potential environmental factors such as salinity, predator(s), food, temperature, light, etc. and possibly a short circuit on the HAL 2425 sensor.

Conclusion and Future Work
In this research, we make use of the advances in electronic and computer technology utilizing microcontroller and Hall effect sensor to build a resilient, low-power, low-cost and multifunctional sensor system that can measure and record the gape of bivalves (oyster) both in the field and in the laboratory. One of the goals of this research was to build and develop an efficient power system using low power libraries that could sustain the sensor system for a long period of time.
The sensor system is battery driven with limited energy sources and a large power consumption. Hence, efficient energy management is a critical design objective both in hardware and software design. One of the greatest challenges of this research was the energy consumption of the system. Therefore, reducing the overall energy consumption of the system was necessary for optimal performance while satisfying the Quality of Service (QoS) or performance constraints.

Limitations
Although some tremendous milestones were reached in our research, we encountered a few challenges:

Power Consumption
The initial goal of this study was to have an energy system that would last for a minimum of 60 days. However, that was not achieved as the battery could only last for 29 days versus 7 days at the start of the project. This short life span of power stemmed from many factors. The SD memory card, which was used to store data for a submerged sensor system, was a "power hungry device". Another factor that could cause a drastic drain of the battery energy is the way the Hall effect sensor terminals are connected to the Arduino Nano. A good technique is to connect the power terminal of the sensor to the analog pins of the Arduino Nano.

Sensor Calibration and Linearization
The enhanced calibration approach that would guarantee precise calibrated and linearized sensor readings should be adopted. Although the current calibration method (rotor calibration machine) is automated, manual inputs are required from users. This could introduce errors that could interrupt the final results and ultimately impair the accuracy of the experiment if caution is not exercised during calibration.

Cellular Networks
The best approach to guarantee smooth and continuous data transmission is General Packet Radio Service (GPRS). This method is currently undergoing tests.

Mobile Application
Although this App has been developed, it has not been fully operational for Android and iOS smartphones. It is fully functional on iOS desktop.

Future Work
While the main objectives set in the beginning of the project have been achieved, this work represents only one approach of the problem to solve. It would be interesting to further investigate on how to improve certain aspects of the project. Further research could be explored in the following areas:  Improving on the use of cellular networks (GPRS) to transmit data from the field to webserver on the cloud. Relying on Wi-Fi sometimes creates a point of failure and bandwidth congestion  Furthering study on enhancing the life span of battery. In our study, the battery could last for 29 days instead of the 7-14 days prior to the start of the research  Incorporating the ability to view all sensors concurrently alongside the smart phone application.  Exploring a robust calibration and linearization technique for future research to further refine results