element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog [Upcycle It] WiFi Connected Smoke Detector #10: Addressing False Positives
  • 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: vlasov01
  • Date Created: 29 May 2017 2:11 AM Date Created
  • Views 2040 views
  • Likes 3 likes
  • Comments 11 comments
  • false positives
Related
Recommended

[Upcycle It] WiFi Connected Smoke Detector #10: Addressing False Positives

vlasov01
vlasov01
29 May 2017
<<Previous

Project Index

Next >>

 

Nobody likes false positives

 

I don't like them too, especially where I have control and can address them. I had two cases in the past 10 days when my connected smoke detector generated false positives. So I decided to address them.

 

Options: Neural networks vs. traditional approach

 

I was doing some machine learning courses in the past and have some ideas how to apply neural networks (NN) for sound detection. NN is the most popular way to recognize voice. But with all advantages of NN it is still considered a "black box" approach.

Alternatively I've collected statistics from the detector logs by using system journal.

journalctl -b|grep node|grep above >/tmp/logs.csv

 

Then I looked in the log at times when alarm was raised (value of the counter above 50).

 

May 18 18:09:31 gate1 node[306]: Above threshold 489 counter 10
May 18 18:09:31 gate1 node[306]: Above threshold 497 counter 18
May 18 18:09:31 gate1 node[306]: Above threshold 492 counter 26
May 18 18:09:32 gate1 node[306]: Above threshold 488 counter 36
May 18 18:09:32 gate1 node[306]: Above threshold 487 counter 44
May 18 18:09:32 gate1 node[306]: Above threshold 488 counter 52

 

May 20 22:56:20 gate1 node[306]: Above treashold 478 counter 10
May 20 22:56:21 gate1 node[306]: Above treashold 485 counter 17
May 20 22:56:21 gate1 node[306]: Above treashold 493 counter 23
May 20 22:56:21 gate1 node[306]: Above treashold 485 counter 32
May 20 22:56:23 gate1 node[306]: Above treashold 486 counter 28
May 20 22:56:23 gate1 node[306]: Above treashold 492 counter 37
May 20 22:56:23 gate1 node[306]: Above treashold 489 counter 46
May 20 22:56:24 gate1 node[306]: Above treashold 492 counter 53

 

The log file only contains entries when the microphone captures a loud signal above predefined threshold, which is now defined as 470. The signal gets measured every 100 ms. If the signal above 470 the counter get increased by 10. If it is below 470, it gets decreased by 1 while its value is above 0. And when the counter is above 50 it is raising alarm, Here is the code of my audio processing function in Node.js:

 

function processAudio(){
  // read the value to start off
  var level = audio.read();

  // If the sound is higher than the threshold, make the request
  if(level >= threshold){
    audioCounter=audioCounter+10;
    console.log('Above threshold ' + level + ' counter ' + audioCounter);
    if(audioCounter>50){
        state = true;
        setTimeout(processAudio, 60*1000); //wait 60 seconds before activating it again
        client.publish(kitchen_alarm_state_topic, 'true', {qos: 2, retain: true}, function() {
            console.log('Audio alarm detected ' + level + ' counter ' + audioCounter);
        });
        audioCounter=0; //reset counter
    }
    else {
        setTimeout(processAudio, 100);
    }
  } else {
    if(audioCounter>0){
        audioCounter--;
    }else if(state){
        state = false; //switch off alarm
        client.publish(kitchen_alarm_state_topic, 'false', {qos: 2, retain: true}, function() {
            console.log('Audio alarm switched off ' + level + ' counter ' + audioCounter);
        });
    }
    setTimeout(processAudio, 100);
    //console.log(level + ' counter ' + audioCounter);
  }
}

 

In both cases of false positives value of the counter was 52 and 53. So I've changed the threshold to be just above these values and set it to 53 instead of 50 (line 9).

I've pushed the code, restarted the detector service and verified its status after restart.

root@gate1:~# sudo systemctl restart smoke-detector
root@gate1:~# sudo systemctl status smoke-detector
● smoke-detector.service - SmokeDetectorApp
   Loaded: loaded (/lib/systemd/system/smoke-detector.service; enabled)
   Active: active (running) since Sun 2017-05-28 22:06:03 EDT; 9s ago
 Main PID: 5603 (node)
   CGroup: /system.slice/smoke-detector.service
           └─5603 /usr/bin/node /home/root/detector.js

May 28 22:06:03 gate1 systemd[1]: Started SmokeDetectorApp.
May 28 22:06:06 gate1 node[5603]: /home/root/node_modules/mraa/build/Release/mraa.node
May 28 22:06:06 gate1 libmraa[5603]: libmraa version v1.6.1 initialised by user 'root' with EUID 0
May 28 22:06:06 gate1 libmraa[5603]: edison: Arduino board detected
May 28 22:06:06 gate1 libmraa[5603]: libmraa initialised for platform 'Intel Edison' of type 2
May 28 22:06:06 gate1 node[5603]: MRAA Version: v1.6.1
May 28 22:06:06 gate1 node[5603]: Kitchen alarms detector connected

 

I'll keep looking to see if false positive will reappear again. But in this case it seems the simple approach of adjusting thresholds based on statistical data is good enough.

  • Sign in to reply

Top Comments

  • vlasov01
    vlasov01 over 8 years ago in reply to mcb1 +2
    It allows to have a time perspective. It will take a 10 measurements over 1 second without any loud sounds to completely negate one that is above threshold. A smoke alarm generates sound with some constant…
  • Workshopshed
    Workshopshed over 8 years ago +1
    >If the signal above 470 the counter get increased by 10. If it is below 470, it gets decreased by 1 while its value is above 0. How about a simple hysteresis ? That should help detect a continually loud…
  • DAB
    DAB over 8 years ago in reply to mcb1 +1
    I too used to laugh until I finally understood that it was a very useful way to combine a state machine with more flexible detection points. The result is a system that smoothly transitions states without…
Parents
  • mcb1
    mcb1 over 8 years ago

    If the signal above 470 the counter get increased by 10. If it is below 470, it gets decreased by 1 while its value is above 0

    Curious why you raise it by 10, but only reduce by 1.

     

    I'm presumming that when the alarm does go off, the numbers are very large.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • vlasov01
    vlasov01 over 8 years ago in reply to mcb1

    It allows to have a time perspective.

    It will take a 10 measurements over 1 second without any loud sounds to completely negate one that is above threshold.

     

    A smoke alarm generates sound with some constant time intervals.My approach allows to distinguish a smoke detector alarm from a random noise.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • vlasov01
    vlasov01 over 8 years ago in reply to mcb1

    It allows to have a time perspective.

    It will take a 10 measurements over 1 second without any loud sounds to completely negate one that is above threshold.

     

    A smoke alarm generates sound with some constant time intervals.My approach allows to distinguish a smoke detector alarm from a random noise.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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