Door sensor #
Proprietary IoT device. A door sensor device in two pieces, which is part of a proprietary Internet of Things (IoT) solution, was installed near the top of the door of a dormitory room. Door sensor events, including door opening and closing events, were persistently logged to the servers set up by the vendor.
Proprietary API. Using a packaged solution eliminated the hassle of setting up my own logging server albeit altogether with data privacy. The vendor provided a mobile application with only limited functionality. There was no visualization or export facilities for door sensor logs. It is suggested that vendors develop open API for users who want to manipulate the data themselves.
Data extraction. Using mitmproxy to intercept network traffic of the proprietary application by the vendor, which makes requests to its servers with an undocumented API while the logs are scrolled through in the application interface, I extracted door sensor events data from the JSON responses from server. It was not a difficult reverse engineering effort since the property names were explicit and unobfuscated. Note that timezone correction had to be applied on the extracted event time stamps.
Data plotting. A scatter plot where each data point denotes a door sensor event, with time on the x-axis and date on the y-axis, is generated for visual analysis of event patterns. It is proposed that it may be called a time series dot plot.
Data interpretation. While there is an significantly reduced level of activity during the small hours after midnight, no other patterns are observable in the plot. Nonetheless, the door sensor data may be found useful with appropriate data from other types of sensors, such as thermometer, motion sensor or camera.
Note on door opening and closing. A door opening event and a door closing event do not always come in pairs in the logs, possibly due to missed sensor readings. Nonetheless, the two type of events do come in pairs most of the time and have highly correlated time stamps. Therefore, a differentiation between the two types of events is not readily visualizable in a plot without a very scaled up time axis and hence unnecessary.
Note on sensor data transfer. Note that data from the battery-powered door sensor were sent wirelessly via low-powered ZigBee protocol to a relay device, which would upload data logs via Wi-Fi and emit configurable color light signals upon registering a sensor event.
Relay device for door sensor emitting white light and plugged in a wall socket (2018) (f/3.625, 1/5, ISO 6400)
Temperature and humidity sensor #
Proprietary IoT appliance. A proprietary IoT home appliance was placed on the floor of a room equipped with a thermostat-controlled window type air-conditioner. The appliance contains several environment sensors including the following:
- a temperature sensor with an accuracy of 0.1 degree Celsius
- a humidity sensor with an accuracy of 1% relative humidity
Proprietary API. While the vendor provided a mobile application with graphs of sensor data, the resolution of the time axis was only on the order of magnitude of an hour, and the resolution of the temperature data axis was only 1 degree Celsius. Since fine-grained sensor data was not available in the vendor application, a third-party library found online was used to gather sensor data directly from the WiFi-enabled home appliance via the MQTT protocol.
Data logging. A simple script was written and put on a single board computer to have various sensor data from the appliance collected and recorded every 30 second with a time stamp. The 30-second time interval was chosen as the typical time duration between two different readings observed considering the accuracy of sensors.
Data plotting. Line plots of sensor data against time are generated for analysis. The 30-minute rolling mean interval was chosen for a smooth rolling mean curve as the typical air-conditioner compressor on-off cycle time observed was 25 to 30 minutes. Note that rolling mean is also known as moving average.
The following plot shows the changes in temperature readings as the air-conditioner was switched on with the compressor on during initial cooling, followed by four complete compressor off-then-on cycles. It is observed that the compressor is on for about half of time in each cycle.
The following plot shows the changes in temperature readings for just over a day. The air-conditioner continued with its compressor cycles throughout the night. The gradual decrease in rolling mean temperature could most likely be attributed to a decrease in outside temperature from evening to midnight.
The air-conditioner was switched off in the morning. The temperature increased with a decreasing slope except during two instances of air-conditioner usage.
The following plot shows the changes in humidity readings in the same period. The curves show more ragged shapes since the resolution of humidity sensor data relative to the change in unit data is lower than that for temperature sensor data.
The gradual increase in rolling mean humidity before sunrise could most likely be attributed to an increase in outside humidity from midnight to sunrise.
A scatter plot is generated to show the correlation between temperature and humidity readings in the same period, with the pixel area of markers being the frequency of temperature-humidity data pairs. The Pearson correlation coefficient between the two sets of data is 0.89, indicating strong positive correlation.
- Feb 2021 Added plots of temperature and humidity sensor data.
- Jan 2021 Added photograph of relay device for sensor.