close-circle
Close

zmote configuration with REST APIs in Windows Powershell

A project log for zmote

Wi-Fi Universal Remote using the ESP8266

Mohan Yenigalla 11/27/2015 at 13:420 Comments

First thing you need to do with a new zmote is to connect it to your Wi-Fi router. Every time zmote is powered ON, it configures itself as Wi-Fi access point (AP) so that one can connect to it (no password required) and configure it for connection with your router. Accesspoint (aka. hotspot) willshow up as zmote_*******. In this example it is zmote_00f2e958.

Power on zmote and Connect your pc/laptop to zmote_******** access point (hotspot)

When connected to zmote through its AP interface, zmote can be accessed at 192.168.4.1 IP.

Let us find out its MAC address, which we will need later:

> Invoke-RestMethod -Uri 192.168.4.1/api/wifi/mac

   ap_mac                                       sta_mac

   ------                                       -------

   1a-fe-34-f2-e9-58                        18-fe-34-f2-e9-58

Now, let's configure zmote to connect to our Wi-Fi router with SSID router and password sample.

> Invoke-RestMethod -Uri "192.168.4.1/18-fe-34-f2-e9-58/api/wifi/connect" -Method Put -ContentType 'application/json' -Body "{""ssid"":""router"",""password"":""sample""}"

status
------
OK

Note that we have used sta_mac from earlier API here. This value is required in many APIs to make sure that our commands reach intended zmote (in case there are dynamic changes in IP by DHCP server).

After above command, zmote will configure itself to connect to router, will restart and get an IP from the DHCP server running on router. It may take 15-30 seconds for it to get connected and register itself with zmote.io server.

Power off and power on zmote.
Disconnect pc/laptop from zmote_******** access point (hotspot).

After this point, you are ready to use zmote with www.zmote.io or looking at the rest of rest REST API.

Thank you Dougles for the time saving tip on complex double quotes needed http://douglastarr.com/using-powershell-3-invoke-restmethod-with-basic-authentication-and-json/

Discussions