element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
IoT on Wheels Design Challenge
  • Challenges & Projects
  • Design Challenges
  • IoT on Wheels Design Challenge
  • More
  • Cancel
IoT on Wheels Design Challenge
Blog IOT on Wheels Design Challenge - Fatigue Alert System (Blog #7)
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dwinhold
  • Date Created: 5 Nov 2017 12:34 AM Date Created
  • Views 417 views
  • Likes 3 likes
  • Comments 1 comment
  • alert
  • on
  • wheels
  • stm32
  • Design
  • dwinhold
  • fatigue
  • challenge
  • iot
  • system
  • nucleo
Related
Recommended

IOT on Wheels Design Challenge - Fatigue Alert System (Blog #7)

dwinhold
dwinhold
5 Nov 2017

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

  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +1
    Good start Dale, Have you considered using fuzzy logic for the 3-axis sensor? You might want to look at say a 2-degree variance for alert, 2 to 5 degree variance for semi-drowsy and anything more than…
  • DAB
    DAB over 8 years ago

    Good start Dale,

     

    Have you considered using fuzzy logic for the 3-axis sensor?

     

    You might want to look at say a 2-degree variance for alert, 2 to 5 degree variance for semi-drowsy and anything more than 5 degree variance as bad.

     

    Now I have not looked at how you translate the accelerometer data to degree variances, but I am sure there is some code where someone has looked at tilt angle verses acceleration detection.

     

    Just a thought,

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube