This project is based on https://github.com/jcl5m1/ventilator.
- additional 12v pump for the exhale phase
- controller for the exhale pump
- button to switch between adjusting the exhale and inhale cycle
- software changes,
- display shows the cycles/min of the inhale phase
- display shows the cycles/min of the exhale phase
- enables pump between exhale and inhale based on the phases' cycle setting
The display shows two things
- what
Mode
the ventilator is currently in; exhale or inhale. - the cycles per minute for both modes
The annotations in this image; Potentiometer & Button are used to adjust the ventilator. The button will switch the mode between inhale or exhale, while turning the potentiometer will adjust the cycles for the active mode.
Almost all of these can be swapped out with similar components.
-
ESP8266 (any ESP8266 will do)
-
12V air pump (make sure it is 12 volts and has a 2 amp AC power adapter) - Need 2
-
MOSFET 12v controller (can be substituted with a relay) - Need 2
-
Potentiometer 10k (can be substituted with lower resistances)
-
Button
-
OLED Display
-
CPAP tube (6ft with a 15cm diameter) - Need 2
-
3D printer for mouth piece
- TODO
-
3.7v LiPo battery, 800mAh or higher (alternative, keep ESP8266 attached to powered USB)
-
TP4056 LiPo charger module
Version 0.0.1 of this project has a basic/optional LED display and adjusts to a range of ventilation breathing cycles.
Ventilator cycles between a range of breathing cycles as shown on the display
Quick circuit using a glue gun and Dupont connectors MOSFET(left of red LED) is not regulating voltage and isn't generating heat
Simple circuit without battery powered board
-
ESP8266 (any ESP8266 will do)
-
12V air pump (make sure it is 12 volts and has a 2 amp AC power adapter)
-
PWM controller (can be substituted with a relay)
-
Potentiometer 10k
-
OLED Display
-
CPAP tube (6ft with a 15cm diameter)
-
3D printer for mouth piece
-
3.7v LiPo battery (alternative, keep ESP8266 attached to powered USB)
-
TP4056 LiPo charger module
3D printed display mount and case
- ventilator-base-lid-current
- ventilator-base-components-current
- ventilator-base-battery-current
- ventilator-display-mount-current
Build and deploy firmware using PlatformIO.
note, you can can find a partially completed ESP32 project in the master branch
pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
vi ~/.bashrc
(or .profile or zshrc...) and addexport PATH="$PATH:~/.platformio/penv/bin"
- close your terminal and reopen or
source ~/.bashrc
to reload the PATH - (optional) activate the virtual environment,
. activate
which should now be in the PATH - can you run the cli?
pio
? if not go here, https://docs.platformio.org/en/latest/installation.html
- Just search for and install the extension
PlatformIO
- Open
settings.json
in VSCode (from the Command Palette typePreferences Open Settings (JSON)
) - Add the following (inside
{...}
),note, customPATH probably isn't necessary since we added it to the"platformio-ide.customPATH": "~/.platformio/penv/bin", "platformio-ide.useDevelopmentPIOCore": true
PATH
- Restart VSCode
- use the cli an run ,
pio run
this will take a minute to fetch the board firmware and build it. Look in the newly created folder /.pio to see what is pulled down - once everything is built then you need to upload the program (/src/main.cpp) to a board, this example uploads to the ESP32 board,
pio run -e ventilator -t upload
. Note, if you have all your boards connected via a serial port then you don't need to specify-e
or which environment to upload to.upload_port
is pegged to a specific port, this should change as needed.
pio device monitor -b 115200
This project doesn't need VSCode or the PlatformIO extension in VSCode. If you look closely at the commands executed, all that is needed is PlatformIO Core and the included CLI.
-
Update PIO,
pio upgrade --dev
-
Find the latest PIO GCC ARM toolchain for Mac here, https://dl.bintray.com/platformio/dl-packages/ currently it is, toolchain-gccarmnoneeabi-darwin_x86_64-1.90201.191206.tar.gz, then add it to
platform_packages
-
add a platform_packages reference in plaformio.ini
[esp32]
platform_packages =
toolchain-xtensa32 @ 2.80200.200226
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
- then have the environment definition reference this
[env:ventilator]
board = lolin32
framework = arduino
platform = espressif32
platform_packages =
${esp32.platform_packages}
- https://community.platformio.org/t/how-to-install-a-newer-toolchain-than-the-official-one/8238
- https://community.platformio.org/t/can-not-compile-arm-none-eabi-g-command-not-found/9458/14
Follow these articles
- https://docs.platformio.org/en/latest/ide/clion.html
- https://community.platformio.org/t/official-platformio-plugin-for-jetbrains-clion-ide/10653
Once CLion is setup run, platformio project init --ide clion
to refresh and rebuild all CMake targets