IoT Mailbox Detector
In this tutorial we will be going over how to use a Wia Dot One with a Ultrasonic Distance Sensor detect mail and then send a notification to your phone.

Figure 1
Requirements
Preparation
- 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
Creating the code Project
- Now you need to set up a code project so we can code the distance sensor to create an event which has the distance that the sensor reads.
- We will then in the flows take the distance and decide if there is mail or not and decide if a notification should be sent or not.
- If you would like to also graph this data into a widget go here.
#include <WiFi.h>
#include <Wia.h>
#include <Arduino.h>
const int trigPin = 17;
const int echoPin = 16;
long duration;
int distance;
Wia wiaClient = Wia();
void setup() {
WiFi.begin();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
delay(2500);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration*0.034/2;
if(distance < 25)// if mail goes through then the distance jumpes below 25cm
{
wiaClient.createEvent("Proximity (cm)",distance);
delay(3000);
}
}
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 Proximity (cm) which is what we named the event in the code and select your Dot One from the list as seen in figure 2.

Figure 2
* Now click update and drag a Send Notification node, found in the Action tab under Wia and in the settings select Space for the type and enter the message you want to be sent in the notification as seen in figure 3.

Figure 3
- Lastly connect all the nodes as seen in figure 4, turn on the flow and you're all set!

Figure 4