## 3 Design of Hardware and Software for the Data Monitoring System
### Communication between Wireless Modules  
The Wireless module algorithm is always the same, but its behaviour depends on the module to which it is connected. When the connected module request data to the Wireless module, it uses the I\({}^{2}\)C protocol. On the other hand, communication between two Wireless modules uses Serial port. When a communication is requested, the Wireless module analyse the message depending on if the message comes from Serial (from other Wireless module) or from I\({}^{2}\)C (from a Master or Slave module). On the first case, the message has to comply with the standards and, if the message is correct, the Wireless module will accept the order and send an _akn_, otherwise it will ignore the order and send _Nakn_ or a _Ncrc_ if any byte has been corrupted during the transmission. \begin{table}
\begin{tabular}{c c} \hline \hline
**Symbol** & **Description** \\ \hline akn & \multicolumn{1}{c}{Acknowledge byte} \\ Buff\_S & Serial buffer \\ Ch & Sensors Channel \\ CRC & Cyclic Redundancy Check \\ DP & Data Positions (2 bytes: [First\_Byte\_Position, Last\_Byte\_Position]) \\ H\_Ch & Channel header for the transmission of the selected channel \\ H\_Dt & Data header for the transmission of the Data from Sensors \\ H\_FDt & Data header for the transmission of the last message of Data from Sensors \\ LDP & Last sensor data \\ M\_Dir & Wireless Module Address \\ MSign & “_Sign_” always checked as correct coming from a Master Wireless \\ Nakn & Negative Acknowledge byte \\ Ncrc & Negative Cyclic Redundancy Check Validation \\ O\_CCmd & Order of Canceling Command, also used at the end of an instruction \\ O\_MRDt & Order from Master to Request Data from his Wireless Module \\ O\_MRMd & Order from Master to Request Data from a Module of Sensors \\ O\_SRCh & Order from Slave to Request the channel to read the Data from Sensors \\ O\_SSDt & Order from Slave to Save the Data from Sensors \\ O\_STDt & Order from Slave to Transmit the Data from Sensors \\ O\_WRDt & Order from Wireless to Request Data from a Channel of Sensors \\ O\_WSDt & Order from Wireless to Save Data from a Channel of Sensors \\ O\_WTDt & Order from Wireless to Transmit the Data from Sensors \\ PIN\_B & Send Buffer PIN \\ PIN\_R & Request PIN \\ RFrom & Request From \\ Sign & Validation bytes for the transmission of Data \\ XXSD & Information Bytes (XX means de number of bytes) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Glossary of Symbolism used. In order to offer support to the I\({}^{2}\)C communication, two digital pins are used on the Wireless module, _PIN_R_ and _PIN_B_. _PIN_B_ = 1 indicates that a message is available to be read from the exit buffer of the wireless so the Slave or the Master module can send a _RFrom_ command (Figure 6) to read the message. Meanwhile, _PIN_R_ = 1 indicates that the last command order has not been performed yet. Finally, an _O_CCmd_ (Figure 6) can be used to put both _PIN_R_ = 0 and _PIN_B_ = 0, interrupting any communication state. Data transmission always starts with the Master sending a request by I\({}^{2}\)C to its Wireless module using the _O_MRMd_ command (Figure 7). When the information is read, it contacts to the correct module to request its data using the _O_WRDt_ command together with the value of the desired sensors channel. Figure 6: Wireless module, I\({}^{2}\)C Support Orders. Figure 7: Flowchart of wireless orders from Master module. When a Wireless module has been contacted by _O_WRDt_ command (Figure 8), it sends an interruption using _PIN_R_ = 1 indicating to the Slave module that a data request has been managed. Then, a data transmission starts in order to load the sensors data from the requested channel. Once the requested module has loaded the information from the Slave module, it starts the Wireless data transmission. All sensors data are sent in defined transmission messages to the receptor data Wireless module.