Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Soundsensor

Soundsensor

Scheduled Pinned Locked Moved My Project
9 Posts 3 Posters 1.9k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davedeluxe
    wrote on last edited by
    #1

    Hi,
    I have a Soundsensor (http://www.satistronics.com/images/l/1255/3807.jpg) to determine if a smoke detector has been activated.
    My Sketch is the following but I´m not the best in Coding so maybe someone can help me because it doesn´t work :/
    Output: TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:97

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    #define MY_RADIO_NRF24
    #include <SPI.h>
    #include <MySensors.h>  
    #include <Wire.h>
    
    #define CHILD_ID 12   // Id of the sensor child
    #define SND_SENSOR_ANALOG_PIN 0
    
    unsigned long SLEEP_TIME = 5; // Sleep time between reads (in seconds)
    
    MyMessage msg(CHILD_ID, V_VOLUME);
    int lastSND = -1;
     
    void presentation()  
    { 
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Rauchmeldermelder", "1.0");
    
      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID, S_CUSTOM);
    
       pinMode(SND_SENSOR_ANALOG_PIN, INPUT);
    
    }
    
    void loop()     
    {     
     
     
      int SND = map(analogRead(SND_SENSOR_ANALOG_PIN), 0, 1024, 100, 0);
     
      if (SND != lastSND) {
        Serial.println(SND);
        send(msg.set(SND));
        lastSND = SND;
      }
    sleep(3000);
    }```
    mfalkviddM 1 Reply Last reply
    0
    • D davedeluxe

      Hi,
      I have a Soundsensor (http://www.satistronics.com/images/l/1255/3807.jpg) to determine if a smoke detector has been activated.
      My Sketch is the following but I´m not the best in Coding so maybe someone can help me because it doesn´t work :/
      Output: TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:97

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      #define MY_RADIO_NRF24
      #include <SPI.h>
      #include <MySensors.h>  
      #include <Wire.h>
      
      #define CHILD_ID 12   // Id of the sensor child
      #define SND_SENSOR_ANALOG_PIN 0
      
      unsigned long SLEEP_TIME = 5; // Sleep time between reads (in seconds)
      
      MyMessage msg(CHILD_ID, V_VOLUME);
      int lastSND = -1;
       
      void presentation()  
      { 
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Rauchmeldermelder", "1.0");
      
        // Register all sensors to gateway (they will be created as child devices)
        present(CHILD_ID, S_CUSTOM);
      
         pinMode(SND_SENSOR_ANALOG_PIN, INPUT);
      
      }
      
      void loop()     
      {     
       
       
        int SND = map(analogRead(SND_SENSOR_ANALOG_PIN), 0, 1024, 100, 0);
       
        if (SND != lastSND) {
          Serial.println(SND);
          send(msg.set(SND));
          lastSND = SND;
        }
      sleep(3000);
      }```
      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @davedeluxe looks like it is working to me. Why do you think it does not work?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        davedeluxe
        wrote on last edited by
        #3

        The output is everytime the same:
        TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:97
        and when I play with the potentiometer this comes out:
        TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:1

        In FHEM I got the following values:
        mapReading_value112 12 value1
        mapReading_value212 12 value2
        mapReading_value312 12 value3
        mapReading_value412 12 value4
        mapReading_value512 12 value5

        setReading_value112 1
        setReading_value212 1
        setReading_value312 1
        setReading_value412 1
        setReading_value512 1
        I don´t know what that means but it´s useless

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #4

          @davedeluxe said:

          #define SND_SENSOR_ANALOG_PIN 0

          Shouldn't this be A0 ?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            davedeluxe
            wrote on last edited by
            #5

            Yes of course.
            I thouht that means A0

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davedeluxe
              wrote on last edited by
              #6

              I´ve changed it to #define SND_SENSOR_ANALOG_PIN A0
              but the result is the same :(

              1 Reply Last reply
              0
              • mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #7

                what is the result of the Serial.println(SND); in your loop?

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  davedeluxe
                  wrote on last edited by
                  #8

                  All I get is this:
                  TSM:INIT
                  TSM:RADIO:OK
                  TSM:FPAR
                  TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                  TSP:MSG:READ 0-0-255 s=255,c=3,t=8,pt=1,l=1,sg=0:0
                  TSP:MSG:FPAR RES (ID=0, dist=0)
                  TSP:MSG:PAR OK (ID=0, dist=1)
                  TSM:FPAR:OK
                  TSM:ID
                  TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
                  TSP:MSG:READ 0-0-255 s=255,c=3,t=4,pt=0,l=2,sg=0:10
                  TSP:ASSIGNID:OK (ID=10)
                  TSM:CHKID:OK (ID=10)
                  TSM:UPL
                  TSP:PING:SEND (dest=0)
                  TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
                  TSP:MSG:READ 0-0-10 s=255,c=3,t=25,pt=1,l=1,sg=0:1
                  TSP:MSG:PONG RECV (hops=1)
                  TSP:CHKUPL:OK
                  TSM:UPL:OK
                  TSM:READY
                  TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
                  TSP:MSG:SEND 10-10-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
                  TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
                  TSP:MSG:READ 0-0-10 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                  TSP:MSG:READ 0-0-10 s=255,c=3,t=6,pt=0,l=1,sg=0:M
                  TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=11,pt=0,l=17,sg=0,ft=0,st=ok:Rauchmeldermelder
                  TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0
                  TSP:MSG:SEND 10-10-0-0 s=12,c=0,t=23,pt=0,l=0,sg=0,ft=0,st=ok:
                  Request registration...
                  !TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=fail:2
                  TSP:MSG:SEND 10-10-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=ok:2
                  TSP:MSG:READ 0-0-10 s=255,c=3,t=27,pt=1,l=1,sg=0:1
                  Node registration=1
                  Init complete, id=10, parent=0, distance=1, registration=1
                  1
                  TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:1
                  97
                  TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:97
                  1
                  TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:1
                  97
                  TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:97
                  1
                  TSP:MSG:SEND 10-10-0-0 s=12,c=1,t=35,pt=2,l=2,sg=0,ft=0,st=ok:1

                  1 Reply Last reply
                  0
                  • mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #9

                    So the sensor seems to only get readings of 1 and 97. These readings are then sent by MySensors. If you are expecting anything else than 97 and 1, you'll need to investigate the sensor.

                    Try printing the raw analog value (without map) and see if that gives a clue.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    30

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.1k

                    Posts


                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • MySensors
                    • OpenHardware.io
                    • Categories
                    • Recent
                    • Tags
                    • Popular