Varmint Detector

2,821

8

4

About: Hiking, Woodworking, PCB design using Eagle, Writing Software for MacOS and AVR, 3D Design using Fusion 360

The PCB I designed is a “Varmint Detector”. Varmint: noun, North American informal - a troublesome wild animal. In my case, crows and chipmunks attacking our garden. They really aren’t much of a problem, this is just my excuse to build a solar powered device.

Varmint Detector is a solar powered motion activated MP3 player for scaring animals out of a garden.

Scenario: animal moves in front of the detector, detector makes noise, detector triggers other detectors, lots more noise, animal flees.

The detection is handled by a common HC-SR501 PIR module.

The noise is made by a speaker attached to an 8002a mono amplifier.

The amplifier is fed by a YX5200-24SS MP3 chip.

The 100+ mp3 clips are stored on a W25Q64JVSSIQ NOR Flash chip.

Onboard loading of the NOR Flash is enabled using a LVC125A buffer chip (isolates the NOR Flash chip).

Other detectors are triggered using a RFM69CW 433MHz transceiver (also used to silence via a hand held remote).

Everything is controlled by an ATtiny84A mcu.

The power for the board is converted to 3v3 by a LM3671 DC-DC step down converter (on board).

The power from the solar panel is stored on a single 18650 rechargeable 3.7v (4.2v when fully charged) Li-ion battery.

The battery charging is handled by a TP4056 lithium battery charger module.

The panel is a single 5V 1.25W 110x69mm mono-crystalline silicone epoxy solar panel.

Operation:

The detector is turned on by inserting a battery. Once energized, the unit gives the user 20 seconds to get out of the area before it starts responding to motion and/or alerts from other detectors. When something triggers the detector it will start playing a list of MP3 sound clips. The MP3 clip played is determined by where it left off, or the index sent to it from another detector. The clips will be played for as long as there is motion detected in the area. The player will stop when there is no motion for 10 seconds. When all of the detectors are playing, they are all playing the same clip (although not perfectly in-sync.) If the user needs to enter the area where the detectors are placed they can use a remote to mute the detectors. When the user leaves, they use the remote to put the detectors in standby mode. To conserve the battery at night, the detector shuts down when it gets dark.

The three button remote is a detector board without the MP3 section.

The 3D part STL files are available on thingiverse: https://www.thingiverse.com/thing:3317092

The schematic is enclosed in the next step.

Sources are on GitHub: https://github.com/JonMackey/FatFsToHex

If you’re interested in building one, the parts list and board Gerber files are shared on PCBWay.com. https://www.pcbway.com/project/shareproject/Varmi...

Finally, this board with a bit of tweaking can be used for other purposes, such as the remote control noted above. You could also remove the motion sensor and simply use it to remotely play MP3 clips. Or you could remove the MP3 section and use it for remote detection, such as when mail is placed in your mailbox. For another project that uses this MP3 chip see https://www.thingiverse.com/thing:3102114

Step 1: ​Instructions for Assembling the Board

Instructions for assembling the board (or almost any small board) follows. If you know how to assemble an SMD board, jump to step 12. Starting at step 12 there are detailed steps for assembling a detector and remote control. Some of the information is somewhat advanced, such as the steps that describe how to download a sketch to the specific micro controller used, and how to load MP3 files onto the EEPROM.

Step 2: Mount the Board

Using a small piece of wood as a mounting block, I wedge the PCB board between two pieces of scrap prototype board. The prototype boards are held to the mounting block with double stick tape (no tape on the PCB itself).

Step 3: Apply Solder Paste

Apply solder paste to the SMD pads, leaving any through hole pads bare. Being right handed, I generally work from top left to bottom right to minimize the chances of smearing the solder paste that I’ve already applied. If you do smear the paste, use a lint free wipe such as those for removing makeup. Avoid using a Kleenex/tissue. Controlling the amount of paste applied to each pad is something you get the hang of through trial and error. You just want a tiny dab on each pad. The size of the dab is relative to the size and shape of the pad (roughly 50-80% coverage). When in doubt, use less. For pins that are close together, like the LVC125A TSSOP package I mentioned earlier, you apply a very thin strip across all of the pads rather than attempt to apply a separate dab to each each of these very narrow pads. When the solder is melted, the solder mask will cause the solder to migrate to the pad, kind of like how water won’t stick to an oily surface. The solder will bead or move to an area with an exposed pad.

I use a low melting point solder paste (137C Melting Point)

Step 4: Place the SMD Parts

Place the SMD parts. I do this from top left to bottom right, although it doesn’t make much difference other than you’re less likely to miss a part. Give each part a light tap to ensure that it’s sitting flat on the board. When placing a part I use two hands to aid in precise placement.

Inspect the board to make sure any polarized capacitors are in the correct position, and all chips are oriented correctly.

Step 5: Time for the Hot Air Gun

I use a low temperature solder paste (No Clean Lead Free Low Temperature Solder Paste.) Hold the gun perpendicular to the board at about 4cm above the board. The solder around the first parts takes a while to start melting. Don’t be tempted to speed things up by moving the gun close to the board. This generally results in blowing the parts around. Once the solder melts, move on to the next overlapping section of the board. Work your way all around the board.

I use a YAOGONG 858D SMD Hot Air Gun. (On Amazon for less than $40.) The package includes 3 nozzles. I use the largest (8mm) nozzle. This model/style is made or sold by several vendors. I’ve seen ratings all over the place. This gun has worked flawlessly for me.

Step 6: Cleaning/removing the SMD Flux

The solder paste I use is advertised as being “no clean”. You do need to clean the board, it looks much better and it will remove any small beads of solder on the board. Using latex, nitrile, or rubber gloves in a well ventilated space, pour a small amount of Flux Remover into a small ceramic or stainless steel dish. Reseal the flux remover bottle. Using a stiff brush, dab the brush in the flux remover and scrub an area of the board. Repeat till you’ve entirely scrubbed the board surface. I use a gun cleaning brush for this purpose. The bristles are stiffer than most tooth brushes.

Step 7: Place and Solder All of the Trough Hole Parts

After the flux remover has evaporated off the board, place and solder all of the trough hole parts, shortest to tallest, one at a time.

Step 8: Flush Cut Through Hole Pins

Using a flush cutter plier, trim the through hole pins on the underside of the board. Doing this makes removing the flux residue easier.

Step 9: Reheat Through Hole Pins After Clipping

For a nice appearance, reheat the solder on the through hole pins after clipping. This removes the shear marks left by the flush cutter.

Step 10: Remove the Through Hole Flux

Using the same cleaning method as before, clean the back of the board.

Step 11: Apply Power to the Board

Apply power to the board (no more than 5 volts). If nothing fries, measure 3v3 on the output of the DC-DC regulator section (thick trace that feeds two MOSFETs.) You can also measure this across capacitor C3 next to the ATtiny84A.

Step 12: Set the ATtiny84A Fuses

This step sets the processor speed and clock source. In this case it's 8MHz using the internal resonator.

I do this using an ISP, specifically the one I designed (see https://www.instructables.com/id/AVR-Programmer-W... ) You can use any AVR ISP such as Arduino as ISP built on a breadboard. See the Arduino as ISP example from the Arduino IDE Examples menu.

Caution, Mac OS instructions ahead. I'm not a Windows user.

For this step, you could probably do this from the Arduino IDE via "Burn Bootloader", but I prefer to do this from a BBEdit worksheet (you could also do this from a Terminal window)

Connect the ISP cable from the ICSP header on the board to the 3v3 ISP. Set the DPDT switch near the ICSP header to "PROG".

Very important: You must use a 3v3 ISP or you may damage components on the board.

If the ISP is supplying power, disconnect power from the board. I use a 5 wire ISP cable rather than a 6 wire cable. The 5 wire cable doesn't provide power. This way I can make changes to the software without having to remove/provide power to the board between uploads.

Run:

# ATtiny84A 8Mhz, internal clock
/Applications/Arduino\ 1.8.8.app/Contents/Java/hardware/tools/avr/bin/avrdude -C /Applications/Arduino\ 1.8.8.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -p t84 -P /dev/cu.usbserial-A603R1VD -c avrisp -b 19200 -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

/dev/cu.usbserial-A603R1VD above should be replaced with whatever USB serial port is connected to the ISP.

Step 13: Load the Varmint Detector Sketch

If you've never used an ATtiny mcu, you need to install via the Arduino Boards Manager (Tools->Board->Boards Manager), the attiny package by David A. Mellis. Search for ATtiny in the Boards Manager window. If the package doesn't appear, then you need to add "https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json" to the Arduino Preferences - Additional Boards Manager URLs. Go back to the boards manager window to install the package.

Once the package is installed you then need to download the Varmint Detector software from GitHub: https://github.com/JonMackey/FatFsToHex/tree/mast...

You can merge these sources in with your current Arduino files, but a better way would be to place them in a folder named Arduino Tiny, then set the Arduino Preferences path to point to this folder. This way you keep the ATtiny sources separate.

Set the board (Tools->Board) to ATtiny24/44/84. Set the Processor to ATtiny84, and the clock to internal 8MHz.

If you haven't already done so, set the Programmer (Tools->Programmer) to Arduino as ISP.

Compile the Varmint Detector sketch. If that goes well, upload the sketch using the same wiring and ISP used to set the fuses in the previous step.

Step 14: Create the MP3 FAT Hex File

The MP3 FAT Hex file can be created using my Mac OS FatFsToHex application. If you're a Windows user, the end goal is to get an image of a FAT16 file system containing all of the MP3 Files to be played on the Varmint Detector loaded onto the NOR Flash EEPROM. The file order within the FAT root directory determines the order of play.

If you own a Mac, or have access to one, download the FatFsToHex application from GitHub: https://github.com/JonMackey/FatFsToHex

Note that you don't have to build the application, there's a zip file in this repository containing the built application.

After you've decided on the MP3 files you'd like to play on the board, launch the FatFsToHex application and drag the files into the file list. Set the order of play by arranging the files in the list. If this is a set of MP3s you think you may use more than once, save the set to disk using the save command (⌘-S). Export (⌘-E) the MP3 hex file to an SD card, naming the file FLASH.HEX.

I doubt anyone will actually build one of these boards, but if someone does, and you get stuck creating the MP3 hex file, contact me and I'll build it for you.

Step 15: Load the MP3 Files Onto the NOR Flash EEPROM

For this step you need an Arduino as ISP (or the board I designed), and a 6 wire ISP cable. You need to use a 6 wire cable because the board will have the MOSFET that supplies power to the MP3 section turned off. You should also disconnect the power from the board's power connector.

If you're not using the ISP I designed, the ISP you use needs to be loaded with my Hex Copier sketch and it needs to have a SD card module as per the instructions in the HexCopier sketch. The HexCopier sketch can be run on any Arduino with a ATmega328p (and several other ATMegas.) This sketch is in the GitHub FatFsToHex repository.

Set the DPDT switch near the NOR Flash EEPROM to PROG. Connect the 6 pin ISP cable between the ISP and the NOR FLASH header using GND as marked on the board to determine the correct orientation of the connector.

Once power is applied with the SD card inserted, and the baud rate of a serial monitor set to 19200, send the sketch a letter C and a return character ("C\n" or "C\r\n"), to start the copy. See the screen shot for the expected response from the copier sketch running on the ISP.

Step 16: Building the Enclosure

As mentioned earlier, the 3D STL files can be downloaded from Thingiverse: https://www.thingiverse.com/thing:3317092

All of the parts print at 20% fill. Only the BracketBase.stl should be printed with support "Touching Buildplate".

Print the following parts: Box, Cover, Plate, Bracket, and Nut, with BracketBase printed separately as noted above.

As you wait the several hours for the enclosure to print, the next steps describe the modifications to the purchased modules and creating the cable assemblies.

All 3D parts were designed using Autodesk Fusion 360.

Step 17: Remove the 3v3 Regulator From the Motion Detector

The HC-SR501 motion detector module comes with a 3v3 voltage regulator because the board was designed to work at 5V. The Varmint Detector board runs at 3v3 so the regulator should be removed. If you feel strongly that the regulator won't cause any issues, then skip this modification.

The pictures above are the before and after modification. The regulator is removed by using the hot air gun. I protected the electrolytic capacitor nearest the regulator with some aluminum foil. After the regulator is removed, add a 0603 0 ohm jumper as shown in the photo (a blob of solder will also work.)

Step 18: Optional: Remove the USB Connector From the Charger Module

The 18650 TP4056 Lithium battery charger module has a USB connector that can optionally be removed. If it's not removed you just need to use a longer screw to secure it to the side of the detector box.

The screw used when the connector is removed is a M2.5x4 pan head with a washer. You won't need a washer if the USB connector isn't removed (the USB connector extends enough to catch the screw head.)

Step 19: Build the Cables

Most of the connectors are JST XH2.54 except for one 3 pin dupont connector (although you could substitute JST for this.) For the male JST connectors you solder the wires to the connector pins and then use heat shrink tubing to cover the solder joint. They do make male JST crimp pins and connector shells, but they're hard to find and not worth the expense.

You'll need a crimping tool. I use an Iwiss SN-01BM. This crimper handles the JST and Dupont pins. This high quality crimper works much better than the no-name crimpers, and it's only about $5 more. The wire should be stripped consistently to 2mm. The first photo is annotated to show the cable lengths and the connectors to be attached. All of the wire is 26 AWG. Cut the wires to the lengths shown, strip all of the ends to 2mm except for the solar tap where one end of each cable should be 4mm. The 4mm ends are twisted together and solder is applied before soldering to the connector pins (see photos)

NOTE: The pins on the 16cm cable for the solar panel should not be attached until after the solar panel mounting bracket is assembled.

If you've never used a crimp tool before: Place a female pin in the smaller of the two crimp slots with the pin "wings" pointed up. The distance the pin extends out the other side of the die is determined by where the bare wire will be crimped to the pin. See the photos that show a JST pin in the die. Squeeze the crimper handle just enough to keep the pin from falling out of the crimp jaw/die. Insert the wire till you see the bare end start to peek out of the opposite side. The orientation of the bonded wire determines how the pin will mate with the connector. See the photo for the correct orientation. With the wire in the die, squeeze the crimper handle slowly, just until you hear the crimper ratchet release. You DO NOT want to see how hard you can squeeze the crimp handle. If you squeeze past the point of the ratchet releasing you may shear the wire within the pin and not even notice until you try to use the cable. If you do experience sheared wires when using the crimper correctly, the crimper needs to be adjusted. There's a nut on the handle for this adjustment.

Step 20: Assemble the Solar Panel Mounting Bracket

The names used refer to the 3D STL part file names.

Test the fit of the BracketBase and Nut, adjust the BracketBase/Nut as needed. If you printed without support it should be fine. All of mine fit without any cleanup.

Press an M3 nut into the BracketBase (don't worry about getting it in tight, the screw will pull it in.) Join the BracketBase to the Bracket and test the fit. Once you're satisfied with the fit, connect the two pieces with an M3x22mm flathead screw (I cut a 25mm flathead screw to size.) Once satisfied with the fit, separate the two parts, setting the BracketBase aside.

Using two flathead M3x8 screws, dry fit the Bracket to the Plate. If the parts align correctly, back the screws out and put a thin layer of plastic epoxy on the bracket face that mates with the plate. Tighten the two screws and wait for the epoxy to cure.

Run one end of the 16cm red/black 26 AWG bonded wire through the joined Bracket and Plate. Solder the wires to the solar panel as shown in the picture.

Don't remove the protective film on the solar panel face until after the mounting bracket is assembled.

Clean the back of the solar panel with PCB cleaner.

If your solar panel is flat, run a bead of silicone around the edge of the Plate. If your solar panel is warped, use a thin layer of plastic epoxy instead. I had a warped panel that came apart using silicone. Silicone is preferred because you can remove/reuse the solar panel if needed. With epoxy it will be difficult to remove the panel.

Clamp the solar panel to the Plate and wait for the adhesive to cure.

Run the wire through the BracketBase. Tighten the 22mm screw. Crimp the JST female pins to the wires. Attach the connector.

Step 21: Add the Internal Box Parts

Solder the two charger cables to the charger board (the board is well marked)

Dry fit the internal parts.

Cut the 18650 battery holder wires to size (to reach the charger)

Remove the internal parts.

Solder the 18650 battery holder wires to the charger.

Mask off the Box face.

Mask the motion detector cone.

Place a thin ring of silicone around the motion detector and speaker openings.

Do not over tighten the screws...

Using M2x5 screws, secure the motion detector and speaker. Note that the motion detector screws should be tightened together to prevent the module from rocking to one side

Place and secure the battery holder using an M2.5x4 screw.

Place and secure the charger using an M2.5x4 screw + washer (if you removed the USB connector), otherwise whatever length works, I've always removed the USB connector.

Install and secure the Varmint Detector board using 2 or 4 M2x5 screws. M2.3x5 self tapping screws for plastic also work.

Lastly, install a PCB or patch antenna to the U.FL connector on the board. The antenna in the picture is a 433 MHz PCB antenna with an adhesive backing.

Step 22: Slide on the Back Cover and It's Done.

Install a charged 18650 battery, attach the power cable to the board, slide on the back cover and it's ready to annoy some varmints (or your wife.)

Step 23: Optional: Building the Varmint Detector Remote Control

As I noted in the introduction, the remote control is the varmint detector board with fewer parts. I'm not going to go into a lot of detail about the board assembly. In the following steps there are photos of the board with reduced parts that should be enough to figure out what parts are used.

Step 24: Assemble the Board

Assemble the board using roughly the same steps as the Varmint Detector board.

A not-so-obvious difference in this board is a tiny jumper to the left of the reset button that goes between two vias (tiny holes) to carry power to the transceiver when the MOSFET is removed (as it is in this case). Use a short piece of 30 AWG wire wrap wire. If you don't have wire wrap wire you can use bare strands of wire from a heavier multi strand wire, anything to connect the two points.

Step 25: Print the 3D Parts

The names used refer to the 3D STL part file names.

Print the 3D parts: RemoteBase, MCU_Cover, and Battery_Cover.

The parts are printed at 20% fill, no support.

Step 26: Assemble the Battery Harness Cable Assemblies

I used 9x9mm battery spring plates. I purchased them on Banggood.com: https://www.banggood.com/10-Pairs-Silver-Tone-Met...

I have no idea if they're still selling plates of the same dimensions. I bought other plates on AliExpress and they were slightly larger. I haven't taken the time to modify the design to use them.

Fold the tabs over as shown in the photo. Cut and solder the wires to length as shown. Attach female JST pins.

Once the spring clips are installed you can't get them out without destroying the 3D part. The plates have small burrs that prevent the plate from being removed. So be really sure everything is cut the right length.

The spring clips are slid into the channels as shown. I used the flat end of a 3mm hex driver to push them in.

The wire runs up from a tab, across flush with the plate top edge, then down to the next tab. There are channels in the 3D print for the wires to be pressed into (again I used the flat end of a hex driver.)

Step 27: Make the Button Board and Wire Harness

The switch board is a piece of a 20x80mm prototype board cut to 30mm.

The switches are 6X6X10 DIP Tactile Momentary switches. The 10mm length of the button is measured from the back of the switch, the side that touches the board.

An example of this switch: https://www.aliexpress.com/item/100PCS-6X6X10-DIP...

In the back of the switch board you’ll see hole columns M through X. The switch legs are placed on the top and 3rd rows of the board in columns M-P, Q-T, U-X, with jumpers between the 3rd row PQ and TU, with the common ground (black wire) off of X.

The support holes for the mounting screws are made by enlarging the bottom row holes P and U. I also made a cut in between the mounting holes to run the wires.

The wires in the photo are approximately 5cm. Attach them as per the photo.

Step 28: Install the Boards and Antenna

Before installing the boards, ream the 3 button holes to 3.5mm

The boards are installed using 6 M2x5 screws.

The antenna is a 433MHz PCB antenna

Step 29: Set the Fuses and Load the Sketch

Use the same procedure to set the fuses and load the sketch as described earlier for the fully populated Varmint Detector board. The only difference is you're loading the VarmintDetectorRemote sketch.

Attach the battery and mcu cover and you're done.

PCB Contest

Runner Up in the
PCB Contest

Share

    Recommendations

    • Barbeque Challenge

      Barbeque Challenge
    • Paint Challenge

      Paint Challenge
    • Games Contest

      Games Contest

    4 Discussions

    0
    None
    mayan17778

    6 months ago

    This was a lot of the information i was looking for but still to advance for me to understand... the more pictures, the better... a video was be even better... with out a doubt your a complete expert in these types of field... i was wondering if i can get your personal email to ask you more in depth questions

    1 reply
    0
    None
    KISELIN

    6 months ago

    WOW! Great Instr.with ton's of info, but, (maybe I'm a bit stupid, but still) , Ididn't get the Point with this? You playing MP3 audio ? In the instr. at one place you use the Imperial X' X'' (inches) and the other place you use the metric (ISO) mm. please... go for the ISO, (ewen them Yankees are going in for that). Please, in your instr. who would be interrested in what kind of a working table you use, or them supports, stay focused on the Instr. itself that we are interrested in.
    Again: You surely have put a lot of efford in the Instr. and explaining it, but still.... cut it down to the elementary. I did started to read yor instr. but lost my interrest somewhere in... somewere
    Please re-edit your instr. by clening up it from all un-nessesary stuff.
    Have a nice New Year 2019

    1 reply
    0
    None
    JonMackeyKISELIN

    Reply 6 months ago

    I added a one line description of what this project is close to the top of the description. This is in the "Technology" category, so I left in the details in the description of what chips were used and most of how the detector reacts to motion.

    If you feel I still need to pare it down more, you'll have to give me some pointers.

    You have a happy 2019 too.