Skip to content

Ask your phone if you can park in your single car garage with a DIY sensor

License

Notifications You must be signed in to change notification settings

SrGMC/is-there-a-car-in-the-garage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Is there a car in the garage?

Is there a car in the garage? is a small Arduino webserver that uses an ultrasonic sensor to tell if there's a car or not in the garage. It's to be used in conjunction with a Apple Shortcuts or the equivalent in Android.

It is originaly programmed to detect a car in a closed space, but it can be used to detect any static object in a closed space

Prerequisites

This program is tested and used on a Wemos D1 Mini board. Even though other boards are not tested, this program should run without problems on boards with a ESP-8266EX chip.

What's new?

  • v1.1:
    • master branch: Initial release
    • whitelist-ip: Implemented an IP whitelist to bypass authentication for an specific IP
  • v1.0: Initial release

Installation

Server and sensor

If you want whitelist functionality, checkout the whitelist-ip release.

  • Download is-there-a-car-in-the-garage.ino and open the file in the Arduino IDE.
  • Edit the values between " for both the username and password in the following lines. You shouldn't use the default values as it can be a security issue
const char* username = "arduino";
const char* password = "arduino";
  • Edit int source[4] = {192,168,1,2}; to whitelist an IP of your choice. Requests coming from this IP will bypass authentication.
    • This is useful when you want to access the sensor from outside your network but want an specific server from your network (i.e. Homebridge server/plugins) to allow retrieving status because it does not support authentication.
  • Optional: Uncomment and edit the following line if you want to assign the server a fixed IP Address. This can be useful if you want to access the sensor from the outside world and have the same address everytime it reboots:
    • IPAddress(192,168,1,14): IP Address to assign. In this example, 192.168.1.14
    • IPAddress(192,168,1,1): IP Address of the gateway (or router)
    • IPAddress(255,255,255,0): Subnet mask
//wifiManager.setSTAStaticIPConfig(IPAddress(192,168,1,14), IPAddress(192,168,1,1), IPAddress(255,255,255,0));

Arduino IDE

  • Press compile and verify, and wait for the program to load onto the board.
  • Connect pins the following pins on the ultrasonic sensor to corresponding pins in the board:
Sensor pin Board pin
Trig D1
Echo D2
Vcc 5V
Gnd G
  • Power the board up and connect to the wireless network called "garage-sensor". A captive portal should pop up. Use this to set your home's wireless credentials for the Arduino to connect. It should look like this:

Captive portal

  • Your server should be fully functioning. If this is the only server that you'll run open to the internet, open port 80 to the Arduino Server IP on your router. If not, use a reverse proxy in one of your servers.

Reverse proxy

Nginx

Add the following to your sites-enabled configuration:

location /<Path> {
    proxy_pass http://<IP Address>/;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, max-age=0';
    add_header Cache-Control 'post-check=0, pre-check=0';
    add_header Pragma 'no-cache';
}

Change <Path> and <IP Address> accordingly. For example, accessing the server at 192.168.0.13 through the /home path:

location /home {
    proxy_pass http://192.168.0.13/;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, max-age=0';
    add_header Cache-Control 'post-check=0, pre-check=0';
    add_header Pragma 'no-cache';
}

iOS Shortcut

  • Download this Shortcut and fill in all the setup answers.

    • The default username and password is arduino. You shouldn't use the default values as it can be a security issue
    • You can edit the shortcut and its values by pressing on (...)

    Shortcut

Android action

TODO

Usage

Web

You can access the server through a web browser by navigating to the server's IP Address and introducing your credentials. The web page will show true (if there's a car) or false (if there isn't a car)

Login Result

iOS

On iOS 13, you need to ask Siri the name of the shortcut for it to be run. When the shortcut finishes, Siri will speak to you if there is or not a car. You can change what Siri says with the initial setup questions.

On iOS up to iOS 12, you'll need to setup a Siri Shortcut through the shortcut settings. Then, when the shortcut finishes, Siri will speak to you if there is or not a car.

Alternatively you can run the shortcut by pressing on it on the Shortcut app or Widget and Siri will tell you if there is or not a car.

Acknowledgements

About

Ask your phone if you can park in your single car garage with a DIY sensor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages