A Harvard Health study claims that corona has the ability to last in the air for up to 3 HOURS! So stay away from coughs.
In the time of this great pandemic, we can all admit that staying home for more than half a year is a difficult task to accomplish. Many of us miss our old, outdoor habits and begin to exercise such as running, biking, or playing basketball. And believe me, there is absolutely nothing wrong with outdoor exercises, however, the problem is that 9/10 times you don't see people wearing masks. Because of this unwise decision, we must now take the burden of keeping an ear out for coughing which is one of the most common ways of corona transmission. Although many people may say, "how do you not hear a loud cough when it is so distinct?", however, in the midst of a workout, your brain fogs up by trying to concentrate on that last rep or that last mile or that gaming winning shot. The majority of people also love listening to music which additionally blocks your hearing senses for coughs nearby.
This raises the question of how do we stay safe from coughs? Introducing a product that takes the stress off your ears and listens to coughs for you... the Cough Detector! This product is able to differentiate between background noise and coughs to accurately warn the user when a cough is heard.
Why is this Product Useful?- It's wearable
- It's lightweight
- Effective in crowds, during exercise, and hangable outside doors
- Can attach outside doors and know through a Bluetooth app if someone has coughed
- Can even teach you to be more aware of your surroundings
1. Create an account through at Edge Impulse (we will come back to this later)
2. Download Node.js
3. Download Arduino CLIby scrolling down and clicking the correct version that is compatible with your computer.
4. Extract your newly downloaded file to a location of your choice
5. Copy the address of the folder
6. Search for Edit the system environment variables in your computer search bar and click on it
7. Select Environment Variables located near the bottom under the Advanced tab
8. Select Path (in the first box) and Edit... (right underneath it)
9. SelectNew (located on the left side) and paste the copied address with your extracted file
10. Now search for and open Command Prompt and paste:
npm install -g edge-impulse-cli @serialport/terminal
11. Download the latest Edge Impulse firmware, after it finishes downloading
12. Extract the files once again and double click on the file that is specific to your type of computer (MAKE SURE YOUR ARDUINO NANO 33 BLE SENSE IS PLUGGED IN)
(If you're windows, click on flash_windows.bat
)
(If you're mac, click on flash_mac.command
)
(If you're Linux, click on flash_linux.sh
)
13. After it is done flashing, double click the reset button on your Arduino Nano 33 Ble Sense (the orange light will starting fading in and out)
14. Open a new Command Prompt and copy/paste edge-impulse-daemon
(answer the questions the computer asks you)
15. Switch back to your Edge Impulse tab and click on Devices (second tab on the right side) to make sure your Arduino board is connected to Edge Impulse
16. Click on Data Acquisitions and it is now time to sample test data
- Sample at least 10 cough recordings and name all coughing labels "cough" (the more the better)
- I recommend coughing in different ways such as singular, double, triple coughs, clearing the throat, different distances, or coughing under the arm
- If you get tired, search or use cough sound effects such as https://www.youtube.com/watch?v=85456FmaSh4
https://www.youtube.com/watch?v=Qp09X74kjBc
- Don't forget to change up the lengths of each recording and the loudness of each recording
- Next Sample at least 10 background noise recordings and name all background noises "background" (the more the better)
17. Next, click on Create Impulse under Impulse Design
18. Click on MFCC (under Create Impulse) and then Generate Features (at the top tab) and finally GenerateFeatures again (at the bottom) *this might take a while*
19. Next, Click on NN Classifier (under MFCC)
*feel free to fiddle around with Live Classification to test your cough detection*
20. Finally, click on Deployment and only select the Arduino Library (as we will be adding sensors to let the user know a cough has been detected) and lastly click on Build at the bottom.
21. Open your Arduino IDE and do Sketch > Include Library > Add.ZIP library as well as File > Examples > Your project name > nano_ble33_sense_microphone
22. Then go to Tools > Board: "Board Name" > Boards Manager > type "nano 33 ble" in search bar and install
Coding22. Declare your vibration pinnumber at the top (int vibPin = 5;)
23. Add pinMode(vibPin, OUTPUT); in the void setup()
24. Replace *located in the void loop()*
for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++)
{
ei_printf(" %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);
}
with
for (size_t ix = 1; ix < EI_CLASSIFIER_LABEL_COUNT; ix++)
{
Serial.print( result.classification[ix].value);
float Data = result.classification[ix].value;
updateReadings();
if (Data > 0.50)
{
Serial.print("Cough Detected");
vibration();
}
}
(The variable Data is related to how recognizable the cough is. If Data is greater than 0.50, it has over a 50% chance of being a cough. Feel free to change the number to your liking.)
25. Create a method called void vibration() and paste:
void vibration()
{
digitalWrite(vibPin, HIGH);
delay(2000);
digitalWrite(vibPin, LOW);
delay(2000);
}
(The vibration motor will buzz for 2 seconds)
Setting Up Bluetooth to your Phone26. Open your App Store or Google Play and download nRF Connect
27. Add and Declare these new variables to your code
#include <ArduinoBLE.h>
const int UPDATE_FREQUENCY = 2000; // Update frequency in ms
const float CALIBRATION_FACTOR = -4.0; // Temperature calibration factor (celcius)
int previousValue = 0;
long previousMillis = 0; // last time readings were checked, in ms
BLEService environmentService("181A"); // Standard Environmental Sensing service
BLEIntCharacteristic tempCharacteristic("2A6E", // Standard 16-bit Temperature characteristic
BLERead | BLENotify); // Remote clients can read and get updates
28. Copy and Paste in the void setup()
pinMode(LED_BUILTIN, OUTPUT); // Initialize the built-in LED pin
if (!BLE.begin())
{ // Initialize BLE
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("Nano33BLESENSE"); // Set name for connection
BLE.setAdvertisedService(environmentService); // Advertise environment service
environmentService.addCharacteristic(tempCharacteristic); // Add temperature characteristic
//environmentService.addCharacteristic(humidCharacteristic); // Add humidity chararacteristic
BLE.addService(environmentService); // Add environment service
tempCharacteristic.setValue(0); // Set initial temperature value
//humidCharacteristic.setValue(0); // Set initial humidity value
BLE.advertise(); // Start advertising
Serial.print("Peripheral device MAC: ");
Serial.println(BLE.address());
Serial.println("Waiting for connections...");
29. Copy and Paste in the void loop()
BLEDevice central = BLE.central(); // Wait for a BLE central to connect
// If central is connected to peripheral
if (central) {
Serial.print("Connected to central MAC: ");
Serial.println(central.address()); // Central's BT address:
// Turn on the LED to indicate the connection:
digitalWrite(LED_BUILTIN, HIGH);
while (central.connected()) {
long currentMillis = millis();
// After UPDATE_FREQUENCY ms have passed, check temperature & humidity
if (currentMillis - previousMillis >= UPDATE_FREQUENCY) {
previousMillis = currentMillis;
updateReadings();
}
}
// When the central disconnects, turn off the LED
digitalWrite(LED_BUILTIN, LOW);
Serial.print("Disconnected from central MAC: ");
Serial.println(central.address());
}
30. Add this new method called void updateReadings() which will regularly send a notification to the nRF Connect App every time the data points change
void updateReadings() {
if (result.classification[ix].value != previousValue) { // If reading has changed
ei_printf("Cough Probability: ");
ei_printf(result.classification[ix].value);
tempCharacteristic.writeValue(result.classification[ix].value); // Update characteristic
previousValue = result.classification[ix].value; // Save value
}
}
31. Now open the nRF Connect App and make sure you are under the Scanner tab and tap the connect button on Nano33BLESENSE (refresh if needed)
- Swipe right and in the "Cough Recognition" area, tap on the circle with the three arrows pointing down
(Compiling will take an incredibly long amount of time!)
Time for Assembly32. You want to get your Soldering Iron and safely and carefully solder about 35 inches of wire
33. Connect the ends of the wire to Ground Pin and Pin 5
(the Vibration Motor's red wire connects to the Pin)
(the Vibration Motor's blue wire connects to the Ground)
34. Use tape to secure the Vibration Motor on to your Rubber Holder Case (preferably use a hot glue gun)
35. Lastly, take your string and loop the string through the two circles on the Arduino Board. This will act as our wearable necklace for a secure fit.
You Are Now Ready To Go Outdoors And Be Safely Protected By The Cough Detector!
Comments