ESP01 IoT Device for Genetec Security Center



Project Goal

The goal of this project is to build a small IoT device capable of sending temperature data to the Genetec Security Center running the IoT Plugin. The device must be inexpensive and somewhat easy to assemble and program. It must work on any wifi network, without having to directly modify config files or change software.


Parts List


Prerequisite Software


Out of Scope

This blog assumes the prerequisite software has been installed:
  • Genetec Security Center has been installed, is licensed, and is running
  • The Genetec IoT Plugin has been installed and the Industrial IoT role has been created
  • The Arduino IDE has been installed and is able to flash a (any) sample sketch to the ESP01


Program the ESP01 

  1. ESP01 with Programmer
    Load this sketch into the Arduino IDE.
  2. Verify the sketch compiles
    • Use the library manager to load any libraries that are missing, such as the WiFiManager
    • Toggle the switch on the programmer towards the yellow socket to enable programming mode.
  3. Insert the ESP01 into the programmer then insert the programmer into a USB port on your PC
  4. Upload the sketch to the ESP01
  5. When successful, remove the ESP01 from the programmer


Assemble the Device

  1. Flip Over the Blue DHT Sensor
    Before Attaching the ESP01

    Carefully flip over the DHT sensor from the sensor module, without breaking the leads
    • The ESP01 chip produces enough heat to skew the temperature reading of the sensor by several degrees. Flipping the DHT sensor out helps minimize this issue.
  2. Insert the ESP01 into the sensor module
  3. Place the device into the case
  4. Attach power to the device, observing polarity
  5. A least one LED should illuminate to indicate the device has power.


Configure the ESP01 for your Wifi Network

NOTE: If I have given you one of these devices pre-assembled, then this is the point in the instructions where you should start.
  1. Upon initial power-up, the ESP01 will go into AP mode
  2. Using your mobile device, attach to the wifi network called "ESPAutoConnectAP"
    • No password is required
  3. Once connected, point your browser to 192.168.4.1
  4. You should be presented with the menu in the figure
  5. Select Configure Wifi
  6. Select the desired wifi network and enter the wifi password
  7. Enter the IP Address of your Security Center Server
  8. Leave the port at 42000
  9. Leave the Device ID set to 1, unless you have more than one device
    • No two devices can have the same Device ID
    • I was testing multiple devices at the time I made the screenshot below, which is why it shows a 2 for the Device ID. Ignore that. Go with 1.
  10. Verify all the entered information is correct, then click save
  11. The ESP device will reboot and attach to your wifi network
WiFi Manager Portal
Click to Enlarge

WiFi Manager Config
Click to Enlarge



Open Port 42000 on the Windows Firewall

  1. Allow Inbound TCP Port 42000
    Click to Enlarge
    From the Security Center server, open the Windows Firewall
  2. Create an Inbound Rule to allow TCP port 42000









Configure the Genetec IoT Plugin - Create the TCP Server

  1. Create TCP Server
    Click to Enlarge
    Navigate to Config Tool -> Plugins Industrial IoT -> Protocols (tab)
  2. Create a new TCP server by clicking the green "+"
  3. Enter the parameters for the new TCP Server exactly as shown in the following figure.
  4. Click Apply to save changes



Configure the Genetec IoT Plugin - Import the Device Template

  1. Import Device TEmplate
    Click to Enlarge
    Download the appropriate device template according to your version of the IoT plugin and save it to your local drive:
  2. Navigate to Config Tool -> Plugins Industrial IoT -> Device Type tab
  3. Import the recently downloaded template by clicking the import button at the bottom of the screen.
  4. Once imported, your screen should look like the figure

Configure the Genetec IoT Plugin - Create the IoT Device from Template

  1. Add ESP Device
    Click to Enlarge
    Navigate to Config Tool -> Plugins Industrial IoT -> Devices tab
  2. Click the green "+" to add a new device
  3. Give the device a name
  4. Select ESP Device from the type dropdown
  5. From the TCP Server dropdown, select the previously created TCP server
    • In my case the TCP Server was named ESP IoT Server
  6. Enter the same Device ID you used when configuring the WiFiManager
    • The default Device ID is 1
  7. Click Add
  8. Finally, click the Apply button in the bottom right corner of the screen


Verify Data is Being Collected

Data from ESP Device
Click to Enlarge
Basic programming is now complete. At this point, Security Center will begin to collect data from the ESP device. The ESP device will send
new temperature data to Security Center every minute.  

You can now display this device on a map and/or leverage the other features of the IoT Plugin to create events, change states, and create rules. 


Troubleshooting


Builtin Web Portal
ESP01 Web Portal
Click to Enlarge
The ESP Device runs a small web portal, which can provide diagnostic information. Simply point your
web browser to the device's ip address on your local wifi network. Use the basic menu to view device status, along with recent error or success messages.

Reconfigure WiFiManager
If any of the information provided to WiFiManager is not correct, then you will need force the device back into AP mode, to allow you to reconfigure the device. To do that, select the "resetwifi" from the ESP web portal. This will prompt for a username and password. The username is "genetec" and the  password is the mac address, in all caps, without colons. This will erase the save wifi credentials then cause the device to reboot back into AP mode.

Temperature Readings Too High
If the DHT temperature sensor consistently reports higher than expected values, then the heat from the ESP01 chip is likely affecting the sensor. We can compensate by periodically sleeping the ESP01. However, the downside to this is, since the ESP01 is asleep most of the time, there is no builtin web portal one can use for troubleshooting. First verify the ESP01 is successfully reporting to Security Center. Once this is verified, reprogram the ESP01 with this sketch. You will not need to reconfigure WiFiManager configuration.

Security Considerations

These instructions are not intended for a production environment. It should be noted that this device will send data, in clear text, to the Security Center server. The ESP device's built-in web portal is standard HTTP protocol, which can be accessed by anyone on the same network, without a password.

Yes, it is possible to program the ESP01 to require authentication before accessing the built-in web portal, and it is also possible to send data to Security Center using HTTPS. However, that is a project for another day.



Comments

Popular posts from this blog

Welcome