Mobile detection method based on Wi-Fi signal similarity
Through a mobile detection method based on Wi-Fi signal similarity, the cosine similarity formula is used to determine the mobile status of the device, which solves the problem of traditional methods relying on specific hardware and realizes low-cost mobile detection without additional hardware, which is suitable for IoT devices. , which improves the real-time performance and applicable scope of detection.
Patent Information
- Application Number
- CN202411044953.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-08-01
AI Technical Summary
Traditional device motion detection methods require specific hardware support, such as acceleration sensors and gyroscopes, which limits their application scope and increases device cost and power consumption.
Using a mobile detection method based on Wi-Fi signal similarity, the device regularly scans surrounding Wi-Fi hotspots, records the identifier and signal strength, and uses the cosine similarity formula to calculate the signal strength similarity between two consecutive scanned data groups to determine Whether the device is moving.
It achieves low-cost motion detection without additional hardware, has a wider application range, strong real-time performance, is suitable for IoT device management and control, and reduces device cost and power consumption.
Smart Images

Figure CN118566533B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of motion detection, and in particular to a motion detection method based on Wi-Fi signal similarity. Background Art
[0002] Traditional device motion detection methods require the device to have specific hardware support, such as accelerometers and gyroscopes, but many devices do not have such hardware support, which limits its application on various devices. If the corresponding hardware structure is added, it will not only increase the device cost, but also increase the device power consumption. Summary of the invention
[0003] In order to achieve low-cost mobile detection while increasing universality, the present application provides a mobile detection method based on Wi-Fi signal similarity.
[0004] The technical solution adopted by the present invention to solve the above problems is:
[0005] The mobile detection method based on Wi-Fi signal similarity includes:
[0006] Step 1: The device periodically scans the surrounding Wi-Fi hotspots and records the identifier and signal strength of each hotspot to form a scan data set;
[0007] Step 2: Based on two consecutive scan data groups, the cosine similarity formula is used to calculate the similarity of the signal strength. If the similarity is greater than a threshold, the device has not moved, otherwise the device has moved.
[0008] Furthermore, in step 1, the device scans continuously N times in each cycle, and an average value of the signal strength of each hotspot N times is used as the final signal strength of the hotspot in the scan data set.
[0009] Furthermore, N is equal to 5.
[0010] Furthermore, the identifier is a base station identifier.
[0011] Furthermore, there are at least two Wi-Fi hotspots in the surrounding area.
[0012] Further, the step 2 is specifically: cosine similarity CosineSimilarity = DotProduct / (Modulus1×Modulus2), wherein DotProduct is the dot product of the signal strengths in the two scan data groups, and Modulus1 and Modulus2 are the moduli of the signal strengths in the two scan data groups, respectively.
[0013] Compared with the prior art, the present invention has the following beneficial effects:
[0014] By analyzing the signal strength changes of the surrounding Wi-Fi hotspots, the average signal strength of each hotspot is calculated, and the cosine similarity is used to compare two consecutive sets of scanning results to determine whether the device has moved. This method can not only provide real-time feedback on the movement status of the device, which is of great significance for the management and control of IoT devices, but also the IoT devices themselves already have the Wi-Fi signal scanning function, so there is no need to add special motion detection sensors such as accelerometers and gyroscopes, which greatly reduces the cost of the device and has a wider range of applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 The figure is a flow chart of a mobile detection method based on Wi-Fi signal similarity. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0017] The mobile detection method based on Wi-Fi signal similarity includes:
[0018] Step 1: The device periodically scans the surrounding Wi-Fi hotspots and records the identifier and signal strength of each hotspot to form a scan data set;
[0019] Step 2: Based on two consecutive scan data groups, the cosine similarity formula is used to calculate the similarity of the signal strength. If the similarity is greater than a threshold, the device has not moved, otherwise the device has moved.
[0020] The device movement detection method of the present invention scans the surrounding Wi-Fi hotspots in real time and uses cosine similarity to compare two consecutive Wi-Fi signal scanning results to determine whether the device has moved. The method does not rely on specific sensors and hardware solutions, does not require additional hardware costs, and has lower power consumption and higher efficiency. In addition, it also has the advantages of strong real-time performance and simple operation, and is particularly suitable for Internet of Things environments that require large-scale device deployment and management.
[0021] By only using software algorithms for calculations, we can continuously optimize the algorithms to improve the accuracy and real-time performance of mobile detection, and continuously improve product competitiveness through OTA.
[0022] Specifically, Figure 1 As shown, the mobile detection method based on Wi-Fi signal similarity includes:
[0023] (1) Wi-Fi scanning: After the device is started, the Wi-Fi scanning function is turned on first. The device will periodically scan the surrounding Wi-Fi hotspots and record the BSSID (base station identifier) and signal strength (RSSI) of each hotspot. This step is achieved by calling the device's Wi-Fi interface, and information about all surrounding Wi-Fi hotspots can be obtained. In this embodiment, BSSID is used as the unique identifier of the hotspot, and other information can also be used as the identifier, which is not limited here.
[0024] Assume that there are 3 hotspots currently scanned, and save the information of these 3 hotspots as a row vector. Each vector element consists of BSSID and signal strength RSSI, such as:
[0025] [{"aa:bb:cc:dd:ee:ff",-10},{"gg:hh:ii:jj:kk:ll",-20},{"mm:nn:oo:pp:qq:rr",-30}].
[0026] (2) Signal strength analysis: In this embodiment, the device will perform five consecutive scans, and the final signal strength in the scan data set is determined by averaging the signal strength of each hotspot in the five consecutive scan results. The average signal strength can more accurately reflect the signal strength of the hotspot.
[0027] When calculating the average value, it is necessary to consider that there may be different situations in the Wi-Fi hotspots in the two scan result lists. For example, if a hotspot with BSSID "aa:bb:cc:dd:ee:ff" is scanned for the first time, but "aa:bb:cc:dd:ee:ff" is not scanned for the second time, the signal strength of the hotspot with BSSID "aa:bb:cc:dd:ee:ff" for the second time is recorded as 0, and the calculation is still based on five times. In this way, the change range of the average value will increase accordingly, which can better reflect the mobility status of the device itself.
[0028] Assume that the results of the 5 scans are:
[0029] [{"aa:bb:cc:dd:ee:ff",-10},{"gg:hh:ii:jj:kk:ll",-20},{"mm:nn:oo:pp:qq:rr",-30}],[{"aa:bb:cc:dd:ee:ff ",-15},{"gg:hh:ii:jj:kk:ll",-22},{"mm:nn:oo:pp:qq:rr",-30}], [{"aa:bb:cc:dd:ee:ff",-12},{"gg:hh:ii:jj :kk:ll",-30},{"mm:nn:oo:pp:qq:rr",-40}], [{"aa:bb:cc:dd:ee:ff",-30},{"gg:hh:ii:jj:kk:ll",-18},{"mm:nn :oo:pp:qq:rr",-50}], [{"gg:hh:ii:jj:kk:ll",-40},{"mm:nn:oo:pp:qq:rr",-30},{"ss:tt:uu:vv:ww:xx",-40}].
[0030] Then the vector of the final calculated average values is:
[0031] [{“aa:bb:cc:dd:ee:ff”,(-10-15-12-30+0) / 5=-13.4},{“gg:hh:ii:jj:kk:ll”,(-20-22-30-18-40) / 5=-26},{“mm:nn:oo:pp:qq:rr”,(-30-30-40-50-30) / 5=-36},{“ss:tt:uu:vv:ww:xx”,(-40+0+0+0+0) / 5=-8}]. In the fifth result, there is no hotspot with BSSID “aa:bb:cc:dd:ee:ff”. At this time, the signal strength is still calculated based on the average of 5 times. At the same time, since a hotspot with a BSSID of "ss:tt:uu:vv:ww:xx" that has not appeared before appears in the fifth result, this hotspot is added to the vector, and its signal strength is still calculated based on the average of 5 times.
[0032] (3) Cosine similarity calculation: Use the cosine similarity formula to calculate the similarity of two consecutive scan results. Specifically, the device will first calculate the dot product (DotProduct) of the two scan results, then calculate the modulus (Modulus) of each scan result, and finally use the following formula to calculate the cosine similarity (CosineSimilarity): CosineSimilarity = DotProduct\(Modulus1×Modulus2), where DotProduct is the dot product of the two scan results, and Modulus1 and Modulus2 are the modulus of the two scan results. In this way, the cosine similarity of the two scan results can be obtained, thereby determining whether the device has moved.
[0033] Regarding the calculation of dot product: Since two sets of scan results are compared, there may be a situation where the BSSID does not match in the two sets of scan results. For example, there is a hotspot with the BSSID name "aa:bb:cc:dd:ee:ff" in the first set of results, but not in the second set. In this case, the RSSI of "aa:bb:cc:dd:ee:ff" in the second set is calculated as 0. The same applies to the situation where the hotspot exists in the second set but not in the first set.
[0034] Assume that there are currently two calculation results, the first set is the average result of the first 5 scans:
[0035] [{"aa:bb:cc:dd:ee:ff",-13.4},{"gg:hh:ii:jj:kk:ll",-26},{"mm:nn:oo:pp:qq:rr",-36},{"ss:tt:uu:vv:ww:xx",-8}],
[0036] The second group is the average results of the last 5 scans:
[0037] [{"aa:bb:cc:dd:ee:ff",-16},{"gg:hh:ii:jj:kk:ll",-22},{"mm:nn:oo:pp:qq:rr",-46},{"yy:zz:aa:bb:cc:dd",-10}].
[0038] The dot product of the two vectors is: [(-13.4)×(-16)]+[(-26)×(-22)]+[(-36)×(-46)]+[(-8)×0]+[0×(-10)]=2442.4.
[0039] Among them, "ss:tt:uu:vv:ww:xx" and "yy:zz:aa:bb:cc:dd" only appear in the first group and the second group respectively. Both do not appear in each other's vector, so the corresponding intensity product is 0.
[0040] The magnitude of the first set of result vectors is =47.1, the modulus of the second set of result vectors is =54.4.
[0041] The final cosine similarity of the two result vectors is: 2442.4÷(47.1×54.4)=0.95.
[0042] (4) Device movement detection: If the calculated cosine similarity is lower than the preset threshold (for example, 0.5), it is determined that the device has moved; otherwise, the device has not moved. The specific value of the threshold can be set according to actual needs and is not limited here.
[0043] (5) Device movement status feedback: The device will feed back the detection results of the movement status to the user or management system in real time. This step is achieved through the communication interface of the device, and the detection results can be sent through a wireless network, a wired network or other communication methods. In this way, the user or management system can understand the movement status of the device in real time and perform corresponding management and control.
[0044] It should be noted that if there is only one Wi-Fi hotspot in the surrounding environment, the accuracy of mobile detection is not high. If there are two Wi-Fi hotspots, the detection accuracy will be higher. The detection accuracy can be improved by appropriately increasing the number of Wi-Fi hotspots.
Claims
1. A mobile detection method based on Wi-Fi signal similarity, characterized in that: include: Step 1: The device periodically scans the surrounding Wi-Fi hotspots and records the identifier and signal strength of each hotspot to form a scan data set; Step 2: Based on two consecutive scan data groups, the similarity of the signal strength is calculated using the cosine similarity formula. If the similarity is greater than a threshold, the device has not moved, otherwise the device has moved; The cosine similarity formula is: CosineSimilarity = DotProduct / (Modulus1×Modulus2), where DotProduct is the dot product of the signal strengths in the two scan data groups, Modulus1 and Modulus2 are the moduli of the signal strengths in the two scan data groups respectively; the dot product of the signal strengths in the two scan data groups refers to the product of the signal strengths of the same identifier; if there is an identifier in the first group but not in the second group, the signal strength of the identifier in the second group is calculated as 0, and the same applies to the identifiers that exist in the second group but not in the first group.
2. The mobile detection method based on Wi-Fi signal similarity according to claim 1, characterized in that: In step 1, the device scans continuously N times in each cycle, and the average value of the signal strength of each hotspot for N consecutive times is used as the final signal strength of the hotspot in the scan data set.
3. The mobile detection method based on Wi-Fi signal similarity according to claim 2, characterized in that: N is 5.
4. The mobile detection method based on Wi-Fi signal similarity according to claim 1, characterized in that: The identifier is a base station identifier.
5. The mobile detection method based on Wi-Fi signal similarity according to claim 1, characterized in that: There are at least 2 Wi-Fi hotspots in the surrounding area.
