Andrew BerryJack DuffSpivey
Published

IoT Mailbox Detector

In this tutorial, we will go over how to use a Wia Dot One with a Ultrasonic Distance Sensor to detect mail and then send a notification.

IntermediateFull instructions provided18 minutes1,495

Things used in this project

Hardware components

Wia Dot One
Wia Dot One
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
Wia Micro USB Cable
Wia Micro USB Cable
×1

Software apps and online services

Wia
Wia

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Dot One and Sensor Case

This is the main compartment of the case for the sensor and Dot One

Case Lid

This is the lid of the case that holds the sensor and Dot One

Code

Mailbox Detector Dot One Code

C/C++
This is the code that should be deployed to your Dot One
#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);  
  }
}

Credits

Andrew Berry

Andrew Berry

25 projects • 4 followers
Jack Duff

Jack Duff

32 projects • 3 followers
Man of the people. Champion of the downtrodden. Marketing magic @ Wia. Becoming a maker by learning, building, and exploring
Spivey

Spivey

82 projects • 49 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