Plant species that repel rodents around your barn foundation. These include the gopher plant, also known as Euphorbia lathyrus, and the crown imperial fritillary, or Fritillary imperialis.
Place small windmills around your barn foundation. The gentle movement can scare groundhogs and keep timid animals away.
Sprinkle fox or coyote urine around the edges of your barn foundation. Alternately, if you have a dog, you can let him urinate around the foundation for a similar repellent effect.
Use red pepper flakes sprinkled around the edges of the foundation. The scent and taste deter groundhogs and other wildlife. Tabasco and other spicy sauces can also be used in place of red pepper flakes. No matter what spicy concoction you use, you will need to reapply it regularly or it will stop working.
Install an ultrasonic device designed to repel groundhogs. These devices are typically buried in the ground or installed next to a building. They emit a noise that is annoying to animals, although some groundhogs get used to the sound after a while and start ignoring it.
Locate the entrances to the groundhog’s burrow and stuff it with a rag soaked in olive oil. As the oil goes rancid, it will drive the groundhog to move and find a new home.
Dig a one-foot by one-foot trench around your barn foundation and install flexible fencing, such as chicken wire or hardware cloth, to the bottom of the barn wall, lay it down into the trench, and bury the end on the other side of the trench underground to prevent woodchucks from burrowing under the foundation.