Wen-Liang Lin
Published © GPL3+

Breathing Tests Measure

Use to record somebody's blow strength. Since without calibration it is relative value.

BeginnerWork in progress2 hours58
Breathing Tests Measure

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
×1
Axial Fan, 12 VDC
Axial Fan, 12 VDC
×1
Resistor 100k ohm
Resistor 100k ohm
×1
Pmod OLED
Digilent Pmod OLED
×1
Capacitor 10 µF
Capacitor 10 µF
×1
Bridge Rectifier Diode, Glass Passivated
Bridge Rectifier Diode, Glass Passivated
×1
Jumper wires (generic)
Jumper wires (generic)
×8

Software apps and online services

Arduino IoT Cloud
Arduino IoT Cloud
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Easy connect

Code

Blow.ino

Arduino
Upload data to Arduino IoT Cloud
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Blow_Strength_Record"
  https://create.arduino.cc/cloud/things/48864b4f-9d4c-4b83-8f13-587dcfd3b8cc 

  Arduino IoT Cloud Properties description

  The following variables are automatically generated and updated when changes are made to the Thing properties

  float total_blow;

  Properties which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/
#include "arduino_secrets.h"
#include "thingProperties.h"

long ADsum,ADavg;
int ADread,read_cnt;
int Blow_Flag;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(115200);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information youll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  delay(10);
  ADread = analogRead(A0);
  Serial.print(ADread);
  Serial.print(",");
  Serial.print(total_blow);
  Serial.print(",");
  Serial.print(blow_AVG);
  Serial.print(",");
  Serial.println(read_cnt);
  if(ADread>20)
  {
    Blow_Flag = 1;
    ADsum += ADread;
    read_cnt++;

  }
  else if( ADread <= 20 && Blow_Flag == 1 && read_cnt>20)
  {
    total_blow = ADsum;
    blow_AVG = ADsum / read_cnt;
    Blow_Flag = 0;
    read_cnt = 0;
    ADsum = 0;
    //Serial.println(total_blow);

  }
  else if( ADread < 20 )
  {
    Blow_Flag = 0;
    read_cnt = 0;
    ADsum = 0;
  }
  
}

Credits

Wen-Liang Lin

Wen-Liang Lin

16 projects • 21 followers
Hi, I am momososo

Comments

Add projectSign up / Login