Soundsensor



  • 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);
    }```

  • Mod

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



  • 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


  • Admin

    @davedeluxe said:

    #define SND_SENSOR_ANALOG_PIN 0

    Shouldn't this be A0 ?



  • Yes of course.
    I thouht that means A0



  • I´ve changed it to #define SND_SENSOR_ANALOG_PIN A0
    but the result is the same 😞


  • Mod

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



  • 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


  • Mod

    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.


Log in to reply
 

Suggested Topics

  • 8
  • 7
  • 1
  • 1
  • 90
  • 44

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts