top of page

Connection Schemes


In this project, two Arduino Mega 2560 boards are used to capture user input, control the actuator, and collect data from sensors.

The first Arduino Mega works in a slow loop, and the second, in a fast loop.

First Arduino Mega – Slow-loop

This Arduino operates in a low-frequency loop and its main task is to control the stepper motor. This is done through parameters calculated from the user inputs (TV, RR and IT), as already explained in the section "The Theory Behind". The cycle of this loop has the same duration as the cycle of a respiratory rate, as defined by the respective input.

To read the inputs, 3 encoders are connected to the board, through which the user can vary TV, RR and IT via knobs. These inputs are shown on an OLED display also connected to the board.

A button and two LEDs (one green and one yellow) are also connected to this board. By pressing this button, the green LED lights up, informing you that the system starts to operate according to the defined inputs. If the actuator is not in its reference position, the yellow LED lights up while the system automatically sets the actuator in the reference positions. This happens thanks to an “end-stop switch”, also connected to this board. 

Figures 18 and 19 exhibit the connection scheme for the slow-loop board (since there are too many connections, this scheme has been divided into two figures).


Figure 18 - Connection scheme for the slow-loop Arduino


Figure 19 - Connection scheme for the slow-loop Arduino (continuation)

Second Arduino Mega – Fast-loop

This Arduino operates in a high-frequency loop. Its task is to read data from the pressure sensor and the flow meter with the shortest sampling rate the board/code allows. The large amount of data is needed to form curves in real time with as many points as possible. Figure 20 shows the connection scheme for the fast-loop board.


Figure 20 - Connections scheme for the fast-loop Arduino

Raspberry Pi

A Raspberry Pi 4 runs a web server that hosts an HTML page to display the input information as configured by the user (redundancy to the OLED display). In addition, the "Minute Volume" (MV) and the "I: E ratio" are also displayed on the page, as they are calculated from the inputs "Respiratory rate" (RR) and "Inspiratory time" (IT).This information is provided by the first Arduino board (slow-loop).

The same HTML page also presents the pressure and flow readings (including the curves) captured by the respective sensors provided by the second Arduino board (fast-loop).

All this source-code is disclosed in the section "Software".

The Raspberry could be configured as an access point to allow Wi-Fi connections, however, in my opinion, it is a better idea to connect the board to your home network as a client, taking advantage of a more powerful wi-fi signal provided by your router. Once connected, users can view the referred web page through web browsers (from tablets, phones, laptops, etc.). Another interesting point is that the Raspberry has a web browser called "Chromium" (a Linux version of Chrome). Upon connecting the board to a monitor, just open Chromium and run the web page in the Localhost.

The two Arduinos are connected to Raspberry via serial connection (using two of its USB ports). Two Python scripts read the data transmitted by each port and make them available to be processed by the server (in node.js), which sends the information through to be published by the page. Figure 21 shows the connection from the Raspberry.


Figure 21 - Connections from the Raspberry Pi

The First Arduino, the encoders, the OLED, the start/stop button, the LEDs and the Rasberry are located inside a box called "Control Panel Box", as shown in Figures 22a and 22b (without the covers).


Figure 22a - The Control Panel box


Figure 22b - The Control Panel box (uncovered)

The Second Arduino is located very close to the frontal set (in the plumbing circuit). The reason is that the cables connecting the flow meter and the pressure sensor to the board must be very short (maximum 10 cm) to avoid electromagnetic interference. Figure 23 shows the location of the Second Arduino.


Figure 23 - Location of the Second Arduino

bottom of page