# Rural Healthcare IoT Architecture Based on Low-Energy LoRa
## 4 System Architecture
### Memory Persistence in Sleep Modes  
As transmitting data via LoRaWAN has energy implications, an application that aims to reduce consumption could buffer the data gathered by the sensors and transmit more infrequently depending on the data size and the LoRaWAN packet size.  
Let \(p_{l}\) be the power used for sending the LoRaWAN packet and \(t_{l}\) be the time needed to send the packet. Let \(n_{p}\) be the byte-size of the packet and \(n_{s}\) be the sample size of data collected in one sampling interval. Let \(p_{s}\) is the power consumed during sleep. We will assume that this value is much lower than \(p_{l}\) and would not consider it. The energy savings when using data buffers is \(E\), shown in Equation (1).  
\[E=\left(\left\lfloor\frac{n_{p}}{n_{s}}\right\rfloor-1\right)*p_{l}t_{l}\quad \text{(if $p_{s}\ll p_{l}$)} \tag{1}\]  
It is illustrated in Figure 6, where the blue/dotted line indicates a normal scenario where data is sent after each sample and the red/solid line is the energy saving mode where a message is composed of multiple data readings to form a single data frame. \(\left\lfloor\frac{n_{p}}{n_{s}}\right\rfloor\) is equal to four. This indicates that the data from each sensor sample is less than or equal to \(1/4\) of the message size. The '\(-1\)' in the Equation indicated that we could not avoid the final transmission once the packet size is reached. In the case of a noisy channel with a high probability of collisions, this approach further reduces the probability of collision by reducing the number of transmissions.  
Another option is using persistent memory, such as a micro SD card, to preserve the data. In this use case, additional energy is used to read and write data on the SD card each time the sensor reading is performed. We must read data every time the sensor measurement is done to determine if the buffer is full and ready to transmit. Let energy used for the write and read data step \(E_{rw}\). Since the data is written to permanent memory, the microcontroller could be placed in a power-off state to be awaken by external ULP timer. If we consider that the external interrupt uses power much lower than the microcontroller (\(p_{ext}\ll p_{s}\)), in the sleep state, the energy is saved for the entire sleep interval \(t_{s}\). The average power used during boot-up is \(p_{b}\), and the total energy used for the boot-up step is \(E_{b}\). The energy-saving \(E\) is calculated using Equation (2).  
\[E=\left(\left\lfloor\frac{n_{p}}{n_{s}}\right\rfloor-1\right)*(p_{t}t_{l}+p_{s} t_{s})-\left\lfloor\frac{n_{p}}{n_{s}}\right\rfloor*(E_{rw}+E_{b})\quad\text{(if $p_{ext}\ll p_{s}$; $p_{s}\ll p_{l}$)} \tag{2}\]  
This is illustrated in Figure 7, where the blue/dotted line indicates the transmit-for-each-sample scenario and the red/solid line is the energy savings by combining data in a single data frame and writing to persistent storage. The time axis is presented to include all states but is not to scale. In reality the sleep state lasts much longer than the other events such as read-write \(t_{rw}\) and boot-up \(t_{b}\) (\(t_{s}\gg\left\lfloor t_{rw},t_{b},t_{l}\right\rfloor\)).