# Monitoring Perishable Commodities Using Cellular IoT:
## 2 Materials and Methods
### Hardware Architecture
#### 2.2.2 PCB Design  
As for the PCB design, a block diagram of its operation is depicted in Figure 2. The system consisted of a power supply stage, the USB communication, the sensors, the microcontroller and the wireless communication part. The power signal starts from the USB, which charges the lithium battery through the LTC4054 from the Analog Devices (Analog Way, 1, Wilmington, MA, USA) battery charger [62]. Subsequently, depending on whether the USB is connected to the battery, thanks to an assembly made with a diode and a P-channel MOSFET after the general power switch, the signal passes through a low-pass filter and reaches the voltage regulator XC6204 from Torex (Via [PERSON], 8/10, San Prospero, Italy) [63], obtaining a voltage value of 3.3 V to power the system. All power inputs on the various parts are suitably filtered to \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Sensor** & **Model** & **Range** & **Accuracy** & \begin{tabular}{c} **Power** \\ **Consumption** \\ \end{tabular} & **Communication** & **Remarks** \\ \hline \multirow{3}{*}{\
\begin{tabular}{c} Temperature and Humidity \\ \end{tabular} } & \multirow{3}{*}{SHTC3} & \(-\)40 to 125 \({}^{\circ}\)C & \(\pm\)0.2 \({}^{\circ}\)C & \multirow{3}{*}{2.7 \(\mu\)A} & \multirow{3}{*}{I\({}^{2}\)C} & Resolution of 0.01 \({}^{\circ}\)C & \\ \cline{3-3} \cline{5-6}  & & 0 to 100\% RH & \(\pm\)2\% RH & & & & and 0.01\% RH \\ \hline \multirow{3}{*}{
\begin{tabular}{c} Luminosity \\ \end{tabular} } & \multirow{3}{*}{BH1750} & \multirow{3}{*}{1 to 65,535 lx} & \multirow{3}{*}{0.11 lx} & \multirow{3}{*}{60 \(\mu\)A} & \multirow{3}{*}{I\({}^{2}\)C} & Resolution of 1 lx \\ \cline{3-3} \cline{5-6}  & & & & & & & \\ \cline{1-1} \cline{3-3} \cline{5-6}  & & & & & & & \\ \cline{1-1} \cline{3-3} \cline{5-6}  & & & & & & & \\ \hline \multirow{2}{*}{Vibration} & \multirow{2}{*}{ADXL345} & \(\pm\)2 g/\(\pm\)4 g/\(\pm\)16 g & \multirow{2}{*}{15.6 mg/LSB} & \multirow{2}{*}{15 \(\mu\)A} & \multirow{2}{*}{I\({}^{2}\)C and SPI} & Shock and inactivity detection; 10-bit \\ \cline{1-1} \cline{3-3} \cline{5-6}  & & & & & & \\ \cline{1-1} \cline{3-3} \cline{5-6}  & & & & & & \\ \hline \multirow{2}{*}{CO\({}_{2}\)} & \multirow{2}{*}{SCD41} & \multirow{2}{*}{0 to 40,000 ppm} & \(\pm\)40 ppm & 0.4 mA & \multirow{2}{*}{I\({}^{2}\)C} & \multirow{2}{*}{16-bit resolution} \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Summary of the technical description of the sensors. reduce noise and improve system stability, and the USB features an overvoltage protection diode. To read the battery, an N-channel MOSFET and a P-channel MOSFET are mounted to read the battery voltage with an analog input of the microcontroller after a voltage divider. This assembly with the MOSFETs allows for minimizing the consumption when reading the battery. For the sensor part, a P-channel MOSFET is available to power the luminosity, temperature, humidity and CO\({}_{2}\) concentration sensors when they are measuring and disconnect them when they are finished to achieve the maximum possible energy savings. These sensors communicate via I\({}^{2}\)C with the ESP32. The accelerometer is always powered and communicates via SPI with the microcontroller, while also having the interrupt signal connected to it to wake it up when it detects a vibration and to record the measurement. The sensors are filtered at the power inputs to provide greater stability and accuracy in the measurements, and the necessary pull-up and pull-down resistors are included to perform I\({}^{2}\)C and SPI communications with the microcontroller. The USB communicates directly with the CP2102 from Silicon Labs (West Cesar Chavez, 400, Austin, TX, USA) [64], a USB to UART gateway that allows communication with the ESP32 microcontroller, which makes it possible to update its firmware and read data from the sensors stored in memory. The microcontroller is powered by a 3.3 V signal from the voltage regulator, receives the reset and USB read signals and has a 40 MHz oscillator and a 32 kHz oscillator for its operation.