{"id":827,"date":"2026-06-12T15:47:05","date_gmt":"2026-06-12T07:47:05","guid":{"rendered":"https:\/\/projectleon.net\/make\/blog\/gps-geofencing-ugv-arduino-boundary-alert-farsi\/"},"modified":"2026-06-12T15:47:05","modified_gmt":"2026-06-12T07:47:05","slug":"gps-geofencing-ugv-arduino-boundary-alert-farsi","status":"publish","type":"post","link":"https:\/\/projectleon.net\/make\/blog\/gps-geofencing-ugv-arduino-boundary-alert-farsi\/","title":{"rendered":"Geofencing \u0628\u0627 GPS: \u0645\u062d\u062f\u0648\u062f \u06a9\u0631\u062f\u0646 \u0646\u0627\u062d\u06cc\u0647 \u062d\u0631\u06a9\u062a UGV \u0628\u0627 \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 (\u0641\u0627\u0631\u0633\u06cc)"},"content":{"rendered":"<div class='hero-image-container' style='margin-bottom:28px;border-radius:14px;overflow:hidden;box-shadow:0 4px 18px rgba(0,0,0,0.08)'>\n<img src='https:\/\/projectleon.net\/make\/wp-content\/uploads\/2026\/06\/post161-gps-geofencing-ugv-1.jpg' alt='Geofencing GPS UGV \u0622\u0631\u062f\u0648\u06cc\u0646\u0648 \u0645\u062d\u062f\u0648\u062f\u0647 \u062d\u0631\u06a9\u062a' style='width:100%;height:auto;display:block' loading='eager'\/>\n<\/div>\n<div class='beginner-intro' style='background:#f0f7ff;border-right:4px solid #2e5fb6;padding:16px 20px;border-radius:10px;margin-bottom:22px'>\n<h2 style='margin-top:0'>Geofencing \u2014 \u062d\u0635\u0627\u0631 \u062c\u063a\u0631\u0627\u0641\u06cc\u0627\u06cc\u06cc \u062f\u06cc\u062c\u06cc\u062a\u0627\u0644<\/h2>\n<p><strong>Geofencing<\/strong> \u06cc\u0639\u0646\u06cc \u062a\u0639\u0631\u06cc\u0641 \u06cc\u06a9 \u0645\u0646\u0637\u0642\u0647 \u062c\u063a\u0631\u0627\u0641\u06cc\u0627\u06cc\u06cc (\u0628\u0627 \u0645\u062e\u062a\u0635\u0627\u062a GPS) \u0648 \u062a\u0639\u06cc\u06cc\u0646 \u0642\u0627\u0646\u0648\u0646 \u0628\u0631\u0627\u06cc \u0631\u0641\u062a\u0627\u0631 UGV \u0648\u0642\u062a\u06cc \u0627\u0632 \u0622\u0646 \u0645\u0646\u0637\u0642\u0647 \u062e\u0627\u0631\u062c \u0645\u06cc\u200c\u0634\u0648\u062f \u2014 \u0645\u062b\u0644\u0627\u064b \u062a\u0648\u0642\u0641\u060c \u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u062e\u0627\u0646\u0647\u060c \u06cc\u0627 \u0627\u0631\u0633\u0627\u0644 \u0647\u0634\u062f\u0627\u0631. \u06a9\u0627\u0631\u0628\u0631\u062f\u0647\u0627: \u06a9\u0634\u0627\u0648\u0631\u0632\u06cc \u062f\u0642\u06cc\u0642 (UGV \u0641\u0642\u0637 \u062f\u0631 \u0645\u0632\u0631\u0639\u0647 \u062e\u0648\u062f\u062a \u0628\u0645\u0627\u0646\u062f)\u060c \u062a\u062d\u0648\u06cc\u0644 \u0631\u0628\u0627\u062a (\u0641\u0642\u0637 \u062f\u0631 \u0645\u062d\u0648\u0637\u0647 \u0645\u062c\u0627\u0632)\u060c \u0648 \u0627\u06cc\u0645\u0646\u06cc \u0639\u0645\u0648\u0645\u06cc.<\/p>\n<p>\u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 <strong>Ray Casting (Point-in-Polygon)<\/strong> \u062a\u0639\u06cc\u06cc\u0646 \u0645\u06cc\u200c\u06a9\u0646\u062f \u0622\u06cc\u0627 \u0646\u0642\u0637\u0647 \u0641\u0639\u0644\u06cc GPS \u062f\u0627\u062e\u0644 \u0686\u0646\u062f \u0636\u0644\u0639\u06cc \u062a\u0639\u0631\u06cc\u0641\u200c\u0634\u062f\u0647 \u0627\u0633\u062a \u06cc\u0627 \u062e\u0627\u0631\u062c \u2014 \u0631\u0648\u0634\u06cc \u0633\u0627\u062f\u0647 \u0648 \u06a9\u0627\u0631\u0622\u0645\u062f \u062d\u062a\u06cc \u0628\u0631\u0627\u06cc \u0622\u0631\u062f\u0648\u06cc\u0646\u0648.<\/p>\n<\/div>\n<h2>\u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 Ray Casting \u2014 \u06a9\u062f \u0622\u0631\u062f\u0648\u06cc\u0646\u0648<\/h2>\n<pre style='background:#1e1e1e;color:#d4d4d4;padding:14px;border-radius:8px;font-size:12px;margin-bottom:18px'><code>#include &lt;TinyGPS++.h&gt;\n\n\/\/ ===== \u062a\u0639\u0631\u06cc\u0641 \u0645\u0631\u0632 Geofence (\u0686\u0646\u062f \u0636\u0644\u0639\u06cc \u06f4 \u06af\u0648\u0634\u0647 \u2014 \u0645\u062b\u0627\u0644) =====\nconst int NUM_VERTS = 4;\ndouble fenceLat[] = {35.7120, 35.7135, 35.7135, 35.7120};\ndouble fenceLng[] = {51.4050, 51.4050, 51.4070, 51.4070};\n\nbool pointInPolygon(double lat, double lng){\n  bool inside = false;\n  for(int i=0, j=NUM_VERTS-1; i<NUM_VERTS; j=i++){\n    if(((fenceLat[i]>lat) != (fenceLat[j]>lat)) &&\n       (lng < (fenceLng[j]-fenceLng[i])*(lat-fenceLat[i])\/(fenceLat[j]-fenceLat[i])+fenceLng[i])){\n      inside = !inside;\n    }\n  }\n  return inside;\n}\n\nTinyGPSPlus gps;\n\nvoid loop(){\n  while(Serial1.available()) gps.encode(Serial1.read());\n\n  if(gps.location.isValid()){\n    bool safe = pointInPolygon(gps.location.lat(), gps.location.lng());\n    if(!safe){\n      \/\/ \u0645\u0631\u0632 \u0646\u0642\u0636 \u0634\u062f!\n      stopMotors();\n      sendLoRaAlert(\"GEOFENCE BREACH!\");\n    }\n  }\n}\n\nvoid stopMotors(){\n  analogWrite(ENA, 0); analogWrite(ENB, 0);\n}\n\nvoid sendLoRaAlert(String msg){\n  LoRa.beginPacket();\n  LoRa.print(msg);\n  LoRa.endPacket();\n}<\/code><\/pre>\n<h2>\u062a\u0639\u0631\u06cc\u0641 \u0645\u0631\u0632 \u0627\u0632 Google Earth<\/h2>\n<ol style='line-height:2.2'>\n<li>\u062f\u0631 Google Earth Pro \u0631\u0648\u06cc \u0645\u062d\u062f\u0648\u062f\u0647 \u0645\u0648\u0631\u062f \u0646\u0638\u0631 \u06cc\u06a9 Polygon \u0628\u06a9\u0634.<\/li>\n<li>\u06a9\u0644\u06cc\u06a9\u200c\u0631\u0627\u0633\u062a \u2192 Properties \u2192 Coordinates \u0631\u0627 \u06a9\u067e\u06cc \u06a9\u0646.<\/li>\n<li>\u0645\u0642\u0627\u062f\u06cc\u0631 lat\/lng \u0631\u0627 \u062f\u0631 \u0622\u0631\u0627\u06cc\u0647\u200c\u0647\u0627\u06cc fenceLat \u0648 fenceLng \u0642\u0631\u0627\u0631 \u0628\u062f\u0647.<\/li>\n<li>\u062f\u0642\u062a GPS ~\u06f2.\u06f5m \u0627\u0633\u062a \u2014 \u0645\u0631\u0632 \u0631\u0627 \u062d\u062f\u0627\u0642\u0644 \u06f1\u06f0m \u0627\u0632 \u0645\u0648\u0627\u0646\u0639 \u0648\u0627\u0642\u0639\u06cc \u062f\u0648\u0631\u062a\u0631 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646.<\/li>\n<\/ol>\n<h2>\u062c\u062f\u0648\u0644 \u0631\u0641\u062a\u0627\u0631 \u062f\u0631 \u0646\u0642\u0636 \u0645\u0631\u0632<\/h2>\n<table style='width:100%;border-collapse:collapse;margin-bottom:18px'>\n<thead>\n<tr style='background:#ffebee'>\n<th style='padding:8px;border:1px solid #ddd;text-align:right'>\u0633\u0646\u0627\u0631\u06cc\u0648<\/th>\n<th style='padding:8px;border:1px solid #ddd;text-align:right'>\u0631\u0641\u062a\u0627\u0631 \u062a\u0648\u0635\u06cc\u0647\u200c\u0634\u062f\u0647<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style='padding:7px;border:1px solid #ddd'>\u0646\u0632\u062f\u06cc\u06a9 \u0645\u0631\u0632 (\u06f5m)<\/td>\n<td style='padding:7px;border:1px solid #ddd'>\u06a9\u0627\u0647\u0634 \u0633\u0631\u0639\u062a \u0628\u0647 \u06f5\u06f0\u066a<\/td>\n<\/tr>\n<tr style='background:#fafafa'>\n<td style='padding:7px;border:1px solid #ddd'>\u0631\u0648\u06cc \u0645\u0631\u0632<\/td>\n<td style='padding:7px;border:1px solid #ddd'>\u062a\u0648\u0642\u0641 \u06a9\u0627\u0645\u0644<\/td>\n<\/tr>\n<tr>\n<td style='padding:7px;border:1px solid #ddd'>\u062e\u0627\u0631\u062c \u0627\u0632 \u0645\u0631\u0632<\/td>\n<td style='padding:7px;border:1px solid #ddd'>\u062a\u0648\u0642\u0641 + \u0647\u0634\u062f\u0627\u0631 LoRa + \u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u062e\u0627\u0646\u0647<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style='display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:18px;margin:20px 0'>\n<iframe width='100%' height='280' src='https:\/\/www.youtube.com\/embed\/ZLIkJM_0T9w' title='GPS Geofencing Arduino Tutorial' frameborder='0' allowfullscreen><\/iframe><br \/>\n<iframe width='100%' height='280' src='https:\/\/www.youtube.com\/embed\/BFXAhpGaqsA' title='Point in Polygon GPS Boundary Check' frameborder='0' allowfullscreen><\/iframe>\n<\/div>\n<ul>\n<li><a href='https:\/\/wrfranklin.org\/Research\/Short_Notes\/pnpoly.html' target='_blank'>WR Franklin: \u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 PNPOLY \u2014 \u0645\u0631\u062c\u0639 \u0627\u0635\u0644\u06cc<\/a><\/li>\n<li><a href='https:\/\/www.aparat.com\/result\/%D9%85%D8%AD%D8%AF%D9%88%D8%AF%D9%87+%D8%AC%D8%BA%D8%B1%D8%A7%D9%81%DB%8C%D8%A7%DB%8C%DB%8C+GPS' target='_blank'>\u0622\u067e\u0627\u0631\u0627\u062a: \u0645\u062d\u062f\u0648\u062f\u0647 \u062c\u063a\u0631\u0627\u0641\u06cc\u0627\u06cc\u06cc GPS<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u0622\u0645\u0648\u0632\u0634 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc Geofencing \u0628\u0631\u0627\u06cc UGV: \u062a\u0639\u0631\u06cc\u0641 \u0645\u0631\u0632 \u0686\u0646\u062f \u0636\u0644\u0639\u06cc \u0628\u0627 \u0645\u062e\u062a\u0635\u0627\u062a GPS\u060c \u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 Point-in-Polygon\u060c \u0645\u062a\u0648\u0642\u0641 \u06a9\u0631\u062f\u0646 UGV \u062f\u0631 \u0645\u0631\u0632\u060c \u0647\u0634\u062f\u0627\u0631 LoRa \u0648 \u0644\u0627\u06af \u0646\u0642\u0636 \u0645\u0631\u0632.<\/p>\n","protected":false},"author":1,"featured_media":826,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[19,16],"tags":[602,47,44,82,603,48,21,604],"class_list":["post-827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials-2","category-ugv","tag-geofencing","tag-gps","tag-lora","tag-neo-6m","tag-point-in-polygon","tag-ugv","tag-arduino","tag-604"],"_links":{"self":[{"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/comments?post=827"}],"version-history":[{"count":1,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"predecessor-version":[{"id":828,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/posts\/827\/revisions\/828"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/media\/826"}],"wp:attachment":[{"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projectleon.net\/make\/wp-json\/wp\/v2\/tags?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}