Skip to content

A working breathalyzer with a custom PCB and developed with rtfm-rs

License

Notifications You must be signed in to change notification settings

markhakansson/embedded-breathalyzer

 
 

Repository files navigation

E7020E Embedded System Design

Project designed and written in Rust in conjunction with the E7020E Embedded System Design course at Luleå University of Technology.

alt text

Project description

The purpose of this project is to create a breathalyzer to estimate the blood alchohol content (BAC) in a person's breath. To do this a prototype PCB will be designed connected to an alchohol sensor, a button to start the breathalyzer and a small display to show the alchohol permille detected. Over LoRa this device will also alert a ThinkBoard server that this user's breath contains too much alchohol, i.e. they are about to pass out.

The goal is to package this is in a simple and safe to use way for users to interact with. The data that is sent to the ThinkBoard server could be seen as sensitive data and would be ideal to encrypt it before transmitting it.

Limitations

There is no sure way to calibrate this device as the project team does not have access to a real industry-grade breathalyzer. Thus this device can only very roughly estimate the BAC of a person's breath and SHOULD NOT be trusted in any serious situation where it is critical to know the real BAC.

Components / shopping list

Requirements

  • Rustup 1.14.0+
  • rustc 1.31.0+ (stable)
  • GNU ARM embedded toolchain (check your package manager or manually install it)
  • OpenOCD
  • Nucleo dev board (in programming mode)
  • Breathalyzer PCB

Setup

rustc & cargo

Install rustup by following the instructions at https://rustup.rs.

Then install the following tools for rustup and cargo:

rustup component add llvm-tools-preview
rustup target add thumbv6m-none-eabi
cargo install cargo-binutils

Linux

Below are the absolute minimum packages you will need for Linux. Names might vary depending on your distribution, you might need to install it manually if you can't find it using your distribution's package manager.

openocd
arm-none-eabi-gdb
gcc / gcc-c++ (as well as their respective dev packages)
llvm-8.0 (and its dev package)

MacOS

All the tools can be install using Homebrew:

brew cask install gcc-arm-embedded

brew install openocd

PCB

The design of the breathalyzer can be found in /pcbdesign. It was created and can be opened with KiCad. The program has been written especially for that design.

Build instructions

First confirm that the correct runner is chosen in .cargo/config, as the gdb package name might be different depending on you OS. Then build the project

cargo build --features="radio"

Flashing

Connect to the card using the Nucleo F401RE dev board as a programmer with the given configuration

openocd -f openocd.cfg

Then build the project and flash the card

cargo run --features="radio" --release

Authors

License

Licensed under the MIT license. See LICENSE for details.

About

A working breathalyzer with a custom PCB and developed with rtfm-rs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 98.2%
  • GDB 1.8%