IoT Mailbox Detector
Read moreIn this tutorial, we will be going over how to use a Wia Dot One with a Ultrasonic Distance Sensor to detect mail and then send a notification to your phone.
Figure 1
Requirements- Wia Dot One Buy yours here
- Ultrasonic Distance 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 OneYou 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 projectNow 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 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;
ong 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
Jack Duff
32 projects • 8 followers
Man of the people. Champion of the downtrodden. Marketing magic @ Wia.
Becoming a maker by learning, building, and exploring
Spivey
82 projects • 59 followers
Tourist in a Tutu || US Born || Melbourne/Mexico/California Raised || New Yorker at ❤️ || SF to Dublin to be COO of Wia the best IoT startup
Comments