The "WifiSecureAccess" provides an IoT system that can be used for Home/Industrial
Automation, Instrumentation, and remote data collection and logging.
Electrical equipments and Sensors can be connected to the smart device. You can, then, configure the smart device to activate (put on or off) an equipment using a smartphone from anywhere remote or automatically or on a timer schedule, or based on the data sensed by the sensors. You can also use this for collecting data and send to a remote computer for either data logging or detailed data analysis. This is a complete management system which includes the management platform, an inexpensive smart device(buy) and a mobile app (Apple, or Android).
Users can configure these devices such that an equipment (such as electric switches, electric lights, motors, and so on) can be activated either by scanning a QRCode or NFC Tag or by Google Home Assistant or Amazon Alexa, or from remote by pressing a button on the smart phone. Automatic actuation of the equipment can also be configured either when a condition is sensed by a sensor or periodically when a timer times out. It is also possible to configure automatic controls to activate an equipment connected to one smart device depending on the values sensed by a sensor connected to another remote smart device. Remote data collection and data logging can also be configured.
The controller is compatible with Google Home, Nest and Amazon Alexa. So, these can be integrated with your smart home and can work along with all your other devices connected to smart home.
This smart device is a part of our IOT system which has an architecture as shown in Fig 1.
The device comes with a firmware pre-programmed. Firmware can be updated online.
To use this smart device to monitor sensors, and/or to activate equipments and external devices, no programming is required.
Everything can be done by configuring on our web interfaces.
Our IOT system comes with an app for smart phones.
The ports of these smart devices can be activated either by scanning its QR Code/NFC Tag or by pressing a button on the smart phone or using Google Home Assistant or Amazon Alexa.
The smart device is an ESP8266 based hardware with a powerful WiFi.
The device has an AC-To-DC power supply onboard.
It can also take a 12V power instead of an AC power.
The device has one relay with NO, NC and COM available at its connector.
The relay pins are rated 240VAC/10A. So, it can be used to put ON/OFF AC source as well.
The device also has internally operated Buzzer and LEDs.
This smart device also has two digital inputs (D6 and D7) and one analog input Vin. D6 and D7 can be used to read any ON/OFF signals such as limit switches, motion sensors and so on. These can also be used to read digital data from temperature/humidity sensors, ultrasound sensors and so on. This smart device is compatible with almost all sensors that are available for Arduino. The analog input Vin can be in the range of 0 through 3.3V. The device also has a Reset button and a Factory-Reset button
This smart device can be purchased either from eBay or from Amazon. It will be available through other sources in the future. Search for WifisecureAccess in eBay or Amazon.
The following figure shows various components that can be interfaced to access controller. As this picture shows, it can control an electric light, an electric motor, an electric fan, a heavy duty relay, solenoids, and so on. The output current must be limited to 10A. If you are using internal 12V power to drive anything, the current must be less than 1A (preferably 500ma). If you want to activate any equipment of higher ampere, you can connect another heavy duty relay between the controller and that equipment. You can cable only one electrical equipment per controller.
Any type of sensors can also be connected to the controller. It has an analog input and so any sensor that gives an analog output in the range 0 to 3.3V can be connected to it. In addition, any sensor that is compatible with arduino can also be connected to the controller. Examples are mition sensor, temperature humidity sensor, ultrasound sensor and so on. You can cable multiple sensors to a controller.
The controller can be opened by inserting a flat screw driver in the side hole of its plastic box and twisting it. Use a correct flat screw driver that has a flat end approximately as wide as the side hole on the box. Insert it slightly and twist open. You need to apply some force when twisting. You will hear a cracking sound when the latch comes out and the box opens. That sound is normal. Do not pull apart both parts of the box too fast, as there is a cable inside the box connecting the switch on the top lid to the PCB on the bottom part. When opening the box, try not to break that cable. The only time that you need to open the box is when you install it and do the cabling
Pictures below show all the connectors and the labels on each connector. These will help when cabling and installing the controller.
2 Initial Setup and Configuration
In this section, we will describe how to set up the device and how to configure it so that it works as per your requirements.
2.0 Applying Power to the Controller
The controller can take either 110VAC power, or 240VAC, or 12VDC power. Depending on what power is available at the location where you are installing the controller, you connect any one of the power source to the controller. Fig 2C shows the internal connectors and cabling within the smart controller. The controller comes with ac AC cord cabled to the 110/240VAC terminals N and L of connector J2 within the controller. So, if you are using either 110VAC or 240VAC, make sure that the power cable is connected between Neutral (N) and Live (L) terminals of the J2 connector within the controller. Then connect the AC power cord to an AC socket on the wall. However, if you want to use 12VDC power instead of the 110/240VAC power, remove the AC power cord. Then connect 12VDC to the 12Vin and GND terminals of J1 connector (Ref Fig 2D) of the controller. Connecting both AC power at J2 connector as well as 12VDC at J1 connector will not do any harm as there is enough protection on the controller.
Once you connect the power to it, turn on the controller by plugging its power cord to a 110/240VAC socket (or 12VDC, if you have cabled the controller for 12VDC power).
2.1 Setting up the App on your Smart Phone
If you have not downloaded the wifisecureaccess app yet, please download it to your smartphone now.
Search for wifisecureaccess in either Apple Store or Google Play store.
Once downloaded, open the app and press Admin Dashboard. It will prompt you to enter your username and password to login.
If you have not registered yet with https://wifisecureaccess.com, press 'Create NEW Account' button on this page and register.
Follow the prompts and instructions. It needs your email address as user name. You need to set your password. first name, last name and telephone numbers are optional.
Password must have at least 8 characters (maximum 20 characters) and it must contain at least one lower case letter, one upper case letter, one numeric. The system will prompt you for your email verification.
The system uses email address as your username.
It also uses it to send notifications of events in the device, if you have configured the device to send you notifications.
The other two fields "Enable Two Factor Auth' and 'Timezone' will be defaulted to 'No' and 'US/Pacific' respectively. You can enable Two Factor Authentication by selecting 'Yes' for this field, if you want to. When selected 'Yes', a confirmation code will be sent to your email whenever you try to login. This is an additional layer of security for your account. The timezone is your timezone. Select it from the pull-down menu. The default is US/Pacific. Setting this to your timezone will help the system display the times of all your activity in your local time. All these parameters can be changed any time later by clicking 'My Profile' under 'User Admin" in the Dashboard.
Please keep your password confidential to make sure that the device is used by authorised persons only.
Note: The steps of setting up the device and configuring it can be done either using a smart phone or using a computer.
On a computer, you can open a browser and go to https://wifisecureaccess.com/access/index. It will prompt you to log in.
On a smartphone, open the wifisecureaccess app and press on Admin Dashboard in the main scanning page to get to the dashboard.
We recommend that you use a computer for all initial setup and configurations.
However, use your smart phone when you want to activate a device or its ports from remote, or when you need to scan its QR Code or NFC Tag, or when you want to use Google home assistant or Amazon Alexa.
If you are using a smart phone to register, you will see a page similar to Fig 3C. Or, any time in the future, if you open the app and click on the Admin Dashboard, the same display will be shown. You will notice that all the admin menu is collapsed. To see the admin menu, click on the three lines at the top right corner of this page as shown in Fig 3C and 3D.
2.2 Setting WiFi of the Device
There are two ways of setting the WiFi of the device
Using the hotspot of your smart phone
Setting the device as a web server and using a browser (Chrome preferred) on your computer or smart phone. Refer to section 3.5 of this documentation for this method.
Using the HotSpot on your smart phone
If this is a brand new device, its WiFi has been factory reset to the following:
Upon factory reset, the device listens on a WiFi (2.4G) with the following ssid and password:
SSID : MyPhone Password: 12345678
So, when the device is powered ON, it is trying to join this WiFi. Therefore, in order to initially connect to WiFi, you need to setup a mobile hotspot on your smart phone temporarily to this SSID and password so that the device gets connected to internet which will enable you to change its WiFi. Note: (The device is not capable of 5G and so, WiFi must be 2.4G.).
If you are using iPhone, change its Personal hotspot WiFi settings to match the above and put Personal hotspot ON. To change your iphone's SSID, you need to change the name of your phone to MyPhone. This can be done in settings → General → About → Name. To change password, Settings → Personal Hotspot → Wi_Fi Password. Once changed, click on Allow Others to Join so that your Personal Hotspot is ON with this SSID and password. If you are using IPhone 12 and above, you will see a button there named "Maximize Capability". That is normally OFF. You need to turn that ON so that it will work on 2.4GHz.
If you are using an android phone, go to settings → Tethering and Mobile hotspot. Then click Mobile hotspot. Then click on the three dots at the top right and click 'Configure hotspot'. Then change the ssid and password of your mobile hotspot to 'MyPhone' and '12345678'. Note: If your smartphone is capable of 5G hotspot as well as 2.4G, make sure that 2.4G is set on the hotspot of your smartphone, as the device is not capable of 5G. Also, check the Timeout settings of the hotspot. Set it such that it does not timeout too soon while you are using Hotspot. You can set it to Never time-out. After setting it, switch on your mobile hotspot (in the previous menu).
Note: Make sure that the mobile data on your smartphone is turned ON so that the device connected to your hotspot can get access to internet. Also, make sure that the Hotspot stays ON and never times out until you change the WiFi of the device as per the steps in sections 3.3 and 3.4. Your mobile phone must not go into a sleep mode until you change the wifi of your device. For this initial setup, it is important that the device gets connection to internet through the hotspot on your smartphone. If the LED stays flashing blue, that means that it is unable to join the WiFi. If you observe the LED either stays flashing blue with occasional RED, it means that it is unable to connect to the internet after joining WiFi.
Once the personal Hotspot is ON, put on the device, if it is not already ON. You will notice that the device will join that WiFi and connect to internet. You will see in a few seconds that the LED changes colour to RED, and staying RED. If that is not happening, make sure that your personal Hotspot is configured correctly and that it is ON. If this is not happening, there is a problem with the WiFi. You can do a factory reset of the device as explained in section 2.5 of this documentation and try again. If the device is still not joining WiFi, ask for help by Contacting us.
If the device is connected to WiFi and connected to internet, the LED will stay steady RED. Then, you need to take the ownership of this device as explained in section 2.3 below before you can set its WiFi.
2.3 Taking Ownership of the Device
There are two ways in which you can take the ownership of a new device that you just bought. One method is by scanning the QRCode of the device using your smartphone, and the other method is by using a browser on a computer. Before you proceed, make sure that you have turned on the device and it has joined the WiFi of the Hotspot of your smart phone, as explained in the previous section of this documentation.
In the first method. open wifisecureaccess app on your smartphone and go to Scanning page and press Scan QRCode button.
The camera will come ON. Scan the QR code of the device. The QRCode is on the label pasted on the box.
Then follow the prompt. You will be prompted to confirm the buzzer sound as well as the color of the LED a few times to make sure that you have this device in front of you, having connected to internet. If everything is correct, it will assign the ownership of this newly bought device to yourself.
For the second method, open https://wifisecureaccess.com and click on Dashboard. If you are already logged in, you can see a tab "Take Device Ownership" in the sidebar menu. If this is your first device, you will see that on the main page as well. Click on that, and follow the prompt. After getting the confirmation that the device is turned on and connected to internet through its WiFi, you will be prompted to enter the QRCode or Mac address of the device. On the label of the device, you will see either the mac address or the QRCode of the device. Enter it as shown on the label. Follow the rest of the prompts. If you respond to all the prompts correctly, the ownership of the device will be assigned to you and a popup window will appear confirming it.
Once you have taken ownership of the device, your main dashboard page may look like the one shown in Fig 6A, if you are using a smartphone. And, if you expand the dashboard menu, you may see several options as shown in Fig 6B. If you are using a browser on a computer, you will see the dashboard menu on the left side bar.
Once the ownership is transferred, click on
'Access Control Admin' in the Dashboard menu. Then click on 'My Devices in Access Control'.
You will see your device listed there. If you have more than one device, all of them will be listed there. Once the device is assigned to you, nobody other than you will be able to configure it. In the later sections of this documentation, you will learn how to allow others to use this device. You will also learn how to configure this for your specific needs and how to use it.
2.4 Changing WiFi of the Device
If the device is already connected to internet, you can change its WiFi any time as per the steps given here. In the dashboard menu, click on 'Devices Admin' to expand that menu. Then click on 'Set WiFi'. It will take you to a page where it will prompt you to enter the SSID and password of your WiFi. Make sure that the WiFi is 2.4G and not 5G. The device is not capable of 5G WiFi. If the device is running firmware version greater than 4.2, you will see a pulldown menu with all the available WiFi at that location. You can choose one, and enter its password. Once entered, click Submit. If successful, you will see the device restarting, the led blinks blue and then changes to steady Red. The device is now set to go and ready for use.
If you accidentally entered wrong ssid or password, or if the device is not getting connected to the new WiFi, you will hear double beep from the device. The device will revert back to the previous ssid and will try connecting to it. If it is unsuccessful to connect to previous ssid, it will stay in that loop of attempting to connect, and LED will stay BLUE with occasional flashing. You can also do a factory reset as per the steps given in section 2.5 of this documentation. If you are running older firmwares, you will have to do a factory reset and repeat the steps given in section 2.2 and 2.4, if you entered wrong ssid and password.
If the device is still not connecting to your wifi, check the settings of your wifi router. Check if your router has set any limits on the nummber of devices that can connect
to it. Also check if its wireless mode is 802.11bgn, and its channel setting is Auto.
If the device was connected to the hotspot of your smartphone before changing wifi, try disabling hotspot on your smartphone now. If changing wifi was not successful, the LED will start blinking blue again after a few seconds.
The device will remember the WiFi that you set and will connect to that WiFi hereafter whenever power cycled or reset.
If you have used mobile hotspot of your smartphone to get initial connection, you can switch that off now. You can change your smart phone's name and WiFi password to whatever they were initially.
After switching off the hotspot on your mobile phone, try resetting the device by pressing the reset button on the device.
If everything is set correctly, the device will restart and join the WiFi.
You will see LED blinking Blue while trying to join WiFi and then turning to red when successfully connected to WiFi and connected to internet and the cloud server.
If this is not happening, there is something wrong either with the ssid and password that you entered, or with your internet connection through WiFi. Make sure that the ssid and password that you set are that of a 2.4G wifi and not 5G. Make sure that your router has internet connection.
If anything has gone wrong, do a factory reset of WiFi as per the steps in section 2.5 of this documentation, and then try to set WiFi again.
2.5 Doing a Factory Reset of WiFi
The WiFi of this device can be reset to the factory reset any time, if you find a need for it. The factory reset WiFi is : ssid = MyPhone and password = 12345678.
If the device is running firmware version 4.2 and above, you can also set its WiFi using a browser on your computer or Smart Phone by doing a factory reset. This is another method of setting WiFi of the device. After doing a factory reset, follow the steps given here in this section to do so.
To do a factory reset, open the box of the device, and locate two push buttons marked Reset(SW1) and Factory Reset(SW2). Factory Reset Button is also called WiFi reset button. Refer to Fig 8A below to locate these push buttons. If the device is operating at 110V/240VAC, make sure not to touch any of the high voltage tracks or terminals to avoid getting shock. Then, press and hold SW2 (Factory Reset button). While holding it, press and release SW1 (Reset button). Keep holding Factory Reset button until the device restarts and LED changes to flashing blue/green. Then, LED will change to BLUE. At this moment, the ssid and password of the device has been reset to 'MyPhone' and '12345678' respectively. You can release holding the factory reset push button.
If the device is running firmware version below 4.2, it will attempt to connect to wifi with SSID = MyPhone and password = 12345678. This is the method that we discussed in section 2.2 earlier in this documentation. You will see LED Blue and flashing occasionally. If you have enabled hotspot on your smartphone, the device will connect to it. and the LED will turn solid RED. If it is unable to connect, LED will flash blue occasionally and stay in that loop until connected. Refer to section 3.2 of this documentation, and then follow section 2.3 to take ownership of the device and section 2.4 to change its wifi.
When the device is running firmware version 4.2 and above, the device will go into access point mode and operate as a web server. It will advertise an SSID = WiFiSecureAccess. LED will stay solid BLUE without any occasional blinking. Follow the steps below to set its wifi at this time. (Note: If you press reset push button again at this time, the device will change to the previous mode and will attempt to connect to factory reset ssid)
Setting WiFi of the device using a browser when the device is web server mode
If your device is running firmware version 4.2 and above, factory reset will put the device in web server mode advertising an SSID = WiFiSecureAccess, and LED will stay solid BLUE without any occasional flashing. If you look at the available WiFi in your smart phone or computer, you will see this WiFiSecureAccess there. You will see this only after doing a factory reset of the device that is running firmware version 4.2 and above. Now, connect your computer or smart phone to this WiFi. Once your computer or smartphone is connected to this WiFi, open a browser (Chrome preferred) on your computer or smart phone and enter the ip address 192.168.1.1 in the url. You will see a window similar to the one shown in Fig 8B below.
On this page, it will list all the available SSIDs. Enter your SSID and Password and press Submit button. If your entry is correct, the device will set the WiFi of your device to that. Then it will try to connect to that wifi. You will see LED flashing occasionally BLUE. If it is able to connect to this wifi, you will see the LED changing to RED and staying RED (solid RED). If this is a brand new device, as a next step, you need to assign the ownership of this device as explained in section 2.3 of this documentation. If ownership is already assigned, the device is ready to be used.
If it is unable to connect, the device will beep twice (after a few seconds of attempts) and will revert back to the factory reset ssid (MyPhone). Then, it will try to connect to factory reset ssid. If so, follow the steps as explained in section 2.2, or do the factory reset again and enter the correct ssid and password.
2.6 Setting a backup WiFi
If the device is running firmware version 4.2 and above, and if you have more than one WiFi at your premises, you can set up a backup WiFi on this device so that the device will switch over to the backup WiFi whenever the main wiFi fails. Unless you set a backup WiFi, the default backup wiFi is the main WiFi that you have set. If you want to set a backup WiFi, open the dashboard and click on 'Set Backup WiFi' under Device Admin. You will see a page similar to Fig 8C. Just like the way you set the main WiFi in section 2.4, this page shows all the available WiFi in a pull down menu. You can select one of those, or select 'Other ...' to set anything else. Once selected, press Submit.
If successful, the device saves this backup WiFi and will switch to this WiFi whenever the main WiFi fails with three attempts.
Note: If any time need arises, you can use your smartphone's hotspot as a WiFi connection to the device. If you do a factory reset (we called this 'WiFi Reset' a few times), the device resets its WiFi to ssid = MyPhone and password=12345678. Then, if you see LED staying in solid BLUE, press reset button again. You will see LED flashing BLUE. At this time, if you set the hotpot's ssid and password to this and enable hotspot on your phone, the device gets connected to internet. This feature becomes handy when all the configured WiFi fails.
2.7 Initial Configuration of the Device
Once the wifi is set, and once the device is online and connected to the internet, you can check its default configuration. The device comes with a default configuration with its name as its macaddress and its port named as RELAY. It is assumed that nothing other than power is cabled to it yet. To start using it, you have to configure the device according to what is cabled to the device.
To start with, let us see some details of this device. Click on devices admin in the dashboard menu. Then click on My Devices. You will see this device listed there. If this is your first controller, you will see only one device. If you have more than one device, all will be listed here. If you have not changed the name of the device yet, you may see its name as its mac address.
Note: The pictures shown in this document are snapshots taken when using a computer. If you are doing this on a smartphone, your view will be similar, but without a dashboard menu at the left side. When using smart phone, to see the dashboard menu, you have to click on the three lines at the top right as shown in Fig 6A and 6B above.
Now on this page, click on any device. It will show the details of that device. You will see its two output ports (RELAY and BUZZER). It will show whether the output ports are currently ON or OFF. If it is ON, you will see a green circle with a check mark. If it is OFF, you will see an orange circle with a cross mark. You can click on the orange button of BUZZER. You will hear the buzzer sounding. Click this button again to put that off. If you click on the orange button on RELAY, you will notice that the RELAY is turned ON. Click it again, it will be turned OFF.
Now, click on Sensor Value on this page. You will see three sensors listed here: D6, D7 and Vin. If you have enabled additional sensors, you will see all of them listed here.
You will also see the current values sensed by these sensors. By default, D6 and D7 is an ON/OFF type inputs, until changed. Vin is the analog input.
Now, click on Device information. You will see a page similar to the following.
On this page (Fig 12), It will display all the details of this device such as its mac address, QRCode, NFC TagID, name of the device, firmware version, and so on. These are all for information. You may have a close look at all of them. Number of reconnects in this is the number of times the device lost connection to the server. If you see a higher number here, that indicates a weak wifi, or some frequent issues in connecting to internet.
On the firmware version tab, it will show you the current version and the latest version available. If the firmware is not up to date, you will see an orange button to click on to update its firmware.
2.7.1: Checking and Updating Device Firmware
To check the current firmware and to update its firmware, you can revisit this page (Fig 12) by clicking Device Details under Device Admin. Then click on Device Information to see the full information of the device. The Firmware version tab on this page will show the current version of the firmware on your device as well as the latest available. If the latest version or latest build is higher than the current build and current version, you will see an orange button on that tab. Click on that button to update its firmware.
We Strongly recommend updating the firmware to the latest by clicking the link on this page, if it shows new firmware is available
2.7.2: Changing the name of the device
You can change the name of the device as well as the labels of each port, if you prefer. To change the name of the device, click on 'Configure Device' under Device Admin on the left side bar menu. It will present
a form similar to Fig 13. You can Change the name of the device to anything you like. However avoid including any words 'Garage', 'Gate', 'Parking', 'Door' or 'Lock'. These are reserved for garages, gates and parking gates in Access Control mode of operation.
There are several other configurable fields on this page that may be left as defaults now. Check the Timezone on this field. By default, it is set to the timezone of the owner of the device. If this is not correct, you may change it to the timezone where this device is installed.
This helps in displaying all information in that timezone.
Click here to know the format of different time zones.
If this field is left empty, it will change it automatically either to the timezone of the owner of the device or UTC.
Notes on 'Use Type' field in the above form:
This field must be set to 'CONTROL/SENSOR' when used for automation and Remote Switches.
2.7.3: Changing the name of the output port
The names of the ports are also changeable by clicking on 'Ports and Security' under 'Device Admin' in the Dashboard menu. Fig 14 is the page that will show up when clicking 'Ports and Security". What you see here are the default values.
On this page, you will see several fields. The default name of D6 input is D6 and that of D7 input is D7. You can change these names to anything that you prefer, or leave them as they are.
The name of the output port relay1_label may be RELAY by default. You can change this name to anything you want or leave it as it is. But, when using this for automation/Instrumentation and Remote Switches, avoid adding any words 'Garage', 'Gate', 'Door', 'Parking' or 'Lock'. These are reserved for Access Control of these types of gates and doors.
The other fields 'Allow in GoogleHome' and 'allow in Alexa' are by default 'Yes'. That makes device discoverable in GoogleHome and alexa. If you do not want this device to be operated using voice command through Google Home or Alexa, you may set these to 'No'. The field 'Relay Secure port' is a field for additional 2-factor authentication. This must say No. This has a meaning only when you use an access controller instead of an automation controller.
2.7.4: Printing additional QRCode labels
Under device Information (Fig 12), you have noticed that each device has a QRCode. This QRCode is pasted on the box. If you scan this QRCode, you will get to the device details page. You can print as many additional QRCode as you want and paste it any other locations if you find a need. To print a QRCode, click on 'Show QRCode Label' under Device Admin in dashboard menu. Then select the name of the device. Once selected, it will show that QRCode label. You can save this image on your computer and print it using a color printer. Then you can paste it anywhere you want.
2.7.5: Changing QRCode of a device
If any time you find a need to change the QRCode of a device due to any security reasons, you can do so in the Device Configuration page. Click on 'Configure Device' under Device admin under the Dashboard menu. At the bottom of the page that opens up, you will see the tabs 'CHANGE QRCODE'. Click on that to change that QRCode. It wil prompt for confirmation. Once conformed, it will create a new QRCode and will show you that code in the Configure device page. You can print this QRCode label as described earlier. Note: Once the QRCode is changed, the earlier QRCode is no more valid. You will have to replace the old QRCode with the new one where you had pasted the earlier one.
2.7.6: Changing NFC tag of a device
Each device comes with an NFC tag. The NFC tagID of a device can be seen in the 'Device Information' page (Fig 12). This tag is pasted under the top cover of the device. For any reason, if you find a need to change this NFC tag, you can do so in the Configuration page (Fig 13). click on 'Configure device' under Device Admin in the Dashboard menu to get to the Device Configuration page. At the bottom of this page, you will see a tab 'DELETE NFC TAG'. This tab will be seen only if these NFC Tag is already assigned to the device. If you want to replace this tag, click on this tab. That will prompt you to confirm. Once confirmed, that NFC tagid will be deleted, and the device configuration page will be displayed with that NFC TagID as empty.
Next, if you want to use a new NFC tag, buy one NFC tag. We support only Mifare Ultralight 14443-3A type of tags which has 7 bytes of UID. These are very inexpensive tags that you can buy from anywhere. These tags come as stickers as well. Given below is an example link to buy from Amazon. This is just an example. If this link is not available, or if you would like to use a different type, search for a similar item in eBay or Amazon. These NFC tags are available in different type of shapes and packaging. You can use the type you like so long as it is Mifare Ultralite with 7 bytes of UID.
To associate an NFC Tag with your smart device, open the app and press 'Scan NFC Tag' and scan the tag that you purchased.
If this is a new tag and if it is not associated with any other device within our system, you will be taken to a page prompting you to select one of your devices to associate this tag to. The pulldown list will contain all the devices you own (all those devices that are powered on). iIf you have only one device with garage door, you will see only that in the pulldown menu. Select the device that you want to associate this NFC tag to..
Press Submit button after completing the selection.
If entry is correct, this tag is now associated with this device. Now, if you scan it again, it will take you to the Device details page (Fig 10), if this device is in Automation controller.
You can fix the NFC Tag and/or the QRCode label at any convenient place to access this device. These are normally pasted under the top lid of the controller.
Note: In our IOT system, QRCode as well as NFC Tags are both secure and both do the same job.
Even though anybody can scan these NFC tags or QR codes, only the owner of the device as well as those who are allowed by the owner can access/activate the device. For additional layer of security, you can also enable Two Factor Authentication(2FA) as explained in subsection 2.13 in this documentation. NFC tags are safer than QRCodes as NFC tags cannot be copied (we are using UID of the tag). And, if you do not want anybody to operate this device from remote, you can set "Allow remote Control" (Fig 13) to 'N'.
2.7.7: Activating a device
Once the device is installed and the names of the device and ports are configured, you can activate the output port of the device in one of several ways: 1) From the dashboard (Using a browser on computer or smartphone), 2) by scanning the QRCode or NFC tag of the device, 3) Using Google Home assistant on your smart phone, 4) Using Amazon Alexa, or 5) Making an HTTPS POST call from any of your other applications or programs. In the following sections of this document, you will learn how to use all these different methods.
Note: The WiFiSecureAccess controller has a push button mounted on itself. By pressing this button, you can turn ON the output port any time. If, for any reason, you want to disable this push button, you can either remove it from the controller, or disconnect it internally by opening the box.
2.8 Turning ON/OFF an output port from the dashboard
You can activate a device from the dashboard either using a browser on a computer or smartphone or through the WiFisecureAccess App on the smartphone. If you want to use a browser, go to the url https://wifisecureaccess.com. Then click on the dashboard tab on the top navigation bar. That will take you to the main index page. On that page, you will see a menu 'Activate a Device'. Click on that. That will show all devices that you are allowed to activate (similar to Fig 9). Clock on the name of the device that you want to activate. If the device is an automation controller, that will take you its Device Details page. On that page, click the button of the output port. That will toggle the state of that port. If it is currently OFF, it will turn it ON. If it is currently ON, it will turn it OFF.
You can also get to the dashboard through the WiFiSecureaccess App. Open the app on your smartphone. Then click on the 'Admin Dashboard' on the main scanner page of the app (Fig 14_0). That will take you to the main index page. There, you will see a tab "Activate a Device'. You can also see this 'activate a Device' tab in the dashboard menu, if you click on the three lines at the top right. To activate a device, click on 'Activate a Device' menu. that will display all the devices that you are allowed to activate (similar to Fig 9). Click on the device that you want to activate. That will show the device details page. On this page click on the button corresponding to the port that you want to activate..
You can also do the same thing by clicking the 'Activate a Device' in the main scanning page (Fig 14_0) of the WifiSecureAccess app. If you press that button, it will display all the devices that you are allowed to activate (similar to Fig 9). Then press on the device that you want to open or close. That will also take you to the device details page where you can click on the button of the output port that you want to turn ON or OFF.
Note: If you have multiple device, and some of them are access controller, then, clicking access controller device will result in different behaviour. You have to refer to its documentation for details. Also note that whenever you activate using this method, you are toggling the state of the output port. If it is currently OFF, clicking will put that port ON, and, if it is currently ON, clicking will put it OFF.
Note: As mentioned earlier in this documentation, everything that can be done by the wifisecureaccess app on a smartphone can also be done using a browser on a computer, except scanning QRCodes and NFC tags.
2.9 Turning ON/OFF an output port by scanning either QRCode or NFC tag of the Device
As you know by now, by default, each device has been assigned a unique QRCodes. To turn ON/OFF an output port of a device,
you can scan this QRCode using wifisecureaccess app. Open the app, go to the scanning page and press Scan QRCode. The camera will become active, and now scan this QRCode. That will open up the device details page of this device. Then click on the button of the port that you want to activate. That will toggle the current state of that port.
Instead of scanning QRCode, you can scan NFC tag to open/close the door/gate. Open the WiFiSecureAccess app on your smart phone. Then, in the Scanning page, click on 'Scan NFC Tag'. Then scan the top of the controller. (Remember that the BFC tags are sitting under the top lid of these boxes). If successful, you will feel a vibration of the smartphone, and will take you to its device details page. There you can click on the button of the port that you want to activate.
2.10 Using Google Home assistant to activate a port of the device
WiFisecureAccess devices are compatible with GoogleHome, and, therefore, you can use Google Home assistant to activate a port of a device. By default, the port is not enabled to be discovered by Google Home. So, you need to enable it first as explained earlier (under the sub heading 'Changing the name of the output port'). Click on 'Ports and Security' under Device Admin in the dashboard. You will see a page similar to Fig 14A. There, set the field 'Allow RELAY' in Google to Yes and press Submit.
On this page, make sure that 'Allow RELAY in GoogleHome' is set to 'Yes', if you want the RELAY to be activated using Google Home assistant. If you do not want to use Google Assistant to activate the ports, set them to 'No' and press Submit button.
If this is enabled to be discovered by Google Assistant, you can discover these ports in Google Assistant. Press + button in Google Home to add devices. Then press 'Set up device'. Then press 'Have Something already set up". On that page in Google Home, search for WiFiSecureAccess and select it. That will discover all the allowed ports of all your allowed devices. Once discovered, yiu can turn ON that port by a voice command to Google Hone or Nest by saying "Hey Google, turn On 'the name of the port as seen on Google Home'.
You can now rename these whatever you would like to. Hereafter, you can say 'Hey Google, open *name of the device*'. That will open that door/gate. That will open that door or gate. Note that you can change the name of these ports in the "Device Configuration" menu (Fig 13) in WiFiSecureAccess dashboard, and/or within the Google Home. The name in Google Home need not necessarily be the same as that in the configuration within the dashboard of wifisecureaccess.com.
Note:
When a port is enabled to be discovered by Google assistant, it determines the type of the port by looking at the device name as well as the name of the port label. The types are 'Switch', 'Light', 'Fan" and so on. So, it is important that you name the device and its port appropriately. If it finds any such words in either its name or port label, it will take it as its type to create an icon in Google assistant.
2.11 Using Amazon alexa to activate a port
The output ports can also be activated using Amazon Alexa. You may download and install Amazon Alexa on your smart Phone. In Alexa, press 'more' and then click on 'skills and games'. Now search for wifisecureaccess, then enable that skill. When enabling the skill, it will take you to Wifisecureaccess.com and will prompt you to enter your email and password. This is your password for wifisecureaccess.com. If the entered credentials are correct, you may press Discover Devices. That will discover all the wifisecureaccess devices that you own.
As said earlier, you have to enable the port to be discovered by Alexa first prior to attempting to discover. This setting is under 'Configure Pports' under Device admin in the dashboard menu (Fig 14C)
On this page, select 'Yes' for "Allow RELAY in Alexa" if you want garage to be discovered by Alexa. Press Submit after making the selection(s). Then, login to Alexa on your smartphone and discover ports as you did before. If all settings are correct, you should be seeing these devices discovered in your Alexa application on your smart phone. You can now turn ON by saying, for example, "Alexa, turn on XYZ", where XYZ is the name you see for this port in Alexa. Similarly, to turn it OFF, you can say "Alexa, turn off XYZ". All the features of Alexa are now available to you for managing the equipments connected to this smart devices.
2.12 Activating an output port with an HTTPS POST call
You can also turn ON or OFF a port of a device from any of your other application programs using an HTTPS POST call. This helps integrate the WiFiSecureAccess system/devices with your other application programs. This feature also helps the developers to integrate this with their programs.
To turn ON or OFF a port, make an HTTPS POST call with the following details:
POST HTTP/1.1
Host: wifisecureaccess.com/devicePortsJson/
Content-Type: application/json
data = {
"email": email,
"password": password,
"device_name": device_name,
"action": action,
}
--where email is the email address of the owner of the device, password is the password of the owner of the device, device_name is the name of the device and action is either 'ON' or 'OFF'.
Refer to section 8.1 of this documentation below to see more details about this and to see a sample python program.
2.13 Enabling Two Factor Authentication on Turning ON/OFF
By default, the doors and gates are secure, meaning that nobody else other than those who are allowed will be able to open/close them. But, if you are interested in an additional layer of security, you can enable 2FA (two fact authentication) on these controllers. If you enable it, the user will be prompted for two factor authentication when trying to open that gate or garage door. To enable 2FA on any device, click 'Ports and Security' under Devices admin in the dashboard, just like the way it was done when enabling GoogleHome. You will see a page as in Fig 14D.
On that page, you will see a field 'Enable Two Factor Auth (2FA)'. By default, it is disabled. There are multiple optiions for two factor authentication. The options are Personal Pin, 'Send code by email', or 'face recognition'. You can choose any one of them, and press Submit. Google Home always uses Personal Pin, regardless whether you set anything other than 'No'. Once enabled, whenever you tell Google assistant to, activate that device (such as 'Hey google, Open Door'), Google Assistant will respond 'Can I have your pin?'. If you are activating this port by scanning QRCode or NFC tag or by pressing 'activate' button on your smartphone, the system will prompt for the pin before before activating that door/gate. You will have to enter your personal pin correctly to open the door. Your pin can be seen under your profile (click My Profile under User Admin in dashboard to see it). By default, the pin is 1234. You can change it to anything you like. This 2FA is an extra layer of security, and it is optional.
If you set 'Enable Two Factor Auth' to 'Send Verification Code' or 'Face Recognition', these will be used when trying to open this door/gate either by scanning its QRCode or NFC tag, or when pressing its button under 'Activate a Device' on a smart phone or computer. If you set it to 'Personal pin', it will prompt you to enter the personal pin. If you set that to 'Send Verification Code by Email', it will send a code to your email address. You will have to enter that code to open that door or gate. And, if you have set this to 'Face Recognition', it will open up your camera on your smartphone or computer and ask you to take a selfie. It will then match that photo with your profile picture to provide access.
Note: The above method of 2FA will not work with Alexa. For 2FA in Alexa, you need to set it in Alexa itself. Refer to documentation on Alexa for setting pin codes for Locks and Doors.
2.14 Device Use Records
The system keeps record of the use of this garage door for 30 days. At any time, you can see who used this garage door and at what time. To see the use records, click on 'Device Use records' under 'Device admin' in the dashboard menu. You will see a page similar to the one in Fig 38E with two columns (User and use_time).
You can download these use records to your computer, if you want to do so for keeping any records, or for analysing the data. To
download, click on 'Download Device Use records' under Device Admin in the dashboard menu. There you can provide the dates between
which you want to download the data. Leaving any of these dates will take that date as open-ended. Leaving both dates as blank wi
ll download all the available use records for the past 30 days.
You can also add a program in any of your applications to download these records, and do analysis. These use records can be read using a python program. Refer to section 7.1 of this documentation.
3 Allowing Multiple Users
This section explains how multiple users can be allowed to use a device. The owner is allowed to use all his devices all the time regardless of the settings described in this section. This section explains how the owner can allow others to use his devices and how to control and manage their authorization.
3.1 Allowing Others to Use Your Devices
You can allow or authorize the others to use your smart device. To allow someone else to use your device, they have to be registered with wifisecureaccess.com. So, request the other user to register with wifisucureaccess.com. To register, either download the app and open the app and press Admin Dashboard, or go to https://wifisecureaccess.com and click on dashboard in the top navigation bar. When it requests you to login, click on 'Create a New account'
Once they are registered, you add their email address to the Allowed Users group of your device as per the steps below:
First create a Device Group. This can be done by clicking 'Devices groups' under 'Device Groups' in the Dashboard menu.
This page will display all the device groups that you have created so far. To add a new device group, just enter the name of the group in the bottom empty row and press submit. Make sure that the name that you entered is a new name. You can create as many groups as you need.
Next, click on 'Allowed Users' under Device Groups in the Dashboard menu. If you have created multiple groups, you may be prompted to select a group. You will then see a page similar to the one shown in Fig 14F.
In this form, enter the email address of the one whom you want to allow to use your device, and press Submit. If you have several users whom you want to allow, enter the email addresses of all of them, one at a time. You have now created a group of users.
PS. If you want to allow everyone, you can enter an email address *@gmail.com. If this email address is in any device group, everyone can activate that device to which this group is associated by scanning either its QRCode, or NFC Tag, but not by using voice prompt through Google Home or Alexa.
Note: When you added the email address of a user in a group, you could add a start date and an expiry date as well, if you want. Start date is the date and time this user will be allowed. He will not be allowed before that date and time. Once an expiry date is added, that user will not be allowed after that expiry date. The format of these dates is yyyy-mm-dd hh:mm. Leave these date blank if the user is allowed all the time with no start date and no expiry date.
You can also remove any user from this group at any time by checking the delete box against that user's name and pressing Submit.
Next, you need to associate this group to the device so that all users in this group are allowed to use a device. To do that, click on 'Configure Device' under Device Admin in the Dashboard menu.
In this page, select your device group, and press Submit. If all the above configurations are successful, all users in the selected device group are allowed to use this device.
When someone is allowed to use to use your device, they will see this device in the list of devices they can use. Also, when they click on 'Show Device details', this allowed device will show up. If this device's port is enabled for GoogleHome or Alexa, the allowed users will show this device in GoogleHome or Alexa when they discover wifisecureaccess devices. But, keep in mind that the allowed users cannot change the configuration of a device.
Now, all allowed users will be able to activate this device. If you have set a start date, that user will not be able to activate the device before that date. If you have set an expiry date, they will not be able to activate the device after that expiry date.
3.2 Creating a New Group by merging members of two other groups
If you have created two groups and you have added members in each group, and if you are interested in creating ai new group that should contain members of both the other groups, you can do so. First create a new empty group by clicking 'Devices Groups' under 'Device Groups' in the dashboard menu. Then click on 'Merge Device Groups' under 'Device groups' in Dashboard menu. You will see a page similar to Fig 14H.
On this page, select Destination group as the new empty group that you just created. Then, select the first group that you want to add to this in the 'Source Group' field. Then press Submit. Next, repeat the same to add the second group to the same new group by clicking 'Merge Device Groups' and selecting Destination Group as the new group and selecting the second group for the 'Source Group' field. Then, press submit. Now, you have a new group with members of two of the other groups that you selected.
3.3 Entering an allowed user into a group using an HTTPS POST call from any of your applications
You can populate the allowed users of any group from any of your applications such as a booking platform using an HTTPS call. This feature helps integrate the WiFiSecureaccess door controller with your applications such as a booking platform. If these devices are installed, for example, on the door of a hotel room or an AirBnB room, the application platform that makes the booking can enter the customer's email and their start date and expiry date directly into the allowed user's list of the group associated with the controller device. If done, the customer will be allowed to open the door during the period between start-date and expiry-date. The customers can open the door either by a voice prompt, or by scanning the QRCode or NFC tag fixed on the door. Thus, this is an ideal system for hotels and AirBnB users. This eliminates the need to pass on the keys or access cards to the customer.
To add the user to the evice's group, make an HTTPS POST call with the following details:
POST HTTP/1.1
Host: wifisecureaccess.com/loadAllowedUsersJson/
Content-Type: application/json
data = {
"email": your_email,
"password": your_password,
"device_group_name": device_group_name,
"customers": customers
}
-where customers is a double list of customer details.
customers = [customer1, customer2, customer3, ....]
-where each customer is a list as below:
[email_address, start_date, expiry_date]
For example, if you want to add two customers to the allowed group of a device, the customers should be as follows:
customer1 = [customer1_email, customer1_start_date, customer1_expiry_date]
customer2 = [customer2_email, customer2_start_date, customer2_expiry_date]
customers = [customer1, customer2]
Note: Leave start date and expiry date as "", if there is no start date or end date for that customer. If there is no start date, that means that the customer can access immediately. If there is no expiry date, the customer is authorized forever.
You can also remove any customer from the device's group with another HTTPS call as follows:
POST HTTP/1.1
Host: wifisecureaccess.com/removellowedUsersJson/
Content-Type: application/json
data = {
"email": your_email,
"password": your_password,
"device_group_name": device_group_name,
"customers": customers
}
-where customers is a list of email address of the customers that you want to remove from the allowed list.
customers = [customer1_email, customer2_email, ......].
Refer to section 7.2 of this documentation below to see more details about this and to see a sample python program.
3.4 Group Use Records
The system keeps record of the use of all the doors/gates of this group. At any time, you can see who used this group at what time. To see the group use records, click on 'Group Use records' under "device groups' in the dashboard menu. If you have created multiple groups, you will be prompted to select the group. Once selected, you will see a page similar to Fig 14I.
You can download these use records to your computer, if you want to do so for keeping any records, or for analysing the data. To download, click on 'Download Group Use records' under Device Groups in the dashboard menu. There you can provide the dates between which you want to download the data. Leaving any of these dates will take that date as open-ended. Leaving both dates as blank will download all the available use records for the past 30 days.
You can also add a program in any of your applications to download these records, and do analysis. These use records can be read using a python program. Refer to section 8.2 of this documentation.
4 Connecting External Equipments and Sensors
In this section, we will describe how external equipments and sensors can be connected to this smart device.
4.1 110/240V Electric Appliances
One can connect any 110/240V electrical appliance to this device so long as its current rating is 10A or below.
If your electrical appliances have higher current rating than this, you may use an external relay and connect that relay's coil to the solid state switch of the controller as shown in Fig 16A below. The cabling of the external relay to controller is as per the diagrams for cabling a relay to controller (explained the next sub section 4.2).
Fig 15 through 16B show how to connect a 240V electrical bulb to the device. With this connection, the device will behave like a smart plug. But, please keep in mind that this device is not a plug and play type DIY device. One has to wire the electrical appliance to this device.
You can make a smart plug out of this smart device by cabling as per the Fig 15A through 15C.
Or alternatively, you can wire the electrical appliance directly to the smart device instead of using a socket.
Note: This is just an example to show how a 240V or 110V electrical load can be cabled. Instead of a light bulb that we have used here, you can cable any other high voltage electrical load so long as the load is rated 10A or less.
If you want to cable a high powered electrical equipment with higher than 10A current rating, use an external relay of appropriate current rating and do the cabling as shown below in Fig 16A. The rating of the coil of the high power relay must be less than 1A (preferably 500ma) at 12VDC.
Warning: When using AC Power, it is important that qualified electricians are engaged, as AC power can lead to safety issues unless handled properly. Once AC power is connected to this device, one has to be careful in touching this device as the connectors J3 and J4 as well as the relay ports and other AC lines on the PCB can cause electric shock when touched. WiFiSecureAccess takes no responsibility for any harm caused due to mishandling of this device with AC power by unqualified personnel. This device is not a DIY when it comes to using AC power
When connecting 110V or 240V to the device, make sure to put the jumper on PJ1 to select AC as the power source for the PCB. Refer to Fig 5 to locate PJ1. Once all the cabling is done, close the box of the device and and switch on power. You will be seeing the device comes on and LED changes from blue to red and staying red indicating that the device is active.
Now, on the browser (or in the app on smartphone), click on 'Show Device Details' in the left menu bar under Device Admin. If you own more than one device, you will be prompted to select a device. If you have just one device, it will take you to a page with the details of this device. You will be seeing a page similar to Fig 10. You will be seeing the Relay with a red cross mark. Click on that. You will see the relay is put ON and the 240V/110V electrical equipment comes ON. Click on the button again to put off the electrical equipment.
As we described in section 2.8 through 2.11 above, there are four ways of operating this electrical equipment connected to this smart device. If you are using this within a house and would like to operate this using Google Home assistant, or Alexa then you can discover this in the google assistant or Alexa now. It is recommended to name the ports as per your choice. It is also recommended to disable P0 port of smart device as you are not using it when used it as a smart plug. Refer to Fig 14A and 14D for disabling/enabling ports for Google assistant and Alexa. The steps are given in section 2.8 through 2.11.
This is just an example to show how the 240V/110V cabling is to be done. In the later sections of this documentation, you will learn how electrical equipments can be controlled automatically, and how to allow others to operate this device.
4.2 Connecting a Solenoid or any other DC load
Depending on the voltage and current rating of the solenoid, there are two different ways of cabling a solenoid to the smart device. If the current rating of the solenoid is less than 1A (preferably,500ma), and if its voltage rating is 12V, then the internal power from the smart device can be used to power the solenoid or DC load. If the voltage rating or current rating of the solenoid or DC load is higher than this, you need to use an external power source and cable it as per Fig 18A and 18B.
Fig 17 and 17A show how to cable a solenoid with current rating of 500ma (or less) and voltage rating of 12V.
The above cabling is 'normally off', meaning that the solenoid will ne normally off. To do a 'normally on' cabling, do the wiring as shown in Fig 17B.
If you have a higher power solenoid with current rating higher than 500ma, then you need an external power supply to match the current and voltage rating of the solenoid. If so, do the cabling as per
Fig 18A, 18B and 18C. The relay terminals (COM and NO) have 10A current rating. It can take voltages up to 240V.
The smart controller box can be fitted anywhere, either near or far from the solenoid, where it is convenient. At the location where the smart controller is fitted, it is important that there is power and WiFi. Run the cable from the smart device to the coil of the solenoid.
Once this cabling is done, close the box of the device and put its power ON. On a browser or in the app on smartphone, click on 'Show Device Details' in the left menu bar under Device Admin. Then, click on P0 or RELAY depending on how you have done the cabling. You will notice that the solenoid is put ON. To put it off, click it again.
There are four ways you can operate this solenoid manually, including Google Home assistant or Alexa. We have described this in section 2.8 through 2.11 above. So, follow those steps. In addition, if you are using this solenoid for any automatic controls or as access control to home or business, you may read the appropriate sections in this document. In the sections to follow, we will learn how to configure this for various purposes.
4.3 Connecting ON/OFF type sensors
If we are interested in reading the status of an ON/OF switch such as limit switch or any other sensors such as motion detectors that gives ON or OFF output, they can be connected to our smart device for reading its status and to take any action. An ON/OFF sensor can be connected either to D6 or D7 inputs of the smart device. Refer Fig 19.
Connect the ON/OFF sensor between D6 (or D7) and GND. If it is an ON/OFF switch, connect its one terminal to D6 (or D7) and the other terminal to GND on connector J5 of the smart device. If you have a sensor such as PIR motion sensor, connect the OUT of the PIR motion sensor to D6 (or D7) and connect GND of the sensor to GND terminal of the device and connect 3.3V(VCC) of the sensor to 3V3 pin of the smart device. After doing this cabling, put the device ON. Then on a browser or in the app on a smart phone, click on 'Configure Device' under Device admin in Dashboard. On this window, make sure that D6_type as well as D7_Type are both selected as TWO STATE INPUT ON/OFF. If they are not in that state currently, select them and press submit.
Then on a browser or in the app on a smart phone, click on 'Show Device Details' under 'Device Admin' in Dashboard menu. Then click on Sensor Values tab. You will see a window similar to Fig 11.
The status of the sensors connected to D6 and D7 will be displayed here. If D6 or D7 is at 3.3V, it will display as OFF, and if it is at 0V, it will display as ON. If nothing is connected to D6 or D7, it will display as OFF (reverse logic).
In the later sections of this document, we will learn how to use these sensor inputs for controlling any output ports or equipment connected to this device or any other device sitting remotely. We will also learn how to read these sensors and log the data periodically.
4.4 Analog Inputs
Any sensor which gives an analog output can be connected to this device. Connect the analog output of the sensor to the Vin pin of connector J1 of this device with ground connected to GND. Please note that the voltage range of Vin is 0 through 3.3Volts. So, the analog output must be in this range. If not, you will have to modify the analog output using external circuits to convert the range between 0 and 3.3 Volts.
Once connected, click on 'Show Device Details' in the left menu bar under Device Admin. Then under Sensor Values, you will see the actual voltage sensed.
Note: You can do a linear scaling of this analog input by changing the slope and intercept parameters of Vin.
To do that click on 'Ports and Security' under Device Admin in the left menu bar. That will open up a page similar to Fig 14 (in section 2.7 of this documentation). There you will see two parameters ('Vin0 Intercept' Factor and 'Vin0 Slope' Scaling Factor). By default, they are set to 0.0 and 0.00322265625 respectively. The actual values read by the analog to digital converter is between 0 to 1024 for a voltage range of 0 through 3.3V. These intercept and slope are set such that the displayed values are the actual voltages.
You can change these to anything you want to display different scaled values, if you prefer.
In the later sections of this document, we will learn how to use this input for controlling any output ports or equipment connected to this device or any other device
sitting remotely. We will also learn how to read these sensors and log the data periodically.
4.5 Ultrasound Sensor for Distance Measurement
The device can be used to read HC-SR04 Distance Transducer Sensors. These sensors are low-cost sensors which are readily available in the market. You will find them on eBay and amazon. Here is a link from Amazon.
Note: This is just one link to show the type of sensor. We are not recommending to buy this. You can search and buy this from any supplier of your choice.
(If this link is broken, search for HC-SR04 in Amazanon.com)
PS: Make sure to buy the model that works with 3.3V power supply
Buy Now
Figure 22 shows how to connect this ultrasound sensor to the smart device. You can connect ultrasound sensor either to PJ3 connector or J1 connector on the controller. Both these connectors have D1 and D6 which are required to cable the ultrasound sensor. This connector has four pins (GND, D1, D6 3V3). Use a flat cable to connect D1 to 'Trig', D6 to 'Echo', GND to GND and 3V3 to VCC as marked in Fig 23.
Once connected, click on 'Configure Device' in the left menu bar under Device Admin in Dasboard. Then select USOUND to 'YES' and D6_Type as None as shown in Fig 24. Then press Submit.
Now, you can see the distance read by the ultrasound sensor on the Device Details page. Click on 'Show Device details' in menu bar in the left under Device admin. Then click on sensor Values. You will see a page similar to Fig 25 with the current value read by the ultrasound sensor under U_SOUND.
Refresh the page again to read again. Move the objects around ultrasound sensor and notice the actual distance measured. You need to refresh the page every time you move the sensor to display the new distance. We will see later in this documentation how all these can be automated to control anything depending on the inputs.
Note: If you are interested in using this smart device for data monitoring and logging, as well as data analysis, you can read this data to your local computer using a json call. In the later section 8.0 of this document, we will provide sample python programs to read sensor values at regular intervals. You can then write your own program to analyse the data the way you want.
4.6 Motion Sensing Device
The device can be used for reading motion sensors and take actions. Low-cost motion sensors are available through eBay or Amazon. Here is a link from Amazon. A link to a low cost motion sensor than can be purchased from Amazon is given below, or you may choose any model of any source of your preference as long as its voltage rating is 3.3V.
(If this link is broken, search for HC-SR501 in Amazon.com)
PS: The model that you buy must work on 3.3V power
Buy Now
Fig 26 and Fig 27 show how to connect this motion sensor to the smart device. This motion sensor has three pins (GND, OUT, VCC). Connect VCC, OUT and GND of this sensor to 3V3, D7 and GND respectively on connector PJ4 of the device. You can also use D6 or D7 on J1 connector. Motion sensor's OUT can be connected either to D6 or D7 of the smart device.
Once cabled, you need to configure the device. Click on 'Configure Device' in the menu bar on the left under Device Admin in Dashboard. Then select D7_Type as 'TWO STATE INPUT ON/OFF'. If you have connected motion sensor to D6, USOUND must be selected as None, and D6 as 'TWO STATE INPUT ON/OFF'.
Once connected, click on 'Show Device Details' under Device Admin in the menu bar on the left. In Sensor Values, you will see the state of the motion sensor. If motion is detected, and if you have connected motion sensor to D7, you will see D7 displayed as ON. In later sections of this documentation, we will describe how the devices can be configured to take any automatic actions when motion is detected.
Note: Connecting motion sensor to the smart device is similar to connecting any ON/OFF type sensors to this device.
4.7 DHT11 Temperature / Humidity sensor
DHT11 temperature/Humidity sensor is a low cost sensor for reading ambient temperature and humidity. This sensor is available to buy. You can search in eBay or amazon or do a google search to source it. Here is a link from Amazon. Note: If this link is not available, search in eBay or amazon for 'DHT11 temperature humidity' sensor.
(If this link is broken, search for 'DHT11 Temperature and Humidity Sensor' in amazon.com)
PS: You need to buy the model that is rated for 3.3V VCC, and not 5V
Buy Now
Connect this sensor to the device as shown in Fig 29 and Fig 30.
Now, in order to use this, you need to configure the device. Click on 'Configure Device' under Device Admin in the Dashboard menu. If you have connected the sensor to D6, select USOUND as None and D6_Type as 'DHT11/TEMP/HUMIDITY'. If you have connected to D7, select D7_Type as 'DHT11/TEMP/HUMIDITY'. Then press Submit.
Once set correctly, click on 'Show Device Details' under Device Admin in the menu bar on the left in Dashboard. You will see the temperature and humidity read by the sensor under Sensor Values.
Note: In later sections of this documentation, we will describe how to configure automatic controls based on these values read. We will also describe how these values can be read periodically into your computer for any analysis.
4.8 DS18B20- Temperature Sensor
DS18B20 temperature sensor can also be used with our smart device. This can be procured through eBay or Amazon or any other source of your preference. The link given below is an example.
(If this link is broken, search for 'DS18B20 Temperature Sensor' in amazon.com)
PS: The model that you buy must work on 3.3V power source.
Buy Now
Connect this sensor to the device as shown in Fig 33.
Now, in order to use this, you need to configure the device. Click on 'Configure Device' under Device Admin in the Dashboard menu. If you have connected the sensor to D6, select USOUND as None and D6_Type as 'DS18B20 Temp SENSOR'. If you have connected to D7, select D7_Type as 'DS18B20 Temp SENSOR'. Then press Submit.
Once set correctly, click on 'Show Device Details' under Device Admin in Dashboard menu. You will see the temperature read by the sensor under Sensor Values.
Note: In later sections of this documentation, we will describe how to configure automatic controls based on these values read. We will also describe how these values can be read periodically into your local computer for any analysis.
5 Configuring Automatic Controls
This section will help you learn how to configure devices for Home and Industrial Automation. The system has the capability to automate the operation of any externally connected equipments ( the equipments connected to relay of this device). All needed automation can be done by configuring the device without the need for any programming. It is also possible to configure devices such that one device senses values of the sensors connected to it and another device sitting remotely takes an action based on those sensed values.
To use any device for Home/Industrial Automation, the device has to be configure in that mode. To configure a device in Home/Industrial Automation, click on 'Configure Device' under device admin in the Dashboard menu. Then select use_type as CONTROL/SENSOR and press Submit.
Note: If the hardware version is 3.1 and if there is a word Garage, Gate, Parking, Door or Lock either in the name of the device or in any of its output port labels, the system assumes that you have cabled smart device to controllers on Garage, Gate, Parking, Door or Lock, and therefore, you are using it for access control. In that case, you will not be able to change to CONTROL/SENSOR mode. If you need to change to CONTROL/SENSOR mode, you must remove those words from the name of the device and its port labels first.
Note: When using the device for Control/Automation and if the hardware version of the controller is not 3.2, when naming the device or any of its two output ports (DOUTP0 or RELAY), make sure that you do not include the words 'Garage', 'Door', 'Parking', 'Gate' or 'Lock'. these words are case insensitive. If these words are found either in the name of the device or in any of its output ports, the device will automatically switch over to 'Entry or exit' type of Access Control device. This Access Control mode of operation is explained in the next section of this documentation.
5.1 Configuring an Output Port for auto OFF mode
We have learned in section 2 that we can activate any output port (and thus any equipment connected to that port) manually from remote by clicking a button either using a smartphone or from a computer.
In fact, there is a shortcut to activating a port of any device. Click on 'Activate A Device' in the Dashboard menu. The app on the smartphone has this button in its home screen. When you click this button, it will show a window similar to Fig 40B listing all your devices.
Note: You can activate a device by scanning the QRCode of the device using the app. Press Scan QRCode button in the home page of the app, and scan the QRCode label of the device. That will also take you to a page displaying all your devices.
Click on any device on this page that you want to activate a port of. That will take you to a page similar to Fig 41, if the device has earlier been configured in CONTROL/SENSOR.
This page shows the current status of all the three output ports of the device. You can toggle its state by pressing the button of that port.
Note that if you put a port ON, the state of that port stays ON until you press that button again to put it OFF.
If you want, you can configure the device such that it automatically puts its port OFF after a specified duration of time. Suppose that you want the port to be automatically put off 6 seconds after it is manually put ON. If so, configure as follows:
Click on 'Configure Auto Controls' under Device Admin in the Dashboard menu. If you have more than one device, it may either prompt you to choose a device, or may use the previous used device depending on the current state of your configuration. Once the device is selected, it will take you to the Port Controls page which will look similar to Fig 42, if you have not yet configured any auto controls yet. If you had earlier configured any auto controls for this device, it will list all the previously configured auto controls here
Now, press the button labelled 'ADD AUTO RESET (ON/OFF) MODE PORT CONTROL'. That will take you to a page similar to Fig 43.
On this page, select the output port from the pull-down options. The available options are all the output ports of this device. In the second row, it shows the mode. There is no option here. The mode is pre set to "NORMALLY OFF, WHEN PUT ON MANUALLY, AUTO PUT OFF AFTER DURATION".
Then enter the duration of time in seconds after which the port should be auto reset. If you enter 0, it will never reset that port and will stay ON until you manually put it OFF. Then press Submit. If you have entered everything correctly, it will configure the device accordingly and will display the port control page of the device (similar to Fig 44) displaying all your configured port controls of this device.
If you need, you can edit this port control on this page. If you want to delete this portcontrol, scroll the page to the right to see the Delete checkbox at the right end of this portcontrol. If you check that box and press Submit, it will delete this portcontrol.
The port is now configured such that the port automatically gets reset after the specified duration whenever you activate this port. Try to activate this port using a smart phone or computer and test if its is working.
5.2 Configuring Periodic Actions (Interval Based)
You can configure a periodic action on any of the output ports. For example, say, you want the relay to be put ON at the start of every hour. If so, configure it as follows:
Click on 'Configure Auto Controls' under Device Admin in the Dashboard menu. If you have more than one device, it may prompt you to choose the device, or may use the device that you used last depending on the environment. Once the device is selected, it will display a page similar to Fig 42 showing all the current auto controls configured on this device. If you want to configure Relay to come ON at every hour, click on 'ADD TIME BASED PORT CONTROL' on this page. That will display a page similar to Fig 45.
If you are configuring Relay of this device, select RELAY for Output Port on this page. If you want an email to be sent to you (to the email address set for Alert Email field in the 'Configure Device screen') whenever it puts on the relay, select YES in 'Send Email' field. And, since you want this action to be repeated every hour, select 'NORMALLY OFF AND PERIODIC ON, PUT OFF AFTER DURATION' for the MODE field. Note that there are four options for the MODE field. They are self explanatory.
Then, set Repeat Time Period in seconds. If you do not want the action to be repeated, leave this field blank. If you want the relay to be activated every hour, enter 3600 in this field (1 hour = 3600 seconds). Next, you need to set when it should start this repeat cycle. Next Start field can be either a time delay in seconds from now, or an exact date and time in the future. If you leave this as blank, it will be taken "start immediately". If you are entering the exact date and time when this should start, then enter n 24 hour clock. Its format is yyyy-mm-dd hh:mm. You need to specify the year, month, date, hour and minutes in this format. In the next field, enter the duration in seconds the relay should remain ON. If you want the relay to be on for 1 minute, enter 60 here. Keep in mind that this duration must be less than the repeat time interval for obvious reasons.
Note: This is a periodic interval based control. That means that the repeat action is performed after the specified interval. This is not a control that is recommended for scheduling an action for, say, 8:00AM every day. If you configure interval based periodic control for scheduling actions every day, or every Tuesday of every week, this may not work well if the daylight saving time changes. For scheduling events of that nature, we recommend the configuration as shown in section 6 below.
There are three more additional fields in this form. They are optional fields. You can leave them as they are if you are only interested in just a periodic action. However, if you want the periodic action to take place only when a condition is met, then you can enter that information here. For example, say, you want RELAY to come ON periodically every hour only if a sensor detects a pre-set value. If so, connect that sensor to the inputs of this smart device. The sensors can be motion sensor, temperature sensor, rain sensor and so on. section 3.0 of this documentation describes how to connect various types of sensors to this smart device. Once the desired sensor is connected to the smart device, you can now choose that device here in configuring periodic actions. Select input port to which sensor is connected. Then in the next field, choose the logical operation (LESS THAN. or GREATER THAN OR EQUAL TO). Then enter the pre-set value of the sensor in the Value field. Fig 45A shows an example of such entry. By selecting these three fields appropriately, you are configuring the smart device to put on the OutPort periodically only if the value sensed at the Inport is either less than (or greater than or equal to) the Value. As mentioned earlier, if you leave input port as None, it will ignore this condition when activating periodic actions.
Once all these fields are entered press Submit. If all entered values are valid, it will configure the device accordingly and display the portcontrol page similar to Fig 46. If there is any error, it will display errors. If errors are reported, fix those errors and enter the values again and re-submit. Fig 46 will show all the port controls configured in this device (the currently configured as well as all previously configured and still active). You can delete any of these port controls any time by checking delete button (at the far right of each row) and by pressing Submit button.
Note: If you do not want the action to be repeated, but just only once at the Next-Start, select MODE as 'NORMALLY OFF, PUT ON AT NEXT START. PUT OFF AFTER DURATION' or 'NORMALLY ON, PUT OFF AT NEXT START, PUT ON AFTER DURATION' and set Repeat Time interval as 0 when adding portcontrol
Now, you can monitor this device. You will observe that the relay is put on for one minute at every hour starting 2020-08-21 18:00 (as per the settings in this example). It will put relay ON the first time at 18:00 on 2020-08-21. The relay will remain ON for one minute. Again, the relay will come ON at 19:00, and again at 20:00 and so on.
Note: What is demonstrated here is just an example only. You can create such portcontrols on any port of any of your smart devices to meet your needs.
You can delete this portcontrol or any portcontrols that you have configured by checking the delete box against that portcontrol in the portcontrols page (Fig 46) and pressing Submit button. Note that the delete checkbox is all the way at the right of the form. You may have to scroll the bottom bar of that form to find it.
Note: You can configure periodic port controls on any of your device to send you emails even without activating an output port. For example, say, you want emails sent to the 'Alert Email' address every hour starting at 8:00AM, 2021-02-15 as a reminder. You can do that exactly the same way as you have configured above, except that when selecting fields, select None for Output port and YES for 'send Email' fields. Note: Alert email is the email address set in the Alert Email' field in the 'Configure Device' screen. Unless set, it defaults to the email address of the owner of the device.
5.3 Configuring port control based on Input Condition
You can configure an output port to be put ON/OFF based on an input sensor values. Fo example, you can configure RELAY to be put ON when the voltage level at Vin is greater than or equal to 1.0volts. Or you can configure P0 to be automatically put ON when the temperature read by DS18B20 Temperature Sensor connected to D7 is 60 degree or higher. Or, you can configure Buzzer to be activated when the motion sensor connected to D6 senses a motion, and so on for any of your requirements.
Let us see, for example, how to configure the device such that RELAY is automatically put ON when the analog voltage read from Vin is greater than or equal to 1.0Volts, and it gets put OFF when the voltage is less than 1.0Volts. To configure this automatic control, click on 'Configure Auto controls' under Device admin in the Dashboard menu. As mentioned in the previous section, it may prompt you to choose device if you have more than one device. Once selected, it will come to portcontrols page displaying all the portcontrols that you have configured on this device so far. Click on 'ADD INPUT BASED PORT CONTROL' on this page. That will take you to a page similar to Fig 47.
Similar to what we did when configuring periodic port control, select the various fields in this form. For our example, select RELAY for output port. Choose 'Self' for the 'Out Device'. In fact, this system has capability to activate a port on another device when sensor condition on this device are met. We will discuss that in the next subsection. Here, for our example, select 'Self' for this field. In the 'Send Email' field, select either YES or NO depending on whether you want an email to be sent to the Alert Email address when the output port is activated. For the 'Mode' field, there are two options - 'PUT ON THE PORT AND/OR SEND EMAIL' or 'PUT OFF THE PORT AND/OR SEND EMAIL'. For our example, select 'PUT ON THE PORT AND/OR SEND EMAIL'.
Choose the input sensor in the field 'Input Port'. Depending on what you have connected to D6, and D7, you will be presented with the available choices. For this example, select Vin.
In the next field, you have to choose a logical comparator, either 'LESS THAN' or 'GREATER THAN OR EQUAL TO'. For our example select 'GREATER THAN OR EQUAL TO'. This is for the comparison of the sensed value with the Sensor Limit Value.
The device will compare the sensed value from the input sensor Limit Value to make a decision on activating the output port.
In the field 'Sensor Limit Value', enter a value. For our example, enter 1.0.
This means that the device will continuously read Vin and compare it with 1.0Volts. If the value at Vin is greater than or equal to 1.0, the condition for activation of the output port is met.
There are three more field in this form. They are to be filled if the output port must be put off after a duration even if the input condition remains met, and whether the output port must be put on again in a repeat cycle if the condition remains met.
For our example here, let us leave those fields blank and press submit.
If every entry is correct, it will configure the device and will show you portcontrols page of this device showing all the portcontrols that you have configured so far as shown in Fig 48. You may have to scroll the form right to see all the columns of this port control.
You have just one input based port control. That port control will put on RELAY when Vin is 1.0volts or more. Relay will remain ON so long as Vin is greater than or equal to 1.0. Relay will be put OFF when Vin is less that 1.0Volts. You can test this on the device by applying voltage at Vin.
The above control has some drawbacks when the Vin fluctuates rapidly around 1.0Volts. The Relay will keep on putting ON and OFF if Vin fluctuates around 1.0Volts. In systems where you do not want such things to happen, you can add a separate portcontrol to put the relay off. In other words, say, you want the relay to be put on when Vin greater than or equal to 1.0Volts, but once it is ON, you want relay to be OFF only when Vin is less than 0.5Volts.. This can be done by adding one more portcontrol for RELAY. Click on 'ADD INPUT BASED PORT CONTROL' once more and add another port control to put RELAY OFF when Vin is less that 0.5volts as shown in Fig 49.
Enter the values as shown in Fig 49 above and press Submit. It will then show you portcontrol page similar to Fig 50 with two portcontrols for RELAY. The first one is to put RELAY ON and the second one is to put RELAY OFF.
You may test this now by applying voltages at Vin. You will see that the Relay comes ON when Vin is greater than or equal to 1.0. It will stay ON until Vin goes below 0.5Volts.
Note: Make a note of the difference between having just one portcontrol to put the relay ON and having separate portcontrols for putting relay ON and OFF respectively.
As mentioned before, you have three other fields in an input-based portcontrol They are 'Start Delay', 'Repeat Time period' and "Duration to stay active'. These fields can be used if you want the relay to stay active only for a fixed duration when activated and repeat this periodically, instead of keeping it on whenever the input conditions are met. If you want to wait for a delay time to activate relay after the input condition is met, enter that delay time in seconds in 'Start Delay' field.
For example, if you enter 10 seconds for 'Start Delay', delay will be activated only 10 seconds after the input condition is met. And, if you set a duration of, say, 60, the relay will get put off automatically after 60 seconds even if input condition remains met. And, if you enter 60 seconds for "Repeat Time Period', relay will be put on again after 60 seconds. This cycle will repeat until input condition for putting OFF relay is met.
You can generate input based port controls on any output port as per the steps outlined above. You can use any types of inputs connected to the input ports. They can be limit switches, ultrasound sensors, motion sensors, analog inputs, DHT11 temperature/humidity sensor, DS18B20 temperature sensor and so on.
Note: If you are using ON/OFF type sensor, keep in mind that the value read is either 0.0 or 1.0. The the Value field should be either 1.0 (OFF) or 0.0 (ON) when adding an input based port control. If you enter anything above 1.0 for Value when the sensor is an On/OFF type, it will automatically set it as 1.0. Similarly, if you enter less than 1.0 for Value, it will automatically reset it as 0.0..
5.4 Configuring One Device to Control Another Device
Our IOT system has the capability of controlling ports on remote devices based on the conditions sensed by another device. You can configure a device to control another device. You set the port controls of a device such that when a condition on inputs is met, an output port of another remote device is activated. Both devices must be owned by you to make this type of port control. Configuration is the same as describes in the previous section on 'Configuring port control based on Input Condition', except that when choosing Out device, choose the device whose Output port you want to control, instead of 'Self'. Available devices will be seen in the drop down selections. The Out devices have to be in SENSOR/CONTROL mode in 'Use Type' (This setting is in 'Configure Device' under Device Admin). When the 'Use Type' of a device is in Entry or Exit (gate/door), port controls cannot be added. Fig 51 shows an example of adding such a configuration.
Note: When one device controls the other, sensors are on the first device and the equipments that it controls are connected to the other device. Input based port controls must be set up on the first device to which sensors are connected and NOT on the other device to which equipments are connected.
If you own two devices, try setting this and try testing it.
7 Remote Data Collection, Moinitoring and Analysis
Our smart devices can be used for collecting data from remote sensors. You can collect data at periodic intervals and save them in your computer for your records, or for any type of data analysis of your choice. Connect the sensors to the device as explained in section 3.0 on 'Connecting External Equipments and Sensors' in this documentation. Once connected, as explained in that section, you can see the outputs of the sensors by clicking 'Show Devices details' under Device Admin in the Dashboard. By refreshing that page, you can see the updated data. However, this is not ideal for periodic data collection. In this section, you will learn how to collect data from sensors periodically and how to store them in your computer.
7.1 Data Collection at Periodic Time Intervals
Data from sensors of any smart device can be obtained using a python program that makes a call to https://wifisecureaccess.com. Here is a python program that will collect data and and print it on the console terminal as well as write to a file on your local computer.
#!/usr/bin/env python
import time
import requests
import json
import getpass
from threading import Timer
import os
import signal
#
def keyboardInterruptHandler(signal, frame):
print("KeyboardInterrupt (ID: {}) has been caught. Cleaning up...".format(signal))
ti.cancel()
f.close()
exit(0)
def main_loop():
while True:
email = input("Enter email : ")
if email and email != "":
break
email = email.upper()
while True:
password = getpass.getpass()
if password and password != "":
break
while True:
device_name = input("Device Name: ")
if device_name and device_name != '':
break
if device_name.isspace():
print("device name cannot be empty spaces")
exit(1)
Error_code = 1
while Error_code == 1:
try:
time_period = int(input("Time Period for data collection in seconds (no fractions, minimum 1): "))
Error_code = 0
except:
Error_code = 1
if time_period < 1:
print(" Time period is too short for data collection through internet")
exit(1)
while True:
file_name = input("File Name: ")
if file_name and file_name != '':
break
if file_name.isspace():
print("Error. File name cannot be blank spaces")
exit(1)
try:
f = open(file_name, "a+")
except:
print("Unable to open the file %s" % (file_name))
exit(1)
s = requests.session()
url = "https://wifisecureaccess.com/access/devicePortsJson/"
# The labels should be the changed names. That means, if the user has changed the labels, use the changed labels.
# Returned data will have the status of all the input ports of this device
data = {'email': email, 'password': password, 'device_name': device_name,}
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
while True:
r = s.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
#print(res)
if res['result'] and res['result'] == 'SUCCESS':
if 'dev_time' in res:
print('Device_time = %s' % res['dev_time'], end=', ')
f.write('Device_time = %s, ' % res['dev_time'])
if 'Vin' in res:
print('Vin = %s' % res['Vin'], end=', ')
f.write('Vin = %s, ' % res['Vin'])
if 'U_SOUND' in res:
print('Ultra_sound = %s' % res['U_SOUND'], end=", ")
f.write('Ultra_sound = %s, ' % res['U_SOUND'])
if 'D6' in res:
print('D6 = %s' % res['D6'], end=', ')
f.write('D6 = %s, ' % res['D6'])
if 'D7' in res:
print('D7 = %s' % res['D7'], end=', ')
f.write('D7 = %s, ' % res['D7'])
if 'D6_temp_c' in res:
print('D6_tem_c = %s' % res['D6_temp_c'], end=', ')
f.write('D6_tem_c = %s, ' % res['D6_temp_c'])
if 'D6_temp_f' in res:
print('D6_temp_f = %s' % res['D6_temp_f'], end=', ')
f.write('D6_temp_f = %s, ' % res['D6_temp_f'])
if 'D6_humidity' in res:
print('D6_humidity = %s' % res['D6_humidity'], end=', ')
f.write('D6_humidity = %s, ' % res['D6_humidity'])
if 'D7_temp_c' in res:
print('D7_tem_c = %s' % res['D7_temp_c'], end=', ')
f.write('D7_tem_c = %s, ' % res['D7_temp_c'])
if 'D7_temp_f' in res:
print('D7_temp_f = %s' % res['D7_temp_f'], end=', ')
f.write('D7_temp_f = %s, ' % res['D7_temp_f'])
if 'D7_humidity' in res:
print('D7_humidity = %s' % res['D7_humidity'], end=', ')
f.write('D7_humidity = %s, ' % res['D7_humidity'])
print()
f.write("\r\n")
time.sleep(time_period)
else:
if 'msg' in res:
msg = res['msg']
else:
msg = ""
print("FAIL: ", msg)
f.close()
break
else:
print("FAIL. Device not communicating")
print(r)
f.close()
break
if __name__ == '__main__':
main_loop()
When run, the program will prompt for your user name and password for wifisecureaccess.com. It will also ask for the file name on your local computer to save the data.
And, here is a snapshot of the screen running this test program:
The above program makes a call to the server at every specified time period. And, it prints out the return values in a single line. You may modify this program if you want it to write the data in any other format.
You may use any of your analytical tools to analyse the data collected in a file..
Note: If you have changed the labels of the inputs, you may have to modify the above program to reflect those changes. The default labels of input ports are 'Vin', 'D6', 'D7' and 'U_SOUND'. When a json call is made to "https://wifisecureaccess.com/access/devicePortsJson/", the return parameters are: {'dev_time': device_time_string, 'Vin': vin in float, ''D6': 'ON or 'OFF', 'D7': 'ON' or 'OFF', 'U_SOUND': usound reading in float, 'D6_temp_c': D6 temperature in C(float), 'D6_tenp_f': D6 temperature in F (float), 'D6_humidity': D6 humidity(float), 'D7_temp_c': D7 temperature in C(float), 'D7_tenp_f': D7 temperature in F (float), 'D7_humidity': D7 humidity(float),}. Refer to the python program to see how these parameters are handled. You can print res in the program to know its format.
This data colection is done from a remote sensor over the internet. So, the precision and accuracy of the time period cannot be guaranteed, as it depends on the internet. Also, avoid using very short intervals of data collection. Time period less than 1 second will not be accepted by the system.
7.2 Reading Data From Any Port of Your devices Using Your Own Program
If you are interested in reading data from any port of your devices using your own program on your local computer, you can incorporate the following python code into your code. This python program makes a call to https://wifisecureaccess.com with your credentials. You can specify the port name as well as the device name. The python program returns the data from that port and prints it on terminal. When you incorporate this program into your codes, you can do whatever you want to do with that read data instead of printing on the terminal. This code becomes useful if you plan to write your own program to control ports of any of your devices based on other conditions which are outside the sensor values of any of your devices.
#!/usr/bin/env python
import requests
import json
import getpass
def main_loop():
while True:
email = input("Enter email : ")
if email and email != "":
break
email = email.upper()
while True:
password = getpass.getpass()
if password and password != "":
break
while True:
device_name = input("Device Name: ")
if device_name and device_name != '':
break
if device_name.isspace():
print("device name cannot be empty spaces")
exit(1)
while True:
port_name = input("Inport Name: ")
if port_name and port_name != '':
break
if port_name.isspace():
print("Port name cannot be empty spaces")
exit(1)
s = requests.session()
url = "https://wifisecureaccess.com/access/devicePortsJson/"
# The port_name should be the changed label name of the port. That means, if the user has changed the labels, use the changed labels.
#For example, if you have changed the label D6 to something like 'MyPort', you should be using 'MyPort' in these programs for inport name instead of D6
data = {'email': email, 'password': password, 'device_name': device_name,}
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
r = s.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
print(res)
if res['result'] and res['result'] == 'SUCCESS':
if port_name in res:
print(port_name, ': ', res[port_name])
else:
print("%s does not exist in the device" % (port_name))
print("Received Port Names and their current status are: %s" % (res))
elif res['msg']:
print(res['msg'])
else:
print("Server error or communication error")
if __name__ == '__main__':
main_loop()
When run, the above program prompts for your email address, password, device name and port name. It then, makes a call to the server and returns the value from that port. It prints that value on your terminal. If the port name is an output port, it displays the current state of that output port (ON or OFF). If it is an input port, it displays the data read from that port.
7.3 Putting ON/OFF any OutPort of any of Your devices Using Your Own Program
You can also put ON or OFF any ouput port of any of your devices using your own program. Given below is a python program to do that. When run, the program prompts for your email, password, device name, the name of the outport and whether you want to put it ON or OFF. It then puts that port ON or OFF depending on what you requested and prints the final status of that port.
#!/usr/bin/env python
import requests
import json
import getpass
from datetime import datetime
import pytz
def main_loop():
while True:
email = input("Enter email : ")
if email and email != "":
break
email = email.upper()
while True:
password = getpass.getpass()
if password and password != "":
break
while True:
device_name = input("Device Name: ")
if device_name and device_name != '':
break
if device_name.isspace():
print("device name cannot be empty spaces")
exit(1)
while True:
port_name = input("Outport Name: ")
if port_name and port_name != '':
break
if port_name.isspace():
print("Outport name cannot be empty spaces")
exit(1)
while True:
on_off = input("ON or OFF ? : ")
if on_off == 'ON' or on_off == 'OFF':
break
s = requests.session()
url = "https://wifisecureaccess.com/access/devicePortsJson/"
# The port_name should be the changed label name of the port. That means, if the user has changed the labels, use the changed labels.
#For example, if you have changed the label P0 to something like 'MyOutPort', you should be using 'MyoutPort' in these programs for Outport name instead of P0
data = {'email': email, 'password': password, 'device_name': device_name, 'port_name': port_name, 'action': on_off,}
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
r = s.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
#print(res)
if res['result'] and res['result'] == 'SUCCESS':
if port_name in res:
print(port_name, ': ', res[port_name])
else:
print("%s does not exist in the device" % (port_name))
print("Received Port Names and their current status are: %s" % (res))
elif res['msg']:
print(res['msg'])
else:
print("Server error or communication error")
if __name__ == '__main__':
main_loop()
The programs in sections 7.2 and 7.3 can be used for controlling any port of any of your devices using your own program, if you so desire. Normally, there will not be any need to write any of your code as almost all your requirements can be met with just configuring devices as per the steps given in sections 5, 6 and 7. However, for those hobby enthusiasts as well as developers with special needs, these two methods in section 7.2 and 7.3 will be helpful.
8 Integration with your other Apps and programs
WiFiSecureAccess system has web interfaces that can be used by any of your applications programs or any other Apps to open or close the garage door. From your applications, you can make an HTTPS POST call to url https://wifisecureaccess.com/devicePortsJson/ giving your credentials and the name of your device and the action to be taken in a JSON format.
8.1 Activating an output port with an HTTPS POST call
To turn On or OFF an output port of a device, make an HTTPS POST call with the following details:
POST HTTP/1.1
Host: wifisecureaccess.com/devicePortsJson/
Content-Type: application/json
Provide the credentials and data in the following JSON format:
data = {
"email": email,
"password": password,
"device_name": device_name,
"action": action,
}
--where email and password are the email address and password of the owner of the device connected to your controller. device_name is the name of this device. action should be either "ON" or "OFF". If you want to turn ON the device, action must be "ON", and if you want to turn it OFF, action must be "OFF".
If a POST call is made as per that above format, the the output port of the device will be activated as per the action specified. Refer to the following sample python program. This sample call will turn ON the port.
#!/usr/bin/env python
import requests
import json
def main_loop():
url = "https://wifisecureaccess.com/access/devicePortsJson/"
#the following are just an example. replace these with your's.
device_name = 'My Controller' # Replace this with the name of your device
email = "tester@gmail.com"
password = "12345678"
action = "ON"
data = {'email': email, 'password': password, 'device_name': device_name, 'action': action,}
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
r = requests.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
if res['result'] and res['result'] == 'SUCCESS':
print("SUCCESS")
elif res['msg']:
print(res['msg'])
else:
print("FAIL")
else:
print("Server error or communication error")
if __name__ == '__main__':
main_loop()
8.2 HTTPS call to add or remove allowed Users
Repeating what we said in section 4-4 above ...
You can populate the allowed users of any group from any of your applications such as a booking platform using an HTTPS call. This feature helps integrate the WiFiSecureaccess door controller with your applications such as a booking platform. If these devices are installed, for example, on the door of a hotel room or an AirBnB room, the application platform that makes the booking can enter the customer's email and their start date and expiry date directly into the allowed user's list of the group associated with the controller device. If done, the customer will be allowed to open the door during the period between start-date and expiry-date. The customers can open the door either by a voice prompt, or by scanning the QRCode or NFC tag fixed on the door. Thus, this is an ideal system for hotels and AirBnB users. This eliminates the need to pass on the keys or access cards to the customer.
To add the user to the device's group, make an HTTPS POST call with the following details:
POST HTTP/1.1
Host: wifisecureaccess.com/loadAllowedUsersJson/
Content-Type: application/json
data = {
"email": your_email,
"password": your_password,
"device_group_name": device_group_name,
"customers": customers
}
-where customers is a double list of customer details.
customers = [customer1, customer2, customer3, ....]
-where each customer is a list as below:
[email_address, start_date, expiry_date]
For example, if you want to add two customers to the allowed group of a device, the customers should be as follows:
customer1 = [customer1_email, customer1_start_date, customer1_expiry_date]
customer2 = [customer2_email, customer2_start_date, customer2_expiry_date]
customers = [customer1, customer2]
Note: Leave start date and expiry date as "", if there is no start date or end date for that customer. If there is no start date, that means that the customer can access immediately. If there is no expiry date, the customer is authorized forever.
Here is a sample program to add two customers as allowed members in a device group named test_group:
#!/usr/bin/env python
import requests
import json
def main_loop():
email = 'tester@gmail.com' # Replace this with your email address
password = 'password' # Replace with your password of your account with wifisecureaccess.com
url = "https://wifisecureaccess.com/access/loadAllowedUsersJson/"
#customer = [[customer_email, dt_start_str, dt_exp_str[, [.....], [.....],]
customers = [['customer1@gmail.com', '2021-09-24 10:30', '2021-09-25 10:30'], ['customer2@gmail.com', '', ''],]
data = {'email': email, 'password': password, 'device_group_name': 'test_group', 'customers': customers,}
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
r = requests.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
#print(res)
if res['result'] and res['result'] == 'SUCCESS':
print(res['msg'])
else:
print('Error_code = ', res['Error_code'], res['msg'])
if __name__ == '__main__':
main_loop()
You can also remove any customer from the device's group with another HTTPS call as follows:
POST HTTP/1.1
Host: wifisecureaccess.com/removellowedUsersJson/
Content-Type: application/json
data = {
"email": your_email,
"password": your_password,
"device_group_name": device_group_name,
"customers": customers
}
-where customers is a list of email address of the customers that you want to remove from the allowed list.
customers = [customer1_email, customer2_email, ......].
And, here is a sample program showing how to make an HHTPS call to remove a customer from the allowed list of a group.
#!/usr/bin/env python
import requests
import json
def main_loop():
email = 'tester@gmail.com' # replace with your email address
password = 'password' # Replace this with your password of your account with wifisecureaccess.com
url = "https://wifisecureaccess.com/access/removeAllowedUsersJson/"
customers = ['customer1@gmail.com', 'customer2@gmail.com',]
data = {'email': email, 'password': password, 'device_group_name': 'test_group', 'customers': customers,}
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
r = requests.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
#print(res)
if res['result'] and res['result'] == 'SUCCESS':
print(res['msg'])
else:
print('Error_code = ', res['Error_code'], res['msg'])
if __name__ == '__main__':
main_loop()
9 Copying Use Records to Local Computer
Our system keeps all the use records and parking records for 30 days only. However, our customers can copy these records at frequent intervals to their computer and store them longer. They can also use their own dedicated data analysis tools to analyze these data. A simple program making a json call to our url will provide you these use records in json format. Given in this section are some sample test program to copy these records.
9.1 Copying Device Use Records
'Device Use Records' have the information of anybody's using this device. The owner of a device can see the use records in Dashboard by clicking 'Device Use Records' under 'Device Admin'. These records can also be copied at frequent intervals to your local computer. Given below is an example of a program to copy these records.
#!/usr/bin/env python
import requests
import json
import getpass
import os
def main_loop():
while True:
email = input("Enter email : ")
if email and email != "":
break
email = email.upper()
while True:
password = getpass.getpass()
if password and password != "":
break
while True:
device_name = input("Device Name: ")
if device_name and device_name != '':
break
if device_name.isspace():
print("device name cannot be empty spaces")
exit(1)
while True:
start_date = input("Start Date (yyyy-mm-dd hh:mm): ")
if start_date and start_date != '':
break
if start_date.isspace():
print("start_date cannot be blank spaces")
exit(1)
while True:
end_date = input("End Date (yyyy-mm-dd hh:mm): ")
if end_date and end_date != '':
break
if end_date.isspace():
print("End_date cannot be empty spaces")
exit(1)
while True:
file_name = input("File Name: ")
if file_name and file_name != '':
break
if file_name.isspace():
print("Error. File name cannot be blank spaces")
exit(1)
s = requests.session()
n_next = 0
url = "https://wifisecureaccess.com/access/get_useRecordsJson/"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
try:
f = open(file_name, "a+")
except:
print("Unable to open the file %s" % (file_name))
exit(1)
while True:
data = {'email': email, 'password': password, 'records_type': 'device', 'device_name': device_name, 'start_date': start_date, 'end_date': end_date, 'n_next': n_next,}
r = s.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
if res['result'] and res['result'] == 'SUCCESS':
if n_next == 0:
print("Field Names: ", res['field_names'])
if os.stat(file_name).st_size == 0:
field_names = res['field_names']
for field_name in field_names:
f.write(field_name)
f.write(", ")
f.write("\r\n\r\n")
records = res['records']
for record in records:
for value in record:
if not value:
value = ''
print(value, end=", ")
f.write(value)
f.write(", ")
print()
f.write("\r\n")
n_next = res['n_next']
records_remaining = res['records_remaining']
if records_remaining == 0:
break
else:
if 'msg' in res:
msg = res['msg']
else:
msg = ""
print("FAIL: ", msg)
break
else:
print(r)
print("FAIL: Communication error")
break
f.close()
if __name__ == '__main__':
main_loop()
And, here is a screenshot of the terminal running this program:
The above program makes a call to the server. And, it prints out the records on the terminal window of the user's computer. It also appends the same data to the specified local file. Note that it appends the data to the file instead of creating a new file so that records read earlier will not be lost. You can use the data in the file for doing any analysis of the data. The System keeps the use records for 30 days only. So, the owner of the device may read this record, say, every 15 days giving the start data and end date appropriately so that you copy the data from the last end_date. As the program appends the new data to the file, all the previously read records are also in the same file. In doing so, you will have the complete record of as many days as you want.
Note: the first line of the file will have the field names. Subsequent lines in the file are the records.
9.2 Copying Group Use Records
Group records is the use records of a group, showing who used the devices in this group and when. These records can be seen on the dashboard by clicking 'Group Records' under Device Groups in Dashboard. To copy the same records into your computer, you need a program to make calls to the IOT server. Given below is a program to do that.
#!/usr/bin/env python
import requests
import json
import getpass
import os
def main_loop():
while True:
email = input("Enter email : ")
if email and email != "":
break
email = email.upper()
while True:
password = getpass.getpass()
if password and password != "":
break
while True:
group_name = input("Group Name: ")
if group_name and group_name != '':
break
if group_name.isspace():
print("group name cannot be blank spaces")
exit(1)
while True:
start_date = input("Start Date (yyyy-mm-dd hh:mm): ")
if start_date and start_date != '':
break
if start_date.isspace():
print("start_date cannot be blank spaces")
exit(1)
while True:
end_date = input("End Date (yyyy-mm-dd hh:mm): ")
if end_date and end_date != '':
break
if end_date.isspace():
print("End_date cannot be empty spaces")
exit(1)
while True:
file_name = input("File Name: ")
if file_name and file_name != '':
break
if file_name.isspace():
print("Error. File name cannot be blank spaces")
exit(1)
s = requests.session()
n_next = 0
url = "https://wifisecureaccess.com/access/get_useRecordsJson/"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
try:
f = open(file_name, "a+")
except:
print("Unable to open the file %s" % (file_name))
exit(1)
while True:
data = {'email': email, 'password': password, 'records_type': 'group', 'group_name': group_name, 'start_date': start_date, 'end_date': end_date, 'n_next': n_next,}
r = s.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
if res['result'] and res['result'] == 'SUCCESS':
if n_next == 0:
print("Field Names: ", res['field_names'])
if os.stat(file_name).st_size == 0:
field_names = res['field_names']
for field_name in field_names:
f.write(field_name)
f.write(", ")
f.write("\r\n\r\n")
records = res['records']
for record in records:
for value in record:
if not value:
value = ''
print(value, end=', ')
f.write(value)
f.write(", ")
print()
f.write("\r\n")
n_next = res['n_next']
records_remaining = res['records_remaining']
if records_remaining == 0:
break
else:
if 'msg' in res:
msg = res['msg']
else:
msg = ""
print("FAIL: ", msg)
break
else:
print(r)
print("FAIL: Communication error")
break
f.close()
if __name__ == '__main__':
main_loop()
And, here is a sample snapshot of a terminal running this program:
The above program makes a call to the server. And, it prints the records on the terminal of your computer. It also appends the same data to the specified file on your local computer. Note that it appends the data to the file instead of creating a new file so that all previously read data are retained in the file. This data in the file will help you analyse it using any of your sophisticated tools. Keep in mid that the system keeps records for 30 days only. So, you will have to copy the records, say, every 15 days or so giving the start date as the end date given when copying data last time. As the program appends the data to the same file, it will have all the previously read data as well. That way, your file will have all the records for a much longer time.
9.3 Copying Customer Use Records
Customer use records are the records of a customer's use of all the devices in the system. You can see your use records of any devices in the system in Dashboard by clicking 'My Use Records' under 'User Admin' in Dashboard. If you want the same records copied into your local computer to keep the data for longer time, or to do detailed data analysis for your special needs, you need a program to make calls to the server. Given below is a program in python to get these records from the server.
#!/usr/bin/env python
import requests
import json
import getpass
import os
def main_loop():
while True:
email = input("Enter email : ")
if email and email != "":
break
email = email.upper()
while True:
password = getpass.getpass()
if password and password != "":
break
while True:
start_date = input("Start Date (yyyy-mm-dd hh:mm): ")
if start_date and start_date != '':
break
if start_date.isspace():
print("start_date cannot be blank spaces")
exit(1)
while True:
end_date = input("End Date (yyyy-mm-dd hh:mm): ")
if end_date and end_date != '':
break
if end_date.isspace():
print("End_date cannot be empty spaces")
exit(1)
while True:
file_name = input("File Name: ")
if file_name and file_name != '':
break
if file_name.isspace():
print("Error. File name cannot be blank spaces")
exit(1)
s = requests.session()
n_next = 0
url = "https://wifisecureaccess.com/access/get_useRecordsJson/"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
try:
f = open(file_name, "a+")
except:
print("Unable to open the file %s" % (file_name))
exit(1)
while True:
data = {'email': email, 'password': password, 'records_type': 'customer', 'start_date': start_date, 'end_date': end_date, 'n_next': n_next,}
r = s.post(url, data=json.dumps(data), headers=headers)
if r.status_code == requests.codes['ok']:
res = r.json()
if res['result'] and res['result'] == 'SUCCESS':
if n_next == 0:
print("Field Names: ", res['field_names'])
if os.stat(file_name).st_size == 0:
field_names = res['field_names']
for field_name in field_names:
f.write(field_name)
f.write(", ")
f.write("\r\n\r\n")
records = res['records']
for record in records:
for value in record:
if not value:
value = ''
print(value, end=", ")
f.write(value)
f.write(", ")
print()
f.write("\r\n")
n_next = res['n_next']
records_remaining = res['records_remaining']
if records_remaining == 0:
break
else:
if 'msg' in res:
msg = res['msg']
else:
msg = ""
print("FAIL: ", msg)
break
else:
print(r)
print("FAIL: Communication error")
break
f.close()
if __name__ == '__main__':
main_loop()
And, here is an example snapshot of a local terminal running this program.
The above program makes a call to the server. Refer to the suggestions given for reading group records in the previous section about copying records. Those comments apply here as well.