Shag Bag Golf Ball Counter ESP8266

by buteomont in Circuits > Microcontrollers

495 Views, 0 Favorites, 0 Comments

Shag Bag Golf Ball Counter ESP8266

croppedBag.jpg

A shag bag is a device for collecting golf balls that are scattered about an area. It's a great tool if you're picking up more than a few balls, because you don't even have to bend over to get them. You just position the snout of the shag bag over the ball, press down, and it gobbles the ball right up!

The snout, at least on mine, has three springy steel fingers evenly spaced around the circumference. These spread out when a ball is pressed between them, and then snap back after the ball passes through. The balls stack up in the tube until they reach the top, which is inside the bag part. As more balls are pressed into the tube, the upper ones fall out into the bag. It's a great time (and back) saver!

While learning to play golf, I would take about 50 balls and hit them in a field behind my house every day. Being a new golfer, of course they didn't all land anywhere near one another. I would walk around in the field with my shag bag, picking them up and counting them with my meat computer... uh, I mean brain. This is not a reliable way to count balls! I needed a better way.

After thinking about it a bit, I came up with the Shag Bag Golf Ball Counter. It had to be battery operated, extremely low power for long battery life, and dependable. I didn't want to have to turn it on and off, and it had to be simple to operate. I think I've met those conditions. You can build one too!

Supplies

Some of the links below are for more than one of each item. You only need one in most cases, but it's good to have two or more around, especially if the smoke leaks out of one. And they're cheaper that way!

And of course, you need a shag bag!

Theory of Operation

golf ball counter schematic.gif

It's always good to understand how something works before actually building it, and this is no different.

Fortunately, the operation of the Shag Bag Golf Ball Counter is dead simple! Here's how the magic happens (refer to the schematic and the program listing):

  1. Under normal circumstances, the microprocessor is in deep-sleep mode and the display is dark. This mode draws mere microamps from the battery, which is why there's no on/off switch. It's always on!
  2. When the golf ball enters the snout of the shag bag, it moves the magnet closer to the reed switch (SW1) and transfers it, sending a negative pulse through C1 to the reset pin of the microprocessor. This wakes it up and starts the program chuggin' in the setup() function.
  3. After initializing a few ports and libraries, the setup() function retrieves the previous ball count from battery-backed storage1 into working memory.
  4. The program then checks to see if button SW2 is pressed. Pressing this button will also wake up the microprocessor (via D1 and C3), but the program needs to know if it should count a ball or just display the current total. This is how it knows.
  5. If the button is not pressed, then it must have been the reed switch that woke up the processor, so it adds 1 to the total and writes the result back to RTC memory.
  6. The program then displays the total ball count on the display, delays for 2 seconds, and then shuts everything off and goes back into deep-sleep mode. That's it!

Notice that the loop() function is empty. That function is never executed because the processor goes back to sleep before it ever gets there, so it's not necessary. There is also coding in the program to erase the total ball count to zero when the button is held in for two seconds.

1The total ball count is held in "RTC" storage so that it will be maintained while the microprocessor is in sleep mode.

Programming the Microprocessor

Programming the microprocessor is done just like an Arduino. I programmed mine with PlatformIO, but it should work just fine in the Arduino IDE. The only difference between this processor and the Arduino is that the ESP8266-01S has no built-in USB port - that's what the adapter is for. After it's programmed, the adapter is disconnected and the microprocessor is used without it.

How to operate the Arduino IDE is beyond the scope of this article, but you can view this one to learn how to do it!

Assembling the Board

golfBallStripBoard.png
IMG_20230309_105921684_HDR.jpg

Cut a piece of stripboard about 65mm long and 40mm wide, with the strips running in the long dimension. Cut the strips in the locations shown with an "X", and solder short jumper wires where you see the green rectangles in the diagram. Next, mount and solder the other components as shown in the diagram. Some of them are underneath the display and processor, so add those two last.

If you're going to 3D-print the case, now would be a good time to do it. You may have to adjust either the size of the case or trim the board a little to make everything fit tightly. Friction on the corners will hold the board in place.

The STL files for the case can be downloaded below. Notice that the window on the lid shows only about a third of the display. Most of the display real estate is not needed since it's unlikely you're going to pick up more than 99 balls!

Mounting Everything on the Shag Bag

IMG_20230309_104052312_HDR.jpg
IMG_20230309_103930444_HDR.jpg
IMG_20230309_103822477_HDR.jpg
snoutWithNotes.jpg

The case (with board) and the battery holder should be mounted on top of the shag bag. I used double-sided foam tape which worked well, but you can use glue or whatever method you wish. Poke a hole in the top of the bag, just large enough to pass the speaker wire through to the ball tube inside. Run the wire through the hole and down the outside of the tube all the way to the snout. Zip ties in strategic locations will hold it in place.

Solder each end of the reed switch to a conductor of the speaker wire, and glue the switch to the snout close to one of the springy fingers. You may want to encase the reed switch in heat-shrink tubing or hot-melt glue before gluing it down, just to make it more durable. Don't go wild with the glue because you may need to fine-tune the location of the reed switch later. Also, be careful not to get glue under the metal finger!

Mount the magnet on the inside of the finger (see photo), so that it will transfer the reed switch when the golf ball presses it outward. You will likely have to move this magnet (and maybe the reed switch) around a bit to get it just right, but don't get frustrated. You will be able to get it to work. If you can find some kind of easily-removable sticky substance to hold the magnet temporarily until you find the right spot, that will make the fine-tuning go faster.

After getting everything mounted and connected, insert the batteries. The display may show some random number, but if you press and hold the pushbutton it should reset to zero. Then try picking up some golf balls to see if the magnet needs adjusting. Once you are satisfied with the way it works, permanently glue the magnet in place.

Practice, Practice, Practice!

I hope this device will help inspire you to get out there and practice your golf swing. It's the only way to remove strokes from your game!