In this tutorial, we will be going over how to use the Wia Dot One and a Grove sound sensor to create a noise monitor which sends you a notification if there is any really loud noise for a few minutes.
You can use this if you have an Airbnb and you want to make sure that your guests are not being too loud and disturbing your neighbors.
Figure 1
Requirements- Wia Dot One Buy yours here
- Grove Sound Sensor Buy yours here
- MicroUSB cable Buy yours here
- Account on Wia
- Account at Wia
You will need to be registered and /or logged in to your Wia account at https://www.wia.io/. - Set up your Dot One
You will need to have a set up Dot One and you can find the tutorial on how to do that Here. - Set up your code project
Now you will need to create a space and then a block project on your Wia Dashboard
- Now you need to set up a code project so we can code the distance sensor to create an event whenever there is sound above a certain level for a specific time frame.
- We will then make a flow which takes that event and sends a notification to your phone.
- Below is the code for this portion follow along the comments to understand and feel free to try and write it yourself!
#include <WiFi.h>
#include <Wia.h>
const int pinAdc = 33; // input pin from the sensorint
startTime = 0; // used to track time
int averageSound = 0; // this is the average in a certain time frame
int iterations = 0; // this is used to calculate average
Wia wiaClient = Wia(); // this is necessary for the Dot One to funtion properly
void setup()
{
WiFi.begin(); // this connects the Dot One to the wifi
delay(2500);
}
void loop()
{
long sum = 0; // this sums data
for(int i=0; i<32; i++)
{
sum += analogRead(pinAdc); //this adds each reading from the input pin to sum
}
averageSound += sum; // this adds up the sums which later is converted to an average
iterations++; // this is used to know how much you should divide average by
if(millis() - startTime >= 300000) // this occurs every five minutes
{
averageSound = averageSound/iterations; // computing average
averageSound >>= 5; // shifting average for cleaner data
// 700 is a number I selected for being too loud but you can raise or lower it based on your own needs
if(averageSound >= 700) //if the average sound is over 700 then create an event
{
wiaClient.createEvent("Noise Warning!");
delay(1000);
}
iterations = 0; // reset iterations
startTime = millis(); // start the timer again
}
delay(50);
}
Wiring up your Dot One- Now that you have your code written you can wire up your Wia Dot One with the Grove Sound Sensor.
- You will need to connect the corresponding pins on the sensor to the Dot One as displayed in figure 2
Figure 2
- Note: NC stands for No Connection so if you want you don’t need to do anything with that that cable.
- Now look at figure 3 and 4 to see where the pins listed in figure 2 are on your Dot One and Grove Sensor
Figure 3
Figure 4
Setting up your Flow- Now you will need to create a new flow and drag an Event Created node, found under the Trigger tab under Wia, into the workspace.
- The name the event Turn it down which is what we named the event in the code and select your Dot One from the list as seen in figure 5.
Figure 5
- Now click update and drag a Send Notification node, found in the Action tab under Wiaand in the settings select Space for the type and enter the message you want to be sent in the notification as seen in figure 6.
Figure 6
*Now connect the two nodes as seen in figure 7 and turn the flow on and you’re all set!
Figure 7
Comments