<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[What is the correct message type for a security sirene? And how can I hookup a 9V piezo buzzer to the arduino?]]></title><description><![CDATA[<p dir="auto">I'm trying to figure out the correct message type for a MySensors Security Sirene node.</p>
<p dir="auto">I tried V_TRIPPED with S_SOUND but the sensor didn't appear in Domoticz. I'm using V_LIGHT again, but it Domoticz sees that as a light as expected. But I want it to appear as a sirene.</p>
<pre><code>// Declare messages that will be sent to the MySensor's gateway.
MyMessage sireneMsg( SIRENE_CHILD_ID, V_LIGHT ); // trying to figure out what type to use to make it known as a security sirene..???
</code></pre>
<p dir="auto">I present it as a light, but I'm looking for a S_SOUND</p>
<pre><code>gw.present( SIRENE_CHILD_ID, S_LIGHT, "Sirene" );
</code></pre>
<p dir="auto">As of now I hooked a 3V piezo buzzer  to the Arduino Pro Mini 3.3V which is not really loud. Which is okay for now, I'll be using it as an extra wakeUp alarm. But also help on how to hook up a 9V Piezo to an arduino will be much appreciated.</p>
<p dir="auto">Thanx in advance</p>
<p dir="auto">Here's the code so far.</p>
<pre><code>/**
 * MySensors RoomSensor with piezo alarm for audio feedback, like weather alarm when there's a huricane alarm.
 * Version 1.0b
 * Created 10-10-2015
 * Author  by Theo
 *
 * Version history:
 * 10-10-2015 Initial version
 *
 * Parts used:
 * - Arduino ProMini 3.3V
 * - 3V Piezo buzzer GND connected to Arduino's GND and the + connected to PIN 5.
 *
 * Design decision's
 * - none at the moment.
 */

#include &lt;MySensor.h&gt;
#include &lt;SPI.h&gt;

#define PIEZO_PIN 5       // The arduino pin to which the piezo buzzer is attached
#define SIRENE_CHILD_ID 0 // The child ID of the sirene.
#define PIEZO_ON_DURATION  600
#define PIEZO_OFF_DURATION 500
#define SIRENE_TONE 200   // The tone of the SIRENE. We use PWM so choose from 0 to 255 (0 is off b.t.w.)

// define sketch name and version
#define SN "Sirene"
#define SV "1.0"

boolean sireneOn = false;
unsigned long nextPiezoEvent = 0;
boolean piezoOn = false;

// Declare and initialize objects.
MySensor gw;

// Declare messages that will be sent to the MySensor's gateway.
MyMessage sireneMsg( SIRENE_CHILD_ID, V_LIGHT ); // trying to figure out what type to use to make it known as a security sirene..???

/**
 * Initialize variables, arduino pins etc before we start the main loop.
 */
void setup() {
#ifdef DEBUG
  Serial.begin( 115200 ); // only debug to serial monitor during development
#endif
  // setup a connection to the MySensor's gateway and request an ID if we do not have one yet.
  gw.begin(incomingMessage);
  gw.sendSketchInfo(SN, SV);
#ifdef DEBUG
  Serial.println( "Radio is connect right." );
#endif

  gw.present( SIRENE_CHILD_ID, S_LIGHT, "Sirene" );
  gw.sendBatteryLevel( 100, false ); // Let the Domotica controller know that we're a 100% powered sensor.
  gw.request( SIRENE_CHILD_ID , V_LIGHT ); // request current state. An alarm might be active.
  
  pinMode( PIEZO_PIN, OUTPUT);
}
/**
 * The next Sirene Event has occured. Determine next step.
*/
void handlePiezoEvent() {
  unsigned long curMS = millis();
  if ( piezoOn == true ) {
    digitalWrite( PIEZO_PIN, 0 );
    nextPiezoEvent = curMS + PIEZO_OFF_DURATION;
    piezoOn = false;
  }
  else {
    analogWrite( PIEZO_PIN, SIRENE_TONE );
    nextPiezoEvent = curMS + PIEZO_ON_DURATION;
    piezoOn = true;
  }
}

/** 
 * Main loop of the sketch.
 */
void loop() {
  if ( sireneOn == true &amp;&amp;  millis() &gt;= nextPiezoEvent ) { // only play a tone when there's an actual alarm.
      handlePiezoEvent();
  }
  gw.wait( 50 ); // Just wait 50ms not really necessary but give the arduino some rest. It's working really hard for us. Besides it calls gw.process() which we need for handling incomming messages.
}

/**
 * Call back handler, for handling messages send by the MySensors gateway
 */
void incomingMessage(const MyMessage &amp;message) {
  if ( message.type == V_LIGHT ) {
    if ( message.sensor == SIRENE_CHILD_ID ) {
      sireneOn = message.getBool();
      #ifdef DEBUG
        Serial.println( "Sirene state changed to " + (String)sireneOn );
      #endif
      if ( sireneOn == false ) {
        analogWrite( PIEZO_PIN, 0 ); // turn off the noise
      }
      else {
        nextPiezoEvent = 0;
        piezoOn = false;
      }
    }
  }
}
</code></pre>
]]></description><link>https://forum.mysensors.org/topic/2155/what-is-the-correct-message-type-for-a-security-sirene-and-how-can-i-hookup-a-9v-piezo-buzzer-to-the-arduino</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 06:11:19 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/2155.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 10 Oct 2015 16:01:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to What is the correct message type for a security sirene? And how can I hookup a 9V piezo buzzer to the arduino? on Sun, 11 Oct 2015 07:30:16 GMT]]></title><description><![CDATA[<p dir="auto">No clue :(</p>
]]></description><link>https://forum.mysensors.org/post/22620</link><guid isPermaLink="true">https://forum.mysensors.org/post/22620</guid><dc:creator><![CDATA[sundberg84]]></dc:creator><pubDate>Sun, 11 Oct 2015 07:30:16 GMT</pubDate></item><item><title><![CDATA[Reply to What is the correct message type for a security sirene? And how can I hookup a 9V piezo buzzer to the arduino? on Sat, 10 Oct 2015 20:10:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sundberg84" aria-label="Profile: sundberg84">@<bdi>sundberg84</bdi></a> Thank you very much for your fast reply. I'll install that beta release on one of my spare Raspberry Pi's, because I'm afraid to install it on my production version. It gave me a hard time when I did that a couple of weeks ago. But MySensors support in the Beta sounds really great. Do you happen to know when there will be a new stable version of Domoticz??</p>
]]></description><link>https://forum.mysensors.org/post/22592</link><guid isPermaLink="true">https://forum.mysensors.org/post/22592</guid><dc:creator><![CDATA[TheoL]]></dc:creator><pubDate>Sat, 10 Oct 2015 20:10:36 GMT</pubDate></item><item><title><![CDATA[Reply to What is the correct message type for a security sirene? And how can I hookup a 9V piezo buzzer to the arduino? on Sat, 10 Oct 2015 17:02:46 GMT]]></title><description><![CDATA[<p dir="auto">Assuming you have the latest beta when you look at github s_sound should be supported:</p>
<p dir="auto">S_SOUND = 33,					//Sound sensor	V_LEVEL(in dB), V_TRIPPED, V_ARMED<br />
(<a href="https://github.com/domoticz/domoticz/blob/master/hardware/MySensorsBase.h" rel="nofollow ugc">https://github.com/domoticz/domoticz/blob/master/hardware/MySensorsBase.h</a>)</p>
<pre><code>	V_ARMED = 15,					//Armed status of a security sensor. 1 = Armed, 0 = Bypassed	S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER, S_WATER_LEAK, S_SOUND, S_VIBRATION, S_MOISTURE

	V_TRIPPED = 16,					//Tripped status of a security sensor. 1 = Tripped, 0 = Untripped	S_DOOR, S_MOTION, S_SMOKE, S_SPRINKLER, S_WATER_LEAK, S_SOUND, S_VIBRATION, S_MOISTURE
</code></pre>
<p dir="auto">The Sensor wont appear with the presentation. You need to send the tripped or armed status at startup.</p>
]]></description><link>https://forum.mysensors.org/post/22573</link><guid isPermaLink="true">https://forum.mysensors.org/post/22573</guid><dc:creator><![CDATA[sundberg84]]></dc:creator><pubDate>Sat, 10 Oct 2015 17:02:46 GMT</pubDate></item></channel></rss>