loading

UPDATE: See step 3.

Long story (TL;DR below):
Some time ago I wrote a small bash-script on my computer which would scan the network for registered devices and compare their hostnames against a list with associated names. Every time a device would log-in or out the network I'd get a notification. Like this I'd have an idea who is home (not only is it sometime nice to know who is home to ask them if they want to join a meal or such, but it can also potentially help you avoid awkward situations). Problem is, that this method is not very reliable. Unfortunately some devices don't reply pings (e.g. smartphones) and seem to go into some power-save mode are thus not reliably detectable with commands like nmap . I tried to overcome this by requiring at least 10 negatives before finally announcing that the device left the network. All in all it worked, but slowly, unreliably and not very nicely. Also I wanted to be able to check who is home, without opening my computer.

So I had these ESP8266s lying around - and wanted to play with them. But I didn't wan't to build the 10120124812th ESP-based weather station or such (why would you want to monitor the weather with your crappy ±2°C thermometer when you can just visit some website anyway?). So the plan was made. Unfortunately it turns out that the ESP seems to not be equipped to properly ping (which was bad to begin with, remember?) let alone do a full-blown network scan. I considered writing some library for that - but since my C++ is very limited, this is my first ESP-project and I'm not a genius with network stuff either I scrapped that idea.

After doing some research, I found out, that my router (brand Fritz!Box) actually has an API! YAY!!!! The protocol is called TR-064. Such an inspiring name, right?

Doing some research into the matter, I found a (rather crappy) documentation online. It took me some time to work it out. I might post a more hands-on instructable in the next days (and how to communicate with/test this API using a browser addon).

Once I understood the API, I started using it from my ESP. Long story short: I got a duck-tape-and-wd40 solution running and doing what I wanted (querying the API for connected devices, compare them to a list of MAC-addresses and switching LEDs accordingly).

But I wanted a more robust and flexible solution and this API has so much more to offer (you can change settings (turn on/off the wifi, change password, open/close the guest wifi, change signal power), restart the router, query the connection speed, ...) - so I decided to create a universal TR-064 library!

TL;DR;
Device that indicates via LEDs who is currently at home. Works great, has no great housing yet (hey - noticed the beta in the title?). Uses SOAP-protocol to communicate with router. Wrote Arduino library to make that happen.

Required knowledge
• Basic Arduino/ESP knowledge
• If you assembled a Blink example with your ESP, you'll be fine!
• If not, you can follow the first two steps of this instructable
• Soldering might come in handy, if you want to leave the breadboard stage
• Some 3D designing an/or woodworking might come in handy for a housing


BOM
• ESP8266 + Development-Board or other TTL connector + cable (around 3€)
• Power Source (~2€)
• A few LEDs and resistors (~1€)
• (Casing)


=> Around 4-6€ for a minimal design. That means for me, that I can easily hang a few around the house.
If you are lazy, you can also use a development-board with included LED's (see step 4 for more detail).

Since I'm a late-comer for the IOT-Contest, I'd doubly appreciate if you'd vote for me (up there ↗ somewhere I guess)!

Github project link [https://github.com/Aypac/Arduino-TR-064-SOAP-Library] for quick reference.

Step 1: Set Up Your Router (optional, But Advised)

The protocol was designed as a general protocol for routers, but I only know that (most) Fritz!Box routers (very common at least in Europe) use it. Don't know about other brands. So I'll assume, that you are using a Fritz!Box. If you can make this work (or fail to do so) on any other router, I'd be happy to add it to this instructable (maybe even start a short compatibility list?).

This step is not necessary, you could also just use your admin account, but that is not advisable for obvious reasons (might be intercepted or extracted from your ESP, you might accidentally change stuff you don't want to, ...) - so I advise you to do it.

Anyway, here we go:

  1. Log in to your Fritz!Box by typing fritz.box in the url-bar of your favourite browser.
  2. Find the page for creating a new FRITZ!Box user (you need to have advanced it should be under System, if you can't find it, try updating you device).
  3. Create a new account as you see in the picture (using a different user name/password!).
  4. Logout.

Step 2: Code

  1. You can get the library from Github.

  2. In the examples you will find a file called home-indicator.ino, which is the code for this project. Place the examples folder in your arduino IDE project home folder and the other folder into the libraries folder in the same project home folder.

  3. (Re)Start you IDE.

  4. Open home-indicator.ino in the IDE and enter your settings. It should be quite obvious what goes where. If you have any questions, let me know!

  5. Now you can compile it and transfer it to your ESP!

Step 3: Hardware (beta)

Yeah... This is the step, where I still need to work some more. But I guess there is enough material in the web to figure something out :)

The setup as in the pictures is just a diode with a ~100Ohm resistor wired to the GPIO{5, 4, 0, 2}, which are the D1, D2, D3, D4 (in that order) pins of my MCU ESP8266 board and the little orange cable taking the cathodes to GND (marked G on my board).

If you are lazy, you can do what you see in the second image. Just use a development-board with included LED's (like the "ESP-202", see pictures - around 3.50-5.00€ including shipping). You can then just hook it to USB power or use the included battery pack, draw a interface on a piece of paper and stick it to the wall. Done.

For this specific board the ports are:

int userPins[numUser] = {5,4,2,14,16};

from top to bottom.

Step 4: Outlook/References

This is what I still plan:

1. Making a nice housing (obviously)
2. Adding a nice GUI for managing users/LEDs/MACs/known devices
3. Improving the library (see Github for that)
4. Fix: sometimes the LEDs react sluggishly (it takes a little until they turn off, after a device left) for no obvious reason
5. Hook the thing up in the hallway and maybe a few more around the house


Would love to get some input from you guys! And as always, it makes me really happy to see others build shit you thought up, so please take the minute to comment and post pictures! :):)

____________________________________________________________

Since I'm somewhat a late-comer for the IOT-Contest, I'd doubly appreciate if you'd vote for me (up there ↗ somewhere I guess)!
____________________________________________________________

Some references

I'll link some stuff here, that might help you:

TR-064 reference
Some guy messing around with the shell and TR-064 (good to get a grasp of the API)
• Harry Potter Wikipedia: Weasley Clock entry
Some guys building a beautiful, but complicated Weasly Clock*

____________________________________________________________

*It's based on an app for your phone which is taking your location. If you are in certain pre-defined areas, the according light on the clock will turn on. For me that was too complicated and had to many places where it could break/fail:

• Apps need to be kept up to date
• Everyone has to use these apps
• And be okay with the impact on privacy
• The app only works with internet connection
• You have to use an intermediate server for interfacing the communication
(unless you want to set-up you esp as server and open you home network for outside traffic - yay, yet another unsafe IOT device directly connected to the internet!)
• The intermediate service might go offline one day/change its API,
• ...You need more software. More software means more places to do an error ;)

But, they did an amazing job and if you want to do something like that, head over to their site, it is really great!

<p>Thanks for sharing</p>

About This Instructable

3,453views

74favorites

License:

More by Razanur:[15min] Weasley Clock / Who is Home Indicator - based on TR-064 (beta) Make Apple headphone in-ear. Make custom sized solar panels 
Add instructable to: