Geofence suddenly goes from being within the radius to not being in Radius

The Antenna has not moved from the spot that it was initialized. But the Geofence function will suddenly start returning a 0 for the combined state.

Any suggestions as to how to solve the problem.

Hardware List:

Thing Plus - ESP32 WROOM - WRL-15663

GPS Breakout - NEO-M9N, SMA (Qwiic) - GPS-17285

GPS/GNSS Magnetic Mount Antenna - 3m (SMA) - GPS-14986

Output from the program:

16:45:00.774 → ets Jun 8 2016 00:22:57

16:45:00.774 →

16:45:00.774 → rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

16:45:00.774 → configsip: 0, SPIWP:0xee

16:45:00.774 → clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

16:45:00.774 → mode:DIO, clock div:1

16:45:00.774 → load:0x3fff0018,len:4

16:45:00.774 → load:0x3fff001c,len:1044

16:45:00.774 → load:0x40078000,len:10124

16:45:00.774 → load:0x40080400,len:5856

16:45:00.774 → entry 0x400806a8

16:45:00.961 →

16:45:00.961 →

16:45:00.961 →

16:45:00.961 →

16:45:02.039 → Fix: 3 = 3D . # of Sat: 13

16:45:03.023 → 3D fix found!

16:45:03.117 → Version: 32.1

16:45:03.164 → Lat: 297723127 Long: -955988060

16:45:03.164 → Clearing any existing geofences. clearGeofences returned: 1

16:45:03.164 → Setting the geofences:

16:45:03.164 → addGeofence for geofence 1 returned: 1

16:45:03.211 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:04.336 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:05.399 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:06.523 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:07.609 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:08.734 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:09.811 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:10.928 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:11.994 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:13.122 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:14.200 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:15.312 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:16.394 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:17.517 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:18.603 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:19.724 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:20.798 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:21.918 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:22.996 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:24.106 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:25.220 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:26.311 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:27.389 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:28.513 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:29.597 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:30.718 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:31.843 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:32.930 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:34.008 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:35.133 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:36.199 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:37.328 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:38.399 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:39.507 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:40.640 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:41.743 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:42.821 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:43.945 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:45.023 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:46.128 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:47.236 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:48.312 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:49.428 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:50.506 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:51.620 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:52.717 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:53.795 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:54.920 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:55.998 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:57.123 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:58.196 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:45:59.321 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:00.435 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:01.503 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:02.621 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:03.699 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:04.823 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:05.901 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:06.993 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:08.106 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:09.231 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:10.307 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:11.398 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:12.522 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:13.632 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:14.752 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:15.828 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:16.906 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:18.008 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:19.125 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:20.242 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:21.318 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:22.417 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:23.495 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:24.611 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:25.735 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:26.816 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:27.894 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:29.018 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:30.096 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:31.227 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:32.330 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:33.405 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:34.529 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:35.615 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:36.727 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:37.804 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:38.918 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:40.000 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:41.118 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:42.208 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:43.287 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:44.412 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:45.530 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:46.594 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:47.722 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:48.800 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:49.925 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:51.006 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:52.134 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:53.210 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:54.335 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:55.412 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:56.544 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:57.611 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:58.732 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:46:59.808 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:00.940 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:02.018 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:03.147 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:04.225 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:05.305 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:06.430 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:07.508 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:08.603 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:09.740 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:10.817 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:11.894 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:13.007 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:14.131 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:15.196 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:16.321 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:17.399 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:18.524 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:19.614 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:20.701 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:21.816 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:22.900 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:24.024 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:25.103 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:26.231 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:27.297 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:28.414 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:29.530 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:30.628 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:31.695 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:32.788 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:33.909 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:35.034 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:36.117 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:37.195 → getGeofenceState returned: 1. # of Sat: 13. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:38.308 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:39.423 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:40.495 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:41.607 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:42.726 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:43.804 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:44.916 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:46.017 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:47.095 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:48.208 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:49.332 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:50.410 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:51.540 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:52.611 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:53.729 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:54.802 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:55.927 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:56.999 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:58.112 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:47:59.236 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:00.304 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:01.442 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:02.519 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:03.644 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:04.722 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:05.804 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:06.928 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:08.044 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:09.133 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:10.205 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:11.330 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:12.408 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:13.532 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:14.634 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:15.711 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:16.836 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:17.901 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:19.026 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:20.131 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:21.231 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:22.321 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:23.433 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:24.511 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:25.623 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:26.734 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:27.813 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:28.935 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:30.011 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:31.133 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:32.211 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:33.296 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:34.421 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:35.533 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:36.605 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:37.730 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:38.808 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:39.933 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:40.996 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:42.123 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:43.210 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:44.320 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 1 = Inside. The individual states are: 1

16:48:45.398 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:46.538 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:47.601 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:48.725 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:49.813 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:50.938 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:52.009 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:53.097 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:54.222 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:55.300 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:56.411 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:57.536 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:58.606 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:48:59.731 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:00.835 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:01.913 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:03.034 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:04.114 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:05.239 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:06.317 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:07.441 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:08.519 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:09.613 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:10.705 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:11.827 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:12.908 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:14.033 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:15.145 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:16.227 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:17.305 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:18.420 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:19.545 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:20.605 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:21.744 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:22.815 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:23.930 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:25.015 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:26.140 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:27.222 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:28.300 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:29.425 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:30.495 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:31.615 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:32.740 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:33.818 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:34.943 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:36.000 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:37.121 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:38.200 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:39.324 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:40.402 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:41.515 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:42.621 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:43.724 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:44.805 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:45.915 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:47.032 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:48.109 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:49.231 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:50.296 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:51.428 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:52.505 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:53.623 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:54.701 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:55.825 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:56.888 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:58.013 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:49:59.129 → getGeofenceState returned: 1. # of Sat: 15. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

16:50:00.207 → getGeofenceState returned: 1. # of Sat: 14. status is: 1. numFences is: 1. combState is: 0 = Unknown. The individual states are: 0

Program Source Code:

/*

u-blox M8 geofence example

Written by Paul Clark (PaulZC)

10th December 2019

License: MIT. See license file for more information but you can

basically do whatever you want with this code.

This example demonstrates how to use the addGeofence and getGeofenceState functions

Feel like supporting open source hardware?

Buy a board from SparkFun!

ZED-F9P RTK2: https://www.sparkfun.com/products/15136

NEO-M8P RTK: https://www.sparkfun.com/products/15005

SAM-M8Q: https://www.sparkfun.com/products/15210

ZOE-M8Q: https://www.sparkfun.com/products/15193

This example powers up the GNSS and reads the fix.

Once a valid 3D fix has been found, the code reads the latitude and longitude.

The code then sets four geofences around that position with a radii of 5m, 10m, 15m and 20m with 95% confidence.

The code then monitors the geofence status.

The LED will be illuminated if you are inside the combined geofence (i.e. within the 20m radius).

This code has been tested on the ZOE-M8Q.

*/

#define LED LED_BUILTIN // Change this if your LED is on a different pin

#include <Wire.h> // Needed for I2C

#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS

SFE_UBLOX_GNSS myGNSS;

uint8_t SIV;

boolean result;

// Create storage for the geofence state

geofenceState currentGeofenceState;

long latitude;

long longitude;

uint32_t radius = 500; // Set the radius to 5m (radius is in m * 10^-2 i.e. cm)

byte confidence = 2; // Set the confidence level: 0=none, 1=68%, 2=95%, 3=99.7%, 4=99.99%

void setup()

{

pinMode(LED, OUTPUT);

// Set up the I2C pins

Wire.begin();

// Start the console serial port

Serial.begin(115200);

while (!Serial); // Wait for the user to open the serial monitor

delay(100);

Serial.println();

Serial.println();

//Serial.println(F(“u-blox M8 geofence example”));

Serial.println();

Serial.println();

delay(1000); // Let the GNSS power up

if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port

{

Serial.println(F(“u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.”));

while (1);

}

//myGNSS.enableDebugging(); // Enable debug messages

myGNSS.setI2COutput(COM_TYPE_UBX); // Limit I2C output to UBX (disable the NMEA noise)

// myGNSS.enableDebugging(); //Enable all the debug messages over Serial (default)

//myGNSS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB

//myGNSS.enableDebugging(Serial, true); //Enable only the critical debug messages over Serial

//Set output to 20 times per second

// NOTE: Do not drop the frequency less than 10 Hz

// this will not allow enough memory to available for GPS Messages

myGNSS.setNavigationFrequency(20);

delay(20);

// Serial.println(F(“Waiting for a 3D fix…”));

byte fixType = 0;

while (fixType < 3)

{

fixType = myGNSS.getFixType(); // Get the fix type

Serial.print(F("Fix: ")); // Print it

Serial.print(fixType);

if(fixType == 0) Serial.print(F(" = No fix "));

else if(fixType == 1) Serial.print(F(" = Dead reckoning "));

else if(fixType == 2) Serial.print(F(" = 2D "));

else if(fixType == 3) Serial.print(F(" = 3D "));

else if(fixType == 4) Serial.print(F(" = GNSS + Dead reckoning "));

else if(fixType == 5) Serial.print(F(" = Time only "));

// get the number of current satellites being tracked

SIV = myGNSS.getSIV();

Serial.print(F(". # of Sat: "));

Serial.print(SIV);

Serial.println();

delay(1000);

}

Serial.println(F(“3D fix found!”));

delay(100);

Serial.print(F("Version: "));

byte versionHigh = myGNSS.getProtocolVersionHigh();

Serial.print(int(versionHigh));

Serial.print(“.”);

byte versionLow = myGNSS.getProtocolVersionLow();

Serial.println(int(versionLow));

delay(10);

int32_t EstimatedAccuracy = 0;

/*

Serial.println(“Acc SIV”);

do {

EstimatedAccuracy = myGNSS.getHorizontalAccEst();

// get the number of current satellites being tracked

// SIV = myGNSS.getSIV();

// Serial.print(F(". # of Sat: "));

Serial.print(SIV);

// Serial.print("Estimate Accuracy: ");

Serial.println(EstimatedAccuracy);

delay(10);

} while (EstimatedAccuracy > 1100);

*/

latitude = myGNSS.getLatitude(); // Get the latitude in degrees * 10^-7

Serial.print(F("Lat: "));

Serial.print(latitude);

longitude = myGNSS.getLongitude(); // Get the longitude in degrees * 10^-7

Serial.print(F(" Long: "));

Serial.println(longitude);

radius = 500; // Set the radius to 5m (radius is in m * 10^-2 i.e. cm)

confidence = 2; // Set the confidence level: 0=none, 1=68%, 2=95%, 3=99.7%, 4=99.99%

// Call clearGeofences() to clear all existing geofences.

Serial.print(F("Clearing any existing geofences. clearGeofences returned: "));

Serial.println(myGNSS.clearGeofences());

// It is possible to define up to four geofences.

// Call addGeofence up to four times to define them.

Serial.println(F(“Setting the geofences:”));

Serial.print(F("addGeofence for geofence 1 returned: "));

Serial.println(myGNSS.addGeofence(latitude, longitude, radius, confidence));

/* radius = 1000; // 10m

Serial.print(F("addGeofence for geofence 2 returned: "));

Serial.println(myGNSS.addGeofence(latitude, longitude, radius, confidence));

radius = 1500; // 15m

Serial.print(F("addGeofence for geofence 3 returned: "));

Serial.println(myGNSS.addGeofence(latitude, longitude, radius, confidence));

radius = 2000; // 20m

Serial.print(F("addGeofence for geofence 4 returned: "));

Serial.println(myGNSS.addGeofence(latitude, longitude, radius, confidence));

*/

}

void loop()

{

// return;

result = myGNSS.getGeofenceState(currentGeofenceState);

Serial.print(F("getGeofenceState returned: ")); // Print the combined state

Serial.print(result); // Get the geofence state

if (!result) // If getGeofenceState did not return true

{

Serial.println(F(“.”)); // Tidy up

return; // and go round the loop again

}

if (myGNSS.getPVT() && (myGNSS.getInvalidLlh() == false)) {

// get the number of current satellites being tracked

SIV = myGNSS.getSIV();

Serial.print(F(". # of Sat: "));

Serial.print(SIV);

} else {

Serial.print(F(“. # of Sat: 0”));

}

Serial.print(F(". status is: ")); // Print the status

Serial.print(currentGeofenceState.status);

Serial.print(F(". numFences is: ")); // Print the numFences

Serial.print(currentGeofenceState.numFences);

Serial.print(F(". combState is: ")); // Print the combined state

Serial.print(currentGeofenceState.combState);

if (currentGeofenceState.combState == 0)

{

Serial.print(F(" = Unknown"));

digitalWrite(LED, LOW);

}

if (currentGeofenceState.combState == 1)

{

Serial.print(F(" = Inside"));

digitalWrite(LED, HIGH);

//Serial.print(F("Clearing any existing geofences. clearGeofences returned: "));

//Serial.println(myGNSS.clearGeofences());

myGNSS.clearGeofences();

// It is possible to define up to four geofences.

// Call addGeofence up to four times to define them.

//Serial.println(F(“Setting the geofences:”));

//Serial.print(F("addGeofence for geofence 1 returned: "));

//Serial.println(myGNSS.addGeofence(latitude, longitude, radius, confidence));

myGNSS.addGeofence(latitude, longitude, radius, confidence);

}

else if (currentGeofenceState.combState == 2)

{

Serial.print(F(" = Outside"));

digitalWrite(LED, LOW);

}

Serial.print(F(". The individual states are: ")); // Print the state of each geofence

for(int i = 0; i < currentGeofenceState.numFences; i++)

{

if (i > 0) Serial.print(F(“,”));

Serial.print(currentGeofenceState.states*);*

  • }*
  • Serial.println();*
  • delay(1000);*
    }
    Sample from Program:

Please edit your post to add code tags.

Keep in mind that the reported GPS location can wander by 20 m or more as satellites come into view, or disappear from view.