Skip navigation

This is the final blog on my project for this challenge. The videos I am attaching is of the finished project. The first video is of the finished project description, showing the different parts put together. The second video is of it working in the vehicle. I am very happy how it turned out and that it works so well. I feel it will make a difference the way we drive and more aware of how tired we are while driving. This will also work well to stop distracted driving by alerting you when you aren't paying attention.

 

There are many I want to thank so if I missed anyone I apologise. First is our sponsor STMicroelectronics with Duratool, without them this challenge wouldn't have been possible. I want to thank Element14 for all their support and backing. I want to thank the members for all their help in making my project better. I want to especially thank my wife Claudia and kids Chrystal and Nicholas for putting up with being ignored for the past few weeks (Chrystal did help when she had time!! Thank you honey!!)

 

So here it is:

 

 

Thanks to everyone who followed my project

 

Dale Winhold

Hello everyone,

 

This is my second to last post on this challenge. Everything is now complete except for the vlog on the project working in the vehicle. Below are pictures of the project on my computer desk and the code for the Nucleo. I programmed the Nucleo with the Arduino IDE which worked perfectly (almost, there were a few little bugs). Please leave any questions or comments below.

 

Note: There are 2 tilt sensors that will be attached to the drivers head to sense if they are nodding off. The first is set at a warning angle and the second is set at a full alert angle (I will demonstrate this in my final vlog). Thank you DAB for the idea!!

 

Note 2: I had to delete the heart rate sensor as I couldn't get it working correctly.

 

Thank you for following

 

Dale Winhold

 

 

 

 

 

 

 

 

 

#include <f401reMap.h>

int vibPin = pinMap(5);
int tiltPinB = pinMap(6);
int tiltPin = pinMap(7);
int ledPin = pinMap(8);
int ledPinB = pinMap(9);
int soundPin = pinMap(10);
int soundPinB = pinMap(11);
int buzzerPin = pinMap(1);
int wheelPin = pinMap(12);

int tilt = 0;
int tiltB = 0;
int sound = 0;
int soundB = 0;
int vib = 0;
int wheel = 0;

void setup() {
  
  pinMode(ledPin, OUTPUT);
  pinMode(ledPinB, OUTPUT);
  pinMode(tiltPin, INPUT);
  pinMode(tiltPinB, INPUT);
  pinMode(soundPin, INPUT);
  pinMode(soundPinB, INPUT);
  pinMode(vibPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(wheelPin, INPUT);
}

void loop() {
  
  tilt = digitalRead(tiltPin);
  tiltB = digitalRead(tiltPinB);
  sound = digitalRead(soundPin);
  soundB = digitalRead(soundPinB);
  vib = digitalRead(vibPin);
  wheel = digitalRead(wheelPin);
 
  if (tilt == HIGH)

  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(250);
  }

  if (tiltB == HIGH)

  {
    digitalWrite(ledPinB, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(250);
  }

  if (sound == HIGH)

  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(500);
  }

  if (soundB == HIGH)

  {
    digitalWrite(ledPinB, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(500);
  }

  if (vib == HIGH)

  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(750);
  }

  if (wheel == HIGH)

  {
    digitalWrite(ledPinB, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(500);
  }

else
  
  {

    digitalWrite(ledPin, LOW);
    digitalWrite(ledPinB, LOW);
    digitalWrite(buzzerPin, LOW);
 
   
  }
}

Well, we are getting close to the end of this challenge. This has been a great learning experience and I have really enjoyed it.

 

For my project to be finished up I only have a bit of programming to complete as well as the road test to make the final video blog. Below I have a layout of how the sensors are placed throughout my vehicle.

 

 

I have deleted the acknowledge button and any advanced warning alerts. First the acknowledge button was deleted as the program is set up to stop the alert when the issue is corrected. Second the advanced warning alerts were deleted because they would cause distracted driving and would be to late for the driver to take action.

I really hope my project can progress into a publically available system for anyone to use.

 

Dale

In the past week I have been doing a lot of programming for the sensors It has been a bit of a learning experience working with the Nucleo-L476RG especially since I have been using the Arduino IDE The main part to remember is to assign the pins in your coding with the code"pinMap So far there has been no issue programming the Nucleo with the Arduino IDE everything is working perfectly

 

Attached is the code I have done so far:

 

#include <f401reMap.h>
#define THRESHOLD 2
const int sigPin = pinMap(7); // Tilt sensor
const int ledPin = pinMap(8); // the number of the LED pin
int noisesense = pinMap(1); // Sound sensor
int touchO = pinMap(2);
int touchI = pinMap(3);
int val = 0;
int valB = 0;
int capI;
boolean sigState = 0; // variable for reading the tilt switch status

void setup()
 {
  Serial.begin(9600);
  
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT); 
  // initialize the tilt sensor pin as an input:
  pinMode(sigPin, INPUT); 
  // initialize the sound sensor pin as an input:
  pinMode(noisesense, INPUT);
}

void loop()
{
  // Capacitance sensor start
  capI = 0; // clear out capacitance measure at each loop
  digitalWrite(touchO, HIGH);  
  int valB = digitalRead(touchI);  // read the input to be checked

  while (valB != HIGH){    
    capI++;    
    valB = digitalRead(touchI);    // re-read the input to be checked 
  }
  delay(1);
  
  digitalWrite(touchO, LOW);      
  Serial.println(capI, DEC);  // print out interval 

  if (capI > THRESHOLD)      
    digitalWrite(ledPin, HIGH);
  else  
    digitalWrite(ledPin,  LOW);
  // Capacitive sensor end
  ////////////////////////////////
    
    
  // read tilt switch value:
  sigState = digitalRead(sigPin);
  
  // read sound sensor
  val = digitalRead(noisesense);// digital interface will be assigned a value of pin 1 to read val
// tilt action
  if (sigState == HIGH)
  { 
    // turn LED on
    digitalWrite(ledPin, LOW); 
    
  } 
  else
  {
    // turn LED off:
    digitalWrite(ledPin, HIGH); 
  }

  // Sound action
  
   if (val == HIGH)
  { 
    // turn LED on  
    digitalWrite(ledPin, LOW); 
      
  } 
  else
  {
    // turn LED off:
    digitalWrite(ledPin, HIGH); 
  }

}




 

The code above controls the sound, tilt and capacitive touch sensors. I still require to code for the heart, vibration and temperature sensors as well as the speaker. Once I am completed the coding for the remaining sensors I will be ready for live testing in the vehicle. So far this challenge has been a lot of fun and a great learning experience. I am very confident that I will be finished by the completion date of this challenge.

 

Thank you for reading and following my blogs

 

Dale W

Programming the Nucleo STM32L476

 

I have found it a bit confusing programming the Nucleo in the IDE's suggested from the site. I am use to the Arduino IDE as it is fairly easy to use. So, I found a way to program the Nucleo with the Arduino IDE. This was created by Srihari Koripalli who deserves all the credit for this.

 

Below is how it is done:

 

  • Open the Arduino IDE
  • Go to the "File" menu
  • Go to "Preferences"
  • Under "Additional Boards Manager URLs" enter the link below:

 

https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/STM32/package_stm_index.json

 

 

 

  • Go to "Tools" menu, Click on "Board" then Click on "Boards Manager"

 

  • Scroll down until you find the "STM32 Core" Package by ST-Microelectronics and install it. This will take a bit of time to install.

 

That is it for this part

 

  • Next download the PinMap for the Nucleo Board to the Arduino IDE

 

https://github.com/sriksh9/Nucleo-PinMapping-for-Arduino

 

The PinMap is technically for the f401 board, but is the same for the L476 and does work

 

  • Put the downloaded folder into the Arduino Library Folder (My directory is "C:\Program Files (X86)\Arduino\libraries")

 

  • Next you will have to change the Board in the IDE to the correct Nucleo board by going to "Tools" - "Board" - Select the correct board type "Nucleo-64"

 

  • Then select "Board Part Number" - Select "Nucleo L476RG" - Finally select the correct "Port" the board is attached to

 

This quick program blinks a light from "Pin D2" on the board (PinMap 1)

 

#include 
int a = pinMap(1); //pinMap(Mapped Pin) - for mapped pin refer the attacted image
void setup()
{
  pinMode(a, OUTPUT);
}
void loop()
{
  digitalWrite(a, 1);
  delay(500);
  digitalWrite(a, 0);
  delay(500);

}

 

I want to thank Srihari Koripalli for coming up with this!!

 

I hope this helps others with the programming of the board. It works great!!

 

Dale W

 

 

 

For this weeks blog I am going over the sensors I am using to bring this project together. I was very happy to have all my sensors arrive yesterday as my project would be useless without them.

 

Below is a picture and brief explanation of each sensor I am including in the project:

 

 

So lets start from the top:

 

Big sound sensor - This will be placed at the rear of the vehicle to pick up car horns. If the driver is sleeping at a traffic light and didn't hear the horn, the computer will alert the driver with vibrations and a louder interior sound.

 

Small sound sensor - This will be attached to a hat that the driver wears and will be located so it can pick up driver sounds like snoring.

 

Digital temperature sensor - Checks for car interior temperature. To high of a temperature will increase drowsiness so this will alert you when the temperature hits the warning level.

 

Ball switch sensor - This is going to be located on the dash of the car. If you swerve or hit the rumble cuts in the road this will set of the alarm.

 

Tilt switch sensor - This will be located on the drivers hat. If the driver is to nod off this will cause the alarm to go off.

 

Heartbeat sensor - Keeps track of the drivers heart rate. If the heart rate slows, this is an indication of getting dangerously tired.

 

 

 

As you can see there are a lot of sensors to check the drivers behavior and level of tiredness. I feel very confident this project will save lives, whether it is used for fatigue alert or even distracted driving, it is worth having this in your car.

 

I plan to do another post this week with more pictures and coding.

 

Dale Winhold

Hi everyone,

 

For Blog #4 I am attaching the code for the steering wheel touch sensor. Like I mentioned this is for the Arduino and it will be made to run on the Nucleo (When I get the Nucleo working). I am also blogging about the other parts of my project I have been working on.

 

First the code:

 

#include <CapacitiveSensor.h>

CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8); // 2M resistor between pins 4 & 8, pin 8 is also the sensor pin with the wire to the steering wheel
void setup()                    
{
   cs_4_8.set_CS_AutocaL_Millis(0xFFFFFFFF);
   Serial.begin(9600);
   pinMode(7,OUTPUT);
   pinMode(9,OUTPUT);
}
void loop()                    
{
 long sensor1 =  cs_4_8.capacitiveSensor(50);
    Serial.println(sensor1);  
   if(sensor1 >= 300) // Sensor being touched - No alerts
   {
    digitalWrite(7,LOW);
   }
   else{ // Sensor not touched - Alert activated
    digitalWrite(7,HIGH); // LED lit and alarm activated until sensor touched
    tone(9,500);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,1000);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,500);
    delay(100);
    noTone(9);
   }  
}



The other sensors I am working on are as follows:

 

Tilt sensor: This suggestion is from DAB (Thank you for this!!). This sensor will be attached to a head band and will sense if your head tips forward due to nodding off. This is a serious indication that you must stop driving. Attached is the code.

 

int ledPin = 13;               
int switcher = 3;                 
void setup() {
  pinMode(ledPin, OUTPUT);      
  pinMode(switcher, INPUT);      
}
void loop() {
  if (digitalRead(switcher) == HIGH) 
    digitalWrite(ledPin, HIGH);   // Turn on LED and sound alert when the sensor is tilted
    tone(9,500);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,1000);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,500);
    delay(100);
    noTone(9);
  else
    digitalWrite(ledPin, LOW);    // Turn off LED and sound alert when the sensor is not triggered
}

 

 

Loud sound sensor:

This is to alert you if someone is honking their horn at you or any other loud noises. This could be from falling asleep at a traffic light and other outside warnings. This sensor will be placed in the trunk of the vehicle.

 

int soundPin = 10; 
int soundVal = HIGH; 
boolean bAlarm = false;
unsigned long lastDetectTime; 
int soundTime = 500; // Number of milli seconds to keep the sound alarm high
void setup ()
{
  Serial.begin(9600);  
  pinMode (soundPin, INPUT) ; // input from sensor
}
void loop ()
{
  soundVal = digitalRead (soundPin) ; // read the sound alarm time

  if (soundVal == LOW) // If we hear a sound
  {

    lastDetectTime = millis(); // record the time of the sound alarm
    if (!bAlarm){
    tone(9,500);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,1000);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,500);
    delay(100);
    noTone(9);
      bAlarm = true;
    }
  }
  else
  {
    if( (millis()-lastDetectTime) > soundTime  &&  bAlarm){
      bAlarm = false;
    }
  }
}

 

Next will be creating the vehicle vibration sensor and the vibrating wrist band alert. I am wanting to do the heart rate monitor but I don't think I will be receiving the sensor before the project is to be completed. Hope you enjoyed this update on my project.

 

Thank you

 

Dale W

 

Note: This system can be also used for distracted driving as well (Another very dangerous driving issue)

This weeks update:

 

First, I am having real issues with the Nucleo-64. I downloaded the drivers and got everything loaded. When I plug in the board the red LED just flashes, nothing else. The jumpers are all in the right location. My computer won't recognise the board, I have tried in my other computers and I have the same results. Any help would be appreciated.

 

Here is what I have been working on. I created the steering wheel sensor, if you are not touching the wheel it sets off an alarm and an LED lights up. Below is a layout of the set-up and a video of it running.

 

 

 

 

 

 

I hope you enjoyed this update.

 

Thank you

Dale W

Hello everyone,

 

This weeks update is a flow chart on how the computer will work with the sensors and how I plan the programming. I am also going to blog about the software I plan to use to program the Nucleo.

 

First the flow chart:

 

 

I hope this is fairly easy to follow (it makes sense to me anyway ) The Nucleo is at the heart of my design and everything branches off from there. I will have the WiFi module and the sensor board attached. I will be making a sensor for the steering wheel to make sure your hands are on the wheel. There is also going to be a heart rate monitor a vibration sensor and a confirmation light and button. With this all put together and the programming done right it will sense how tired you are and let you know when to stop driving.

 

As for  programming the Nucleo I will first use Mbed OS 5 https://os.mbed.com/  This looks to be what I need to use and I will also review the ease of this.

 

A quick note on the Nucleo-64 and the expansion boards. They came nicely packaged and with a card of info on each one. The Nucleo-64 and expansion boards are very impressive and will more then do the job I am set out to do. The only thing missing is a USB type A to mini B cable. Luckily I have a lot laying around but it could have been awkward if I didn't.

 

That is it for this blog, next one will be on the programming and making of some sensors.

 

Thank you

Dale W

Fatigue Alert System

First I want to thank our sponsor STMicroelectronics for the kit they are providing and giving us the opportunity to develop our dream. I want to thank Element14 for making this all possible.

 

My reason for this project

 

I have a severe sleep disorder and this makes the possibility of falling asleep while driving a greater possibility. In Canada, fatigue is a factor in up to 21 per cent of motor vehicle collisions,
resulting in about 400 deaths and 2,100 serious injuries every year. At 21 per cent, fatigue would rank as the third highest cause of collisions behind impaired driving and speed. This is an issue that needs to be addressed.

 

Recognize the signs of fatigue:

  • loss of concentration
  • drowsiness
  • yawning
  • slow reactions
  • sore or tired eyes
  • boredom
  • irritability
  • missing road signs
  • drifting out of your lane
  • nodding off

 

Here is my project:

 

Create a device that monitors your body to assess if you are too tired to drive. If you are already driving, it will alert you when you are too tired to drive. The device will
monitor your heart rate, oxygen level and breathing to assess your alertness as well it will also monitor your driving. If the device finds your alertness
isn’t what it should be it will notify you that you shouldn’t be driving. This will be done by alerting you through Bluetooth to the radio or vibration to
make you aware of your situation.

 

The development boards being used from STMicroelectronics:

 

STM32 Nucleo-L476RG Board

Sensor Expansion Board - X-NUCLEO-IKS01A2X-NUCLEO-IKS01A2X-NUCLEO-IKS01A2

Bluetooth LE Expansion Board - X-NUCLEO-IDB05A1X-NUCLEO-IDB05A1X-NUCLEO-IDB05A1

 

Below is a basic layout of my project:

 

Project picture.png

 

Explanation of each:

 

  • Heart rate monitor and oxygen monitor
    • As you get tired your heart rate drops. This will alert the computer you are over tired. If your heart rate
      drops then suddenly spikes, this is more serious as it could be caused by nodding off for a second or two.
    • The oxygen monitor will tell the computer if your oxygen level is where it should be, being low on oxygen can
      cause drowsiness.
  • Vibrating buzzer
    • This will be one of the ways to alert you if you are falling asleep
  • Alertness button
    • If you are drowsy the computer will require you to check in by lighting an LED. When the LED is lit you must press
      the alertness button to confirm you are alert. This acts as another check by seeing how long it takes to react to the light, the longer it takes the drowsier
      you are.
  • Vibration sensor
    • This sensor will be located on the dash board. It will sense if the vehicle is drifting onto the side of the road.
  • Bluetooth notification
    • This will be another way for the computer to notify you of your situation.
  • Accelerometer and temperature sensor
    • The accelerometer will tell the computer of the speed you are traveling at. Any sudden changes will cause the computer to alert you.
    • Temperature sensor is used to record the internal vehicle temperature. Being too warm cause’s drowsiness, this would cause the computer to alert you of this as well.

 

There may be more added or changed, we have to wait and see how it goes!!

 

I hope everyone enjoys following along while I create my project.

 

Thank you,

 

Dale Winhold