1Setting up your code
- First you need to decide what you want to fence in.
- Using Google Maps, select as many points as you need to zone your yard, farm, etc. and write down the latitude and longitude pairs. You will need at least 4 points, but they don't need to make up a perfect square.
- Click the link to get the generic particle code that I created for this project- GPS Collar Code
- Scroll down to where it says double latitude and add all of the latitude locations that you selected, all separated by commas.
- Then go to double longitude and add all of the longitude locations that you selected , all separated by commas.
- Next go to where it says int NumPoints and put in the count of the number of latitude and longitude pairs you selected for your geofence.
- Go to the upper left corner of the screen and press the checkmark to check if your code compiles. If it doesn't, check to make sure that you inputted the same amount of latitude positions as you did longitude.
- Your code is ready.
- NOTE: for those hackers and innovators out there, this code is very basic, and the PCB allows for more to be built upon. Please innovate and share!
2Uploading to Your Particle Electron
This process took me a while to figure out, so I am going to walk through it in detail.
Once you have your particle board connected to the mobile network and your account set up on particle follow these steps:
NOTE: If you are only uploading the code once you may press the lightning bolt button that says flash. It will flash over the air (OTA) and will use some of your data for the month. It is very minimal if you are only uploading once and is the easiest way so I recommend doing this if you aren't trying to alter the code.
If you are going to alter the code follow these steps:
- Go to your code that you just generated and press the <> button on the left side of the page.
- Next to where it says GPS_COLLAR_GENERIC there is a cloud-like button, press this button to download a .bin file that you can use to upload locally onto your particle electron.
- Follow the directions here to set up your command line for uploading directly to your electron - Particle Docs
- Once this is complete you are ready to upload over USB.
- Connect the electron via USB.
- Open a new terminal in the folder where your .bin file is saved.
- Type "particle flash --Serial YOURFILENAME.bin" and of course replace your file name with the name of your file.
- Hit enter on the command line.
- Press and hold the mode button on the electron until it flashes blue.
- Press enter on the command line again.
- Your code should upload. If it does not, check that you typed everything into the command line correctly and try again. It should work.
You will need to order all the parts listed in the parts list in order to create this project and also some type of a bag that your dog can wear to hold all of the components. This may be dog specific since there are many different sized dogs.
Also, if you don't have these tools, getting a set of helping hands, a soldering iron, solder, and a set of wire cutters is pretty much essential for this build.
4Soldering parts onto the PCB.
- Start with the GPS breakout board. Solder the headers onto the board. You only need to solder all 4 corners, Power, GND, TX, RX.
- Next solder the right angle header onto the Pololu 9V buck-boost board.
- Next solder all of the resistors and the capacitors onto the board following the diagram in the pictures section.
- Next solder on the on/off switch and the TIP120 transistor.
- Next solder on the 500k resistor, the battery JST connecor, and the Pololu 9V buck-boost board.
- Next solder on a wire onto the loop connections. Approximately 8-10" or covered wire should be used for this.
- Next solder on both of the 555 timer ICs.
- Next solder on both the particle electron, and the GPS module.
- Next solder on the two RGD LEDs
- Finally solder on the buzzer.
The board is complete and ready.
5Running the board.
Once you have code uploaded onto the electron and all of the components soldered onto the PCB you are ready to fence.
In order to do this plug in both of the batteries to the PCB. Flip the on/off switch away from the TIP120 to the ON position. The board should fire up. As soon as it fires up the LED 1 which is closest to the outside of the board will be red. This indicates no satellite connection. The system is not ready until this LED goes blue or green which indicates that the GPS has a lock. The fence location will be a lot more accurate if you can wait for the LED to go green which indicates that the GPS is connected to more than 1 satellite. When the LED is blue it indicates that it is connected, but only to one satellite. At this point the system is working, and if you have a dog on the system you can put the system in their bag and put their petsafe collar on. If they are within the geofence, LED 2 will light up green. As soon as they go outside of the fence, the board will begin to trigger the shock collar and LED 2 will go red. If the dog is outside the fence for more than 30 seconds and fails to return inside, the shocking will stop. Future iterations of the code will send out an alert to the owner.