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 #6: Listening to the Alarms
  • 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: 30 Apr 2017 12:09 AM Date Created
  • Views 822 views
  • Likes 3 likes
  • Comments 4 comments
  • audio sensor
  • seeed studios
  • node.js
  • grove
  • intel edison
Related
Recommended

[Upcycle It] WiFi Connected Smoke Detector #6: Listening to the Alarms

vlasov01
vlasov01
30 Apr 2017
<< Previous

Project Index

Next>>

 

Connectivity alternatives

 

My initial idea was to connect Edison directly to the smoke detector. But I've read a post by Peter Scargill mentioned early by mcb1

In this post Peter was talking about Alarm Smoke Notifier, which is using audio signal instead of embedded connection. I've analyzed pros and cons of both options.

CriteriaAudio Link
Embedding
Coding complexityMedium (separating noise from detector sound)High (power mode complexity)
Energy budgetSeparate power sourceNegative impact on battery life for a detector not connected to power external source
Detector impactNo impactNeed to solder cables. May loose warranty on detector. May be prohibited by law in some jurisdictions.
CablingNo new cablingCabling is required to connect Edison board to detector
EstheticNo change (Edison board can be placed anywhere in the same room with detector)Additional cables and board may have a negative impact
CostAdditional low cost audio sensor. One device may able to connect several smoke detectors in the same room.Cabling and fixture. Need to connect to each smoke detector.

After this analysis I've decided to start with the Audio Link option.

 

Edison meets Grove Starter Kit for Arduino

 

Grove Starter Kit for Arduino includes audio sensor. It took just a couple of minutes to connect parts. Then I've tested it with Spectrum Analyzer. I've followed the instruction and it worked very well right away. I as well added a LED as indicator and a switch button. I'm planning to use it latter for automatic calibration to reduce number of false positives as different smoke detectors may have different audio signature. The distance between smoke detector and microphone plays role as well.

image

 

Detector Interface Coding

 

I've used Libmraa to interface node.js program with the analog audio sensor. The same library has been used in the Spectrum Analyzer. This C/C++ library has as well bindings to Java and Python. The initial programming of the detector interface module was pretty straightforward as I used a tutorial from Seeed. But it took some time to manually adjust thresholds and other parameters. So I hoping to automate this process.

try {
    console.log(require.resolve("mraa"));
    
    // libmraa - Low Level Skeleton Library for Communication
    var mraa = require('mraa');
    // Analog audio sensor attached to pin 0
    var audio = new mraa.Aio(0);
    // Set the audio threshold
    var threshold = 470;
    // Wait before trigger alarm to reduce false positives
    var audioCounter = 0;
    var state = false;

    // Run the function to start out
    processAudio();

    client.publish(kitchen_alarm_topic, 'true', {qos: 2, retain: true}, function() {
        console.log("Kitchen alarms detector connected");
        client.publish(kitchen_alarm_state_topic, 'false', {qos: 2, retain: true});
    });
    
} catch(e) {
    console.error("mraa is not found");
        client.publish(kitchen_alarm_topic, 'false', {qos: 2, retain: true}, function() {
        console.log("Kitchen alarms detector not connected");
    });
    //process.exit(e.code);
}


// Declare the sound check function
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 treashold ' + level + ' counter ' + audioCounter);
    setTimeout(processAudio, 100);
    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 {
    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);
  }
}

 

Summary

Now I have to programs - one central monitor, which can work with multiple detectors and detector interface. They communicate over MQTT

 

To Do List

  • Resolve issue with switching alarm state off to fast.
  • Build and test disconnect a connected appliance scenario.
  • Find a box to fit the board.
  • Implement auto calibration of alarm sound detection algorithm.
  • Publish code to my github repo.
  • Sign in to reply

Top Comments

  • vlasov01
    vlasov01 over 8 years ago in reply to mcb1 +2
    Thank you a lot for your input and feedback! As you can see on the picture I haven't used any filters other then in my code. I had the same idea that smoke alarm is very loud and can be easily picked up…
  • vlasov01
    vlasov01 over 8 years ago in reply to DAB

    Yes, I'd like to address dynamic threshold, but to your point it is not a high priority.

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

    Thank you a lot for your input and feedback!

     

    As you can see on the picture I haven't used any filters other then in my code. I had the same idea that smoke alarm is very loud and can be easily picked up. But when I start testing I've realized that for the audio sensor my steps were as loud as the alarm coming from the detector. So I've used some aggregation over time to distinguish them.

     

    Sergey

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

    Nice update.

     

    There are ways to make a dynamic threshold, but for now I think you are safe using a simple threshold value.

     

    DAB

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

    This is a good solution to overcome the issues you've highlighted, and ensure it can be applied in many juristictions.

     

     

    It made me think about the imbedded solution and what it achieves with regard to "Fail to Safety".

     

    Unless the basic parts of the detector have an internal mechanism to check and they extend it out, the only thing you can check for is power.

    We use wired devices at work and they hold a relay energised until they go off, or they lose power, so they are as Fail to Safe as they can be.

    They get tested at intervals to ensure they detect smoke, which is as much as you can do.

     

     

    Battery powered detectors have a low power warning, which usually goes off in the early hours of the morning, either to annoy you, or because it's colder (I'm still convinced it's the first reason)

    Here in NZ there are TV adverts to change the battery whenever Daylight savings change, which may change as 10 yr battery models become the norm.

     

    As long as you detect the low power warning beeps, then imbedding the device doesn't give you any additional benefits as far as "Fail to Safety" goes.

     

     

    Medium (separating noise from detector sound)

    It's an extremely loud and penetrating noise, so hopefully with a little filtering and reduced gain, it should easily be detectable over most noise.

     

    We have another TV advert about the benefits of a noisy beeping device v someone shouting at you in your sleep.

    IMO it's a little too subtle and many people will miss the real message, but in reality the sound is very distinctive.

     

    Mark

    • Cancel
    • Vote Up 0 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