@@ -87,7 +87,7 @@ AdafruitIO_Feed *frontDoor = io.feed("front-door");
8787// `motion-detector` feed
8888AdafruitIO_Feed *motionFeed = io.feed(" motion-detector" );
8989// `home-alarm` feed
90- AdafruitIO_Feed *alarm = io.feed(" home-alarm" );
90+ AdafruitIO_Feed *homeAlarm = io.feed(" home-alarm" );
9191// 'tvoc' feed
9292AdafruitIO_Feed *tvocFeed = io.feed(" tvoc" );
9393// 'eco2' feed
@@ -106,7 +106,7 @@ void setup() {
106106 io.connect ();
107107
108108 // attach a message handler for the `home-alarm` feed
109- alarm ->onMessage (handleAlarm);
109+ homeAlarm ->onMessage (handleAlarm);
110110 // subscribe to lighting feeds and register message handlers
111111 indoorLights->onMessage (indoorLightHandler);
112112 outdoorLights->onMessage (outdoorLightHandler);
@@ -159,7 +159,14 @@ void loop(){
159159void playAlarmAnimation () {
160160// plays the alarm piezo buzzer and turn on/off neopixels
161161 Serial.println (" ALARM TRIGGERED!" );
162- tone (piezoPin, 220 , 2 );
162+
163+ #if defined(ARDUINO_ARCH_ESP32)
164+ // ESP32 doesn't use native tone() function
165+ ledcWriteTone (piezoPin, 220 );
166+ #else
167+ tone (piezoPin, 220 , 2 );
168+ #endif
169+
163170 for (int i=0 ; i<JEWEL_PIXEL_COUNT; ++i) {
164171 strip.setPixelColor (i, 255 , 0 , 0 );
165172 }
@@ -295,4 +302,4 @@ void getTime() {
295302 Serial.print (minutes);
296303 Serial.print (" :" );
297304 Serial.println (seconds);
298- }
305+ }
0 commit comments