Mothbox: DIY Insect Camera for Conservation
by blorgggg in Circuits > Raspberry Pi
1706 Views, 24 Favorites, 0 Comments
Mothbox: DIY Insect Camera for Conservation
The Mothbox is a low-cost, high-performance insect monitor. Its power efficient and lightweight design was created to help biologists deploy it in deep wildernesses, and its low-cost nature means you can also build one to study the biodiversity at your home! All the physical designs, electronics schematics, Pi Scripts, and automated insect-IDing Artificial Intelligence software are provided free and open source! So you can build, share and improve on these designs yourself!
Plus, it's also just really fun to see what kinds of neat bugs you find!
This instructable will guide you through how to build one yourself, but the full project website is here if you want even more info! (Like how to program your own insect AI from scratch!)
What it Does
The Mothbox stays in an ultra low-power state until your schedule tells it which nights to wake up. Then it triggers an insect lure (usually a bright UV light) and then takes ultra-high resolution photos of the visitors it attracts.
Next we created some open-source AI scripts that process these insects for you. First, a trained YOLO v8 detects where all the insects are in the images and crops them out.
Then we use a special version of BioCLIP with a user interface to help you automatically group and ID the insects to different taxonomic levels!
Supplies
The Mothbox uses a Raspberry Pi 5 (or Pi4 and Pijuice), a Talentcell Battery, and a 3 channel relay as its core. The entire materials cost is about $375 per mothbox. (Depends on your options you go with and prices you get where you live). Note that many other similar tools for insect monitoring can cost between $9-$15K!
Here’s a link to a list of most of the parts collected for you.
Electronics
Core Electronics ($233)
Raspberry Pi and Scheduling
- Raspberry Pi 5 (4GB and up) ($60)
- plus a rechargeable RTC battery ($5)
OR
- Raspberry Pi 4 (4GB and up) ($55)
- plus a Pijuice ($100)
- Info Software
Camera
Power
- Battery : Talentcell 12V Lithium ion Battery PB120B1 ($90)
- Relay Expansion Pi Hat (Waveshare 3x relay) ($18)
- Buy
- Info
- Remember you can also wire individual relays, but not solid state relays (they can’t switch low dc voltage)
- 12V regulator / Step-Up Voltage Booster
- Buy
- This extends your battery life by keeping power to the 12V lights even if your battery voltage starts dipping low.
- (Optional) Power sensor for monitoring battery levels *Buy
Lighting ($60)
- Photography Lights (2x)
- 2x 12V 144 LED ringlight ($23)
- The 144 LED ringlights seem to be about the brightest, diffuse 12V LEDs you can find for the price. They are also quite ubiquitous and a standard(ish) form factor
- Purchase 2 of them
- 2.55” (65mm) inside and 3.75” (95mm) overall outside diameters
- UV lights
- 12V
- Any UV light that accepts a 12V input will work easily * Cheap 12V Waterproof UV flood ($13)
- We are also using out custom “Mothbeams” which are like powerful, open source, bespoke, low cost- lepileds. They currently cost about $80 to order them from Moritz at LabLab in Berlin [moritz at lablab.eu] * Or you can order them from Circuithub but there they cost about $200-$400
- 5V (Not Officially Integrated)
- to reduce costs and additional parts, we do not design around an extra 5V output
- You can hack the system to use UV lights that take a 5V input pretty easily though with just an inexpensive high power 12V to 5V adapter
- These light bars are the absolute cheapest ones we can find that attract moths ($5) (395nm) https://www.amazon.com/Black-Light-Bar-Glow-Party/dp/B09BCND2J9/
- Lepileds can also be connected
The Box ($25)
- Plano 1460-00 ($25)
- To be as compact as possible, we designed around the Plano 1460-00 case. It’s cheap, waterproof, CLEAR, quite available internationally, and as compact as possible
- (sometimes called plano 3600) 11”L x 7”W x 4”H </span>
Camera Lens Gear ($20)
We are turning the box into a kind of 55mm lens camera so accessories that work for a 55mm lens should work
- UV Lens Protector and Mount
- Lens rings https://www.amazon.com/dp/B005IMNI4K?psc=1&ref=ppx_yo2ov_dt_b_product_details ($3)
- UV filter Amazon.com : Tiffen 55UVP 55mm UV Protection Filter : Camera Lens Sky And Uv Filters : Electronics ($8)
- Lens Hood - not strictly necessary, but helps keep extra rain off lens when deployed.
- buy (includes lens cap) ($9)
Additional Parts
- Plastic for laser cutting (the design is currently set for 3mm acrylic)
- one 50x60cm piece of acrylic can fit all the parts, but you could cut from many scraps too
- White Felt Acrylic sheets
- minimum 205x305mm (8x12in)
- 1/4in bolts and nuts
- bolts
- hex nuts
- M2 M2.5 and M3 Screws and nuts and Electronics Spacers
- e.g Nylon Standoffs and nuts for Raspberry Pi
- Set of m2 m2.5 m3 bolts and nuts
- Zip ties
- 5.5x2.1mm cables** **
- Strap (To attach to tree)
- Lock (to attach to Tree in places you are worried it might get taken)
Tools for Construction
1x the following: Here’s a list of the tools you need to actually create a Mothbox. If you are building multiple mothboxes, you only need one of these tools no matter how many you make.
- 53mm hole saw bit https://www.amazon.com/dp/B07R5RZNQK?psc=1&ref=ppx_yo2ov_dt_b_product_d53etails
- Drill Bits for Plastic
- Most of the holes drilled are 3/8 in (just over 1/4in) in size, but using something like a Tapered drill bit can be the easiest, as it goes through plastic well, and allows you to adjust the sizes of your holes very finely.
- Wire Strippers
- Plastic epoxy
- Spools of Solid-Core Wire
- Red
- Black
- Lever Nut Connectors
- https://www.amazon.com/LEVER-NUTS-Compact-Splicing-Connector-Assortment/dp/B0957T1S9C/ref=sr_1_1_pp?crid=14GVQPDXZMRQ4&keywords=wago+connectors&qid=1704033576&sprefix=wago+conne%2Caps%2C189&sr=8-1
- (or cheaper knock offs should work fine with low voltage like this)
- Dielectric grease (for additional waterproofing)
Why Study Insects for Conservation?
Why Study Insects for Conservation?
Insect populations can be used as an ultra high resolution sensor for changes in environments.
Insects (Especially Moths and Beetles) are Hyperdiverse
Of all life on earth (including bacteria) there are about 2 million species scientists have described and half of the species are insects! What’s more, if you look at just Moths there are about 144,000 species, meaning about 1 in every 14 species in the world is a moth! For reference there are only about 11,000 bird species, and only 6500 species of mammals (and half are bats and rodents).
Using creatures with a super diverse gene pool allows us to make sophisticated insights into the health of different areas. Combining the activity of thousands of species of insects with other data like climate, acoustic, or soil analysis, can provide deep analysis into how environments can be repaired.
Offer Highly Localized Insights
Because they tend to have short lives and often limited ranges, insects can provide super localized data.
For comparison, think about something like a Jaguar, which is a rare find and scientifically valuable to see on a wildlife camera, but they have large ranges and long lives. The presence of a Jaguar does not necessarily tell us much about the health of the environment where it was spotted. It could simply be travelling across disturbed farmland to escape from a destroyed habitat elsewhere.
Having an insect sensor (like a Mothbox), however, that could compare the activity of thousands of different species of insects can highlight differences in environmental health in areas just a couple kilometers apart.
They are Easy to Attract
Humans have long ago discovered that many nocturnal insects like Moths seem to be attracted to lights. We now know this is because bright lights disorient their natural steering mechanism. Scientists have used bright artificial lights for over a century now to take censuses of insect populations. The problem with this type of “Mothlighting” is that it can be incredibly time consuming (a scientist has to hang out all night and note which insects are visiting). Instead we have an automated device that does all this work for you!
Project Background
Due to climate change and pollution, insect populations have been in an horrific decline worldwide. Scientists studying how to combat this destruction conduct a wide array of environmental assays to learn the intricacies of our effects in wide ecosystems. These include assays like soil samples and wildlife camera traps. Insect populations are incredibly sensitive to natural disturbances and can provide a high resolution way of sensing changes in an environment. The challenge with using insects as a broad surveying tool though are that it's time-consuming to deploy traditional insect traps and then process all the sample collected (not to mention they usually have to kill all the samples).
Hubert Szczgiel was one of these scientists and came across a paper by Bjerge et al, "An Automated Light Trap to Monitor Moths (Lepidoptera) Using Computer Vision-Based Tracking and Deep Learning." Sensors 2021 . Hubert then teamed up with us at Digital Naturalism Laboratories here in Panama to make a new version of this. We wanted to use extremely high resolution cameras (64 mp), make it light enough to even be deployed by a drone if need be, and robust enough so that it could function for long deployments in the harsh tropics.
You can read about the full history of the project, but after a year of work and support from several small science grants, we put together a design that has been working great for us here at several scientific and re-forestation projects in the tropics!
Now we want to share this project, so more people can build them and learn more about all the cool insects near them!
Cut Parts
The new v4 version of the mothbox has a more efficient design, and all the acrylic parts can be cut from one 50x60cm piece of acrylic
Acrylic
In the Github, there are files for all the parts you need to cut. You can use the dxf files or we even made layouts of many of the components in lightburn files for you. There is even a file of “all acrylic parts” that you could cut in one go on many standard lazer cutters.
cut all these parts out of 3mm acrylic.
The cam glare blockers should be cut out of OPAQUE acrylic if possible (or you can spraypaint them black if needed).
The arms should be cut out of CLEAR acrylic if possible.
Otherwise the colors don’t really matter.
Felt
The only other part to cut out is the felt cover for the target. Find some white acrylic felt, and cut out the file that says “Target Material” Acrylic felt cuts really easily and cleanly in the laser cutter.
Create Target
There’s many ways to use your Mothbox! The Mothbox’s default software will automatically calibrate its focus and exposure to whatever kind of target is positioned in front of it. The main thing is that it should probably be
- white
- flat
- easy for insects to perch on
We have found that acrylic felt works quite well for insects to walk around on, to stay clean and not mold, and as a bright, light-diffusing backdrop.
Target Options
We share four main options for your target. We have done most of our testing with the Standard Target, so the other options are still a bit more experimental.
The Standard Target is the most compact surface for the Mothbox. It also can be lit up quite easily from lights inside the mothbox.
The Dual Target doesn’t require any additional materials other than cutting an extra Target shape. It can also fold in half so it doesn’t take up much more room than the Standard Target! So you can pretty much double your target area with minimal changes.
The Quad Target is 4X bigger than the standard target. Because of its size though, it is not as easy to travel with. This large target also needs to be positioned further away from the Mothbox which means the amount of pixels per insect will be reduced. It can work great for areas where you are looking for larger and abundant moths.
The “Just Point it at Something” option works if you have some other surface you are using as a moth target. You can use the arms to measure a distance if you want, but you can just point the mothbox at a wall or sheet.
Standard Target
Building the targets are mostly straightforward. You just glue the target material to the target. Using a spray adhesive tends to work well.
- Spray one side of your target material with glue.
- Make sure the protective plastic is peeled off the acrylic target
- lay the target material on top of the side of the target with the inverted logo. (you are covering up the logo)
- lay some heavy flat things on top of the target (to help make it extra flat)
- Let dry for a couple hours
Dual Target
The process is similar to the Standard Target, but you need to cut out two target surfaces. Put their smooth long edges together
Spray the double-wide target material felt with the adhesive spray.
Carefully align it with the two target backings.
Place something flat and heavy on top of them.
Now the Double Wide target material functions as a sort of hinge you can use to close the target and protect it when in transit. You probably need to tape the back when deployed to keep it rigidly open. This probably could use a design tweak.
Prepare Arms for Dual Target
The dual target can fit at the end of the arms in their standard configuration, but they will fill up the camera image entirely. If you want to have a safe margin around the edges of the dual target, you can adjust the arms one notch outward (it moves them about 7 cm outward).
Quad Target
The quad target design is the size of 4 of the standard targets. If you are desperate, you could literally just set 3 standard targets next to each other in a square and tape them all together. But the stability might be weird.
Instead, we included a design to cut out a single large target. We used coroplast (corrugated plastic polypropylene). It’s lightweight and sturdy an cuts easy. You can also make it foldable by making a slit up one side of the corrugation (but you will need to figure out a way to make it sturdy, even some tape will work.).
Cut out your large target.
Cut out its felt material.
Spray the felt material with spray adhesive.
Lay a flat heavy thing on top.
Let dry for a couple hours.
Prepare Arms for Quad Target
Stagger your arms with some extra bolts
With the extra large target, it might make sense to use the External Attractor option since it is a bit further from the Mothbox.
Just Point it at Something
Depending on your setup, you might not actually need a dedicated target! We have used the Mothbox by just pointing it at a white wall with a bright light that insects were attracted to. Many people want to just point their mothbox at a sheet that have hung up for traditional Mothlighting. This can totally work, BUT some things to keep in mind:
- The mothbox will autocalibrate its focus and exposure, but it only does this about every 6 minutes. Thus if it is pointing at a surface that sways or moves back and forth (possibly like a sheet in a light breeze) many of these images will not be in focus.
- The Mothbox is trying to image a full surface which is different than when you try to take pics individually of specific insects on a moth sheet. Its visual field should be of a surface that is as flat as possible or else parts of the image may by occluded by wrinkles
- The lighting near the edges of a surface may not be as well illuminated as those near the middle.
Cleaning Target
Moths can be a bit grosser than you might think. They can poop a LOT. Look at this target I came back to one night. It got real gross.
Bleach
You can use a 20% solution of bleach to scrub out most stains. Try not to rub too hard or the felt can get too fluffy, but in general it’s quite easy to clean.
Have Backups Ready
Felt is cheap and lightweight and you should probably have extra target material cut and on hand in case your current target accidentally gets messy.
We even upcycled our old felt together with old acrylic by just melting them all together with acetone.
Build Exterior
The external design of the Mothbox 4.0 is much more streamlined than the previous 3.0 version.
The Mothbox has 2 main external parts
- Modified Plano 1460-00 box
- Arms
Modify the Box
Drilling Arm Holes
You should start with 4 laser cut arms.
Each arm of the mothbox is made from 2 arms. This is for strength as well as redundancy. If one arm breaks in the field, you already have a backup!
Lay an arm against the outside of the large plastic flanges.
Use a marker to mark exactly where the holes are. Using a 1/4in drill bit (6.5mm), cut two holes for the arm.
I actually use a drill bit that is slightly larger than 1/4in, like 5/16in because my measuring and aligning abilities aren’t always that great, and this gives you a little wiggle room.
Slide two 1/4in bolts through the holes and secure the arms.
Now you should be able to attach the target to the arms easily!
Drill Front Lens Hole
These boxes are manufactured with a little dot directly in the center of the back of the box. You can use this as a reference point to drill a small pilot hole. When drilling this side of the box for the lens make sure to always use a light pressure as you don’t want to press too hard and crack the box.
After you have drilled the pilot hole, You can get out your 53 mm hole cutter bit. Align this bit with the pilot hole and drill out your hole.
Sometimes the edge of this hole can be a little rough and have extra plastic sticking up that can get in the way. You can just take a deburring tool, or a razor, and go along the edge of this cut just to clean it up.
Epoxy the Lens adapter into place
Mix together some 2-part epoxy on a piece of cardboard with a Popsicle stick.
Put a little bit of epoxy onto the rim of the hole you just cut. Add the lens adapter. Use a thin stick to slide around the edge and make sure the epoxy is in all the seam between the lens connector and box.
Then you can use a larger popsicle stick to smooth out the border of the epoxy and have a nice thick seam connecting them.
Use a towel to clean up any epoxy that may have spilled on the inside of the lens adapter.
Once it is in place, and the epoxy is nice and smooth and thick, let it sit aside for several hours to cure.
After the epoxy has dried, sometimes you may notice some white smudges inside your mothbox. It’s not a big problem. These are from the fumes of some glues attaching to oils left from your fingers. This is actually how people do fingerprinting sometimes! You can just wipe it off with a clean, damp cloth.
Interior: Camera Assembly
The inside of the mothbox has also been improved in version 4.0
There is only one laser cut mainboard, and it fits more securely inside the box.
There are 11 laser cut pieces you will assemble with electronics parts.
- Main board
- 4 clips attach to main board (2 wide 2 thin)
- 6 camera glare blocker circles
Camera Glare Blocker
The function of the camera glare blocker is to set the camera a little bit in front of the super bright lights so that they don’t cause a glare that interferes with the image quality.
Assemble Camera Lens Glare Blocker
Take your six circles and stack them on top of each other.
There is a small arrow with a dot at the top of each camera glare blocker circle. All the arrows should be lined up on top of each other.
Place two zip ties through the side holes of the small glare blocker circles to connect all 6 circles together.
Finally, using two M2 screws, you can attach the Camera into place. You can use 4 screws if you really want, but 2 is sufficient.
Attach Camera Glare Blocker to Mainboard
Using the two holes directly to the side of the vertical center holes at the top and bottom, secure the Camera Glare Blocker to the mainboard.
The Camera Glare Blocker needs to be lined up correctly with the main board. You can use the small arrow to line it up with the mainboard. And the arrow also points to the Mothbox Logo.
Interior: Hack Microscope Ringlights
Ringlights
These two circular lights function to evenly illuminate the target area to get high quality images of the moths. We use these ring lights which are originally sold as inexpensive illuminators for microscopes. They are some of the cheapest and highest density bright LEDs we can find, and work well for taking photos of our moths.
More Built-in Redundancy Each mothbox ideally uses two ring lights to illuminate the target. If necessary, though, (for instance if one light breaks in the field and you have no other options) one ring light can be used and placed directly around the Camera Glare Blocker.
It’s best to use 2 ringlights of the exact same brand, as some can be slightly brighter or differently colored than others leading to uneveness in image quality.
Disassemble Ring Lights
We need to disassemble the ring lights before we can add them to our mothbox. This is so we can make them smaller and controllable.
Basically you want to remove all the plastic to turn your ring light from the product on the left, to the bare ring with two wires sticking out of it pictured on the right.
For most of the ring lights you just need to figure out how to pop the plastic container off. Usually there are a couple small screws you can use to disconnect the plastic. Some have a hidden screw that can be found underneath a sticker.
Peel back the sticker and then unscrew the screw.
The front cover of the ring light should easily pop off now.
Some ringlights will now have all the electronics free. Some may still have some internal screws left connecting the circuit boards to the plastic. Unscrew them and remove it.
Now use some kind of thin tool (e.g. a spudger) or flat screwdriver to pry off the front plastic cover of the ring light.
Identify the Power Source
Some lights have a barrel jack and others have a USB cable. Either way they will lead to a red and black wire. Snip them off so you still have plenty of wire connected to the LEDs. Remove all the electronics from the plastic.
Snip Control Knob Electronics Off
From the current version onward, we no longer need to keep the voltage control knob. That’s because we are using our own 12V regulator. This makes wiring much easier .
You basically just want to end up with the ring of LEDs with a red and black wire sticking out of them.
Older versions of the Mothbox kept the control knob on the ring lights. So if you see images with those knobs still in tact, don’t worry about it.
Interior: Attach Ringlights
Connect Ringlight
First Side
Feed the wires of the ringlight through the hole and position it flat against the mainboard.
Add zipties in these two locations to secure it.
One rightlight should be finished and attached like this!
Second Side
Place the second ring light with the wires towards the big open gap
You can zip its wires in place to stop them from getting tangled in things and help protect them
Add zipties through these two holes
After your ringlights have been physically connected in place, just let their wires dangle out the backside. We will connect them in the next step, wiring
Interior: Finish Up
Connect the Raspberry Pi
It sits in the corner of the mainboard. The connection points for the raspberry pi all have a tiny extra hole right next to them. This helps you locate the exact holes for the Raspberry Pi.
We will only connect 3 of the holes of the Raspberry Pi, because one is hidden behind the ringlight. (If you wish to connect the 4th hole, make sure to use a plastic bolt.)
Add three of the spacers on top of the Pi’s holes like this.
Screw them in from the other side
Connect the RTC battery
Make sure to plug the battery into the Pi5’s little battery slot. This battery keeps the clock accurate even if the pi loses power.
Trim Your Zip ties
Now is a good time to trim up the ends of the zip ties you have sticking around
You want to make sure no zip tie parts are sticking out too far where they will get in the way of the camera glare blocker when the internals are loaded into the box.
Connect the camera cable to the Raspberry Pi
Connect the ribbon cable to the Raspberry Pi. If you are using a Pi5,** make sure to connect to the first slot labeled “Cam0”**
Attach Relay hat to Pi
You will now connect the sockets on the relay hat to all the shiny metal pins sticking out of the Pi. First move the camera ribbon cable to the side of the bolt sticking out of the Pi.
Place the relay hat on top of the Pi. Line up the GPIO pins, and press softly down.
Be careful to not pinch the ribbon cable going to the camera
Tape the RTC battery on top of the relays
This is just to keep it out of the way. and to stop it from getting tangled.
Attach a piece of double sided tape to the little battery. Then stick it on top of the relay. Make sure the battery and the wires are not blocking the screw holes or entrance to the battery.
In this image, it kinda looks like there are too many fingers.
Don’t block the screw holes on top of the relay.
Connect the Battery
Unscrew these three screws from the bottom of your Battery
Save the screws for the next step.
Make sure to press down firmly when unscrewing the screws so you do not strip the heads.
Now screw the screws back in, connecting the battery to the mainboard. You don’t need to screw it in too tight or you might strip the internals of the battery. Just tighten them so the battery is firmly connected.
Add the Clips to Mainboard
Now you can attach all the little plastic standoff clips to the edges of the mainboard. These hold the mothbox electronics firmly in place, with the camera and lights in the correct positions inside the plastic box.
If your mainboard still has protective plastic, you might need to peel it off from the mainboard before attaching the clips. Sometimes the protective plastic makes the acrylic sheets too thick for the clips.
There are 2 LARGE clips and 2 SMALL clips
The locations of the LARGE clips have RED arrows. BLUE arrows point to SMALL clips.
Internals Constructed!
Next you just need to wire all your electronics together!
Electronics Wiring: Overview
Finally we will make all the electrical connections to make our Mothbox work! There is no soldering required, just lever nut connectors and wire strippers. We worked hard to keep the electronics as simple as possible so many people will be able to build this. There may be more “elegant” ways of connecting everything together, but we tried to make a wiring style as easy to understand as possible.
Follow along and fear not!
Overview
Here’s a full circuit diagram of the mothbox wiring. You basically connect the battery to a 12V regulator (which gives consistent brightness over the life of the battery and extends its life). This 12 Volt power goes to the relays which then switch the Attractor lights and the Flash lights switch on and off.
If you have a older setup there are some other diagrams available for wiring without a 12V regulator, or if you decide to keep the brightness knobs on your ring lights
Electronics Wiring: Power to Regulator and Relays
Battery Output to Regulator
Start from the OUTPUT of the battery
Start with a barrel plug wire with two free ends. (I actually chopped my barrel plug wire from one that came with a power supply for the LED ring lights!)
This is the plug that will go into the OUTPUT of the battery. Don’t plug it into the battery yet, we want to safely connect everything first and then connect it!
Next we will prepare the 12V regulator.
(New!) 12V Regulator
The mothbox uses a 12V li-ion battery to power its lights. This is because Li-ion batteries (like the talentcell) tend to be the cheapest and most energy dense batteries you can find. One problem though is that 12V Li-Ion batteries should more properly be called “11 Volt batteries”. This is because as they discharge, most of the battery life is spent 11.9 volts and under
A lot of 12 v equipment is tolerant of slightly lower voltage, but things like light can dim. Thus, if you want your mothbox to run for longer and have consistently bright lights (which can be important for experiments!), there is a pretty easy fix! You can just add in a 12V regulator booster. This is a $11 device you can add inbetween the battery’s output and the rest of the mothbox connections.
Prepare the 12V Regulator
The regulator looks like this black box with 4 wires coming out. 1 Red, 2 Black, and 1 Yellow.
Often these devices only have a little bit of wire sticking out, and it’s necessary to use wire strippers to trim the ends so we have about 1cm of bare wire to work with.
Connect Regulator and Barrel Jack Plug
Use an inline wire nut to connect the red and black wires from the Barrel Jack to the red and black wires on the left side of the regulator.
Regulator to Relays
On the Yellow wire of the 12V relay, connect a lever nut with at least 3 ports. On the Black wire of the 12V relay, connect a lever nut with as many ports as you can (ours has 5).
If you end up needing more ground ports, you can always connect another lever nut to this nut with another black wire.
Cut two red wires that are about 10cm long and stick them into the lever nut connecting to the yellow wire.
Connect the centers of the relays
Now connect these two red wires to the centers of the two relays on the left side of the board as pictured below. Use a screwdriver to tighten the connection.
(You are halfway done with the electronics wiring! Congrats!)
Electronics Wiring: Lights
Connect the Lights
Chop the Ring light Knob (if you haven’t already)
If you haven’t already, chop the control knob electronics that came with your ring light. In older versions of the Mothbox we used to keep this, as it regulates the power to the ring LEDs. But now that we use a 12V regulator, we don’t need this part. Those control knobs were also finnicky and often were manufactured with wimpy wires. They resulted in about 90% of the failures we saw in the field. So good riddance!
Make sure to trim the wires sticking out of the ring lights so you have at least 1 cm of bare wire to work with
Start with Ring Light Near front of Battery
Now add an inline lever nut connector to the Ring light that is in front of the battery. Connect a red and black wire that are each 10cm long to this.
Ring Light Under Battery
Now add another inline lever nut to connect the ring light that is below the battery. This light should have a red and black wire coming out of it that are both 20cm long
Connect Both Ring Lights to Relay
Take both the RED wires from each Ring light and make them go into the left port of the center relay (as shown below)
Both wires can fit in this port together, just tighten down the screw and make sure to give a tug test to make sure neither of the wires are loose.
Connect the UV Attractor Light
There’s a couple different options for what kind of UV attractor light you want (Internal, External,etc…) No matter which option you go with, your attractor light will have a RED/PURPLE (Postive) and BLACK (negative) wire coming out of them. I used a purple wire for my UV attractor light so I would remember it is for a UV light, and it shows up easier in the documentation photos below to let you understand what I am talking about. You can use a red wire if you want though.
Take the positive (red or purple) wire from the UV attractor light, and connect it to the left most slot in the left most relay. (Shown as the purple wire in the photo below).
Connect all the NEGATIVE GROUND wires together
Finally, take all the Black wires from the 2 ring lights and the UV attractor light and connect them to the black wire coming from the 12V regulator.
Stick down the Regulator
Finally add a piece of double sided tape, and just stick it onto the battery so it doesn’t jiggle around.
Most of the wiring has been completed! Only one part to go!
Electronics Wiring: Add Charging Port
Add Charging Port
A nice waterproof charging port makes it much easier to use the mothbox! It’s not too difficult to add either!
You need a plug and a socket DC barrel jack cables. And you can also use a inline lever nut to connect them.
Mark your spot for the port. You can use a marker to note the spot. Though right between the big gap between the flanges is a good spot. You might notice my pen mark is a bit to the left. That works, but actually around where i put the red dot should be easier.
Drill a hole. Our socket is a little over 3/8 in in diameter, so i used a 3/8 in drill bit to make a hole, and then wiggled it around a bit to make it large enough to fit.
You can use a razor blade to remove any burrs from the edges of the hole you made.
Slide the socket into place. The rubber stopper and gasket should be on the outside, and the metal washer and nut should come on the inside after it. Tighten it well.
If you are really paranoid about moisture, you can hot glue or silicone around your port to make it extra secure.
Wiring the Charging Port
Use an inline lever nut to connect the socket to the plug.
Now you can connect the plug to the IN port of your battery.
Try it out, your battery should charge now when it is connected to the external port.
When you aren’t charging it, you can put the rubber cap over the port to protect it from moisture.
Hooray, your charging port should be all set!
Electronics Wiring: Disarming Wires
Add Arming/Disarming Wires
The default behavior of the mothbox is to turn on whenever its schedule dictates (or when there is a change in power, or the power button has been pressed), and then start illuminating the attractor and taking photos every minute.
Sometimes you want to temporarily disable the mothbox from running. For instance if you are travelling overnight somewhere, you might not want 20 mothboxes to start lighting up in the backseat of your car. So there is a simple way to add two wires that let you ARM and DISARM the Mothbox.
Get two jumper wires. One wire should be SOCKET-PIN, and the other should be SOCKET-SOCKET.
Plug the SOCKET-SOCKET plug into the pin labelled P27 (Third pin from the left)
Plug the SOCKET-PIN plug into the pin labelled GND (Fourth pin from the left)
So you should have a wire plugged into both P27 and GND now.
Whenever those two pins are UNCONNECTED from each other, the Mothbox is ARMED and ready to go!
If you CONNECT these two wires together (grounding pin P27), then the Mothbox will be DISARMED and will never turn on (until these pins are eventually disconnected from each other.)
Next you can decide if you want to add a voltage Monitor (below), or a Solar Panel or Extra Battery, or if you haven’t yet made your UV attractor, it’s time to do that!
(Optional) Monitor Voltage
The mothbox images are programmed to monitor and log their voltages. This doesn’t affect their use, but there may be situations for advanced users where you might want to only turn your mothbox on, if it has a certain percentage of its battery charged. For instance if you connect a solar panel to your Mothbox, you might want to wait until your battery is fully charged before arming it to run for an entire night.
If you want to add this optional ability to your mothbox here’s how to do it!
Purchase a $12 Adafruit power sensor. Solder its parts together.
Follow the wiring guide from Adafruit for how to connect the 3.3V GND SDA and SCL wires.
Run the MeasurePower.py script included on the Mothbox Github.
UV Attractor
The next step may vary from Mothbox to Mothbox. It’s about choosing what type of light (or in the future maybe chemical?) based attractor you want to use. We are still experimenting with the most cost efficient and effective LEDs one can find, but luckily the openness of the mothbox design lets us be flexible and have many options.
There are three basic options for your attractor
Internal Mothbeam
We have been using the awesome Mothbeam made by Moritz at LabLab. He designed these PCBs to be super low cost, high power, modular, adapatable insect attractors! We have been using pairs with one PCB with a range of UV, and another PCB with an array of useful visible light.
To get one you can
- order them from him by emailing him (moritz@lablab.eu) (the cheapest way) and they are about $90 for a pair.
- order them from circuithub (the most expensive way)
- or because it’s open source, you can get the files from circuithub and make the PCBs yourself! The tricky part is that because they are high power LEDs though, they are made on a heat-dissipating aluminum substrate. Keep that in mind!
What’s nice is you can arrange them in different ways. You can put them together in a container and use it just like a Lepiled or other portable insect attractors. You could then connect these assembled “Mothbeams” as an “External Attractor”
Build Mothbeam
They need to dissipate heat, and fit flat in the front of the Mothbox.
- Cut a thin piece of metal that fits at the top of the mothbox. We use perforated aluminum and some metal shears.
- put a piece of thermal silicone on the back of each mothbeam pcb. (remove the protective plastic first)
- screw them to the piece of aluminum.
- connect the aluminum to the mothbox.
- route the wires through the little gap near the top.
- connect the negative wire to all the other negative wires.
- connect the positive wire to the attractor relay on the far left.
Internal 12V UV Light
You can purchase 12V UV LEDs easily with many commercially available options. Often many will be too large to fit inside the Mothbox, BUT most of the design of these devices is just a large metal case that works as a heatsink. If you take them apart, you will often find the actualy 12V LED is just a thin part.
for instance these inexpensive 10W flood lights
unscrew very easily and consist of just a simple circuit board connected with thermal glue to the metal case. You can take these apart, and using thermal silicone double sided tape (and maybe a little extra glue or screws) connect these UV leds to a piece of metal mounted inside the mothbox like with the method described above for an Internal Mothbeam.
External 12V UV Light
Using the same method for adding an additional charging port we described earlier, you can add an additional OUTPUT port to the bottom of your mothbox. This new external port should be connected to the same relay as you would hook up any of the attractor options. Then you can simply use a DC cable to connect whatever 12 V light you wish to use outside of the mothbox.
Here’s a step-by-step guide for how to add an External 12V UV Light
You need
- 12 V UV Light inexpensive 10W waterproof flood lights
- Waterproof connectors [e.g. these twist on connectors are easy]
- DC barrel jack cable plug
- Extra DC barrel jack waterproof socket
Prepare the external light
We are using these twist-on waterproof connectors because they are about the easiest way to connect wires in a waterproof way. They are full of a silicone goo that keeps water out.
Take your red wire from your light and the red wire from the barrel jack cable and twist them together.
Twist the black wires together as well. And then stick them inside the connectors, and keep twisting until they feel connected tightly.
Test the light
Plug it in to a battery to make sure it works!
Seal it up even more if you are paranoid
You can heat shrink it
and even fill it full of hot glue if you are worried about water (like if you live in the rainforest!). But honestly the twist nuts full of the silicone goo is probably good enough.
Add an External Attractor Port
Following the instructions for adding the charging port we described earlier, just drill another hole next to that one.
Take another DC socket. To keep myself from confusing the charging port and this new UV OUTPUT PORT I color it purple with a marker.
Your internal charging port should already be connected to a barrel plug. Add a lever nut to your new attractor port,
and add a red and black wire to it.
connect the black wire to the ground (or the extra ground wire of the voltage regulator).
I colored the attractor port purple with a permanent marker so that I wouldn’t confuse it with the charging port.
connect the red wire to the attractor port of the relay
Test it all out! It should light up when the mothbox turns itself on and starts running its routines.
Flash Software
Download the latest Mothbox Image to your computer. You may need an unzipping software like 7zip to unzip the image after you download it.
Download Software to flash the the Image. You can use the traditional, Raspberry Pi Imager, or I often use Win32DiskImager.
Get an SD card (at least 16GB). Connect it to your computer.
Start the Imaging software. If you are using Raspberry Pi Imager, click “Choose OS.” Then scroll all the way down to choose “Use Custom.” Click “Choose Storage” and choose the SD card you have connected. Click “Next.”
If it asks you to apply customization options, just click no.
Now it will start flashing your SD card. This should take about 5-10 mins.
Insert SD Card into Pi
Put this newly flashed SD card into the bottom of your Pi and push it all the way in.
Test Everything!
Connect to Battery
Now is the big moment to see if everything works! You can connect the plug to the OUT port of the battery,
and also plug a USB cable into the raspberry pi and connect it to the battery’s USB port.
When you flip the battery’s switch to “on”, everything should turn on!
At first just the little LEDs on the Pi and the Relay will turn on.
First Boot Up
The first time a Mothbox boots up with a fresh SD card, it will take a lot longer to start up than normal. It has to do all kinds of prep things inside the SD card that take up time on the first launch. It will often shut itself down after it does a first launch. So the first time it gets powered, just wait 10 minutes. If it doesn’t turn on after that, restart the power and it should start up soon.
Second Boot Up
Sometimes the Mothbox will automatically launch the very first time you turn it on, but again, don’t worry if not. Just wait 10 minutes and restart it if it hasn’t started.
On the second boot, after a minute or so, the operating system will have loaded up, and the whole device should go into “Mothbox Mode,” turning on the UV attractor and flashing the Ring Lights every minute.
If something is not lighting up, check your connections you wired up!
If everything is looking good, it’s time to start USING YOUR MOTHBOX
(Optional) Solar and Extra Batteries
The Mothbox has an internal battery that can sample for about 4 nights on its own (22 hours of runtime). BUT maybe you want a SUPER POWERED mothbox that can last even longer?!
Well its very easy to add solar panels or extra batteries to the mothbox!
Add a Solar Panel
This is pretty easy to do! Simply plug a DC barrel jack cable from your panel to the charging port.
That’s it!
We talked to the Talentcell people who make the batteries, they said lots of solar panels will work, especially 18V panels up to 60Watts.**
Panels should be max 18V and 60 watts
Add Extra Batteries
This is also quite an easy addition. You can just plug a DC barrel jack cable from the output of one talentcell battery to the input port of another! Easy as that! You just need to make sure that both batteries are fully charged.
All batteries need to be fully charged if you connect them
Build a waterproof battery pack
You can make an extra power case to connect to your mothbox in the field very easily. You just need an extra waterproof case. You can drill a port exactly the same as when you create the input port for your mothbox.
Add a DC barrel socket to it. Connect a barrel jack plug with a lever nut.
Plug it into the OUT port of an extra talentcell battery.
Seal up the box, and plug it into the input port of your fully charged mothbox
Double Battery Pack?
You bet! Again just make sure all the batteries are charged up fully. Use a DC cable jack splitter (one usually comes with your talentcell battery!)
Plug it into BOTH OUTPUTs of the batteries in your pack.
And you are ready to have a mothbox that can run for 66 hours! Or 12 nights!
Portable Field Guide
The steps below show you what to do to make sure your Mothbox will run in the field. This is also available as a small print out that fits inside the mothbox. We print and laminate them and include them with each mothbox to make sure everyone knows how to use it. This Field guide is available in English and Spanish (and hopefully even more languages soon!)
Basic Use
Preparation
Before you go to the field here’s a checklist of things you go through to make sure it is ready for deployment!
- The battery should always be ON. The switch to the battery should ALWAYS BE IN THE ON POSITION. Open the mothbox make sure the battery switch is ON (if it’s not already on).
- Charge your mothbox. This usually takes several hours. Plug it in. Only use Mothbox charger to charge. If the plug’s indicator is red, the mothbox is charging. When charger light turns green, the mothbox is fully charged!
- USB Storage. Make sure there is external storage plugged in to the Pi’s USB to record your photos.
- Arm Mothbox. The mothbox has two jumper wires that keep it from turning itself on until it is deployed. Arm your mothbox by disconnecting the wires from each other putting them in the “armed” position.
- Check Lights. The RED STANDYBY LEDs should always be on. The mothbox is set to run according to a schedule automatically, so it probably won’t be running when you are setting it up, but you can visually check that things are ok, because there should be a RED led light on the Pi (the pi’s off light) and the battery’s green lights should always be on. (Older models with a Pijuice may also have a BLUE light on as well in standby mode)
- Add Silica. Add packet of silica drying gel inside box.
- Close Box. Make sure box is fully closed and no wires are caught in the door.
- Item Checklist. Make sure to have all these parts with you BEFORE you go into the field
- Mothbox
- USB Storage
- 4 Arms
- 4 Bolts
- 4 Nuts
- Target
- Strap
- Security Chain (if in places where theft may be an issue)
Deploy
- Attach arms to bottom of case with 1/4” screws and nuts. Place target on the end of arms.
- Hang Mothbox. Using the handle, strap mothbox to a tree or tripod. Make sure there are no obstacles (like leaves or tall grasses) that may blow between the box and the target. In general, the Mothbox should be at least 0.5 meters above the ground.
Adding a little wrap of the strap around the handle (The Margaret Technique) adds stability to the mothbox
- Inspect Lens. Check lens for dirt and clean if necessary. Make sure lens cap is off
- Connect Target. Attaching the target should be one of the last things you do because you want to protect it from getting dirty. If you have it connected earlier, it could easily bump into wet or dirty plants and get mud on it.
- Log Data. Write down all the metadata about this deployment on your field sheet.
warning: Don’t look directly at UV light. UV is very bright but invisible to your eye. Can cause eye pain or headaches with long exposure. Use eye protection if working with mothbox for extended periods while it’s on.
Default schedule: mothbox will take photos from 19:30-20:30, 22:30-23:30, 1:30-2:30, and 4:30-5:30. If you want it to take photos at different times, change the settings.
Collect
- Collect the mothbox. Make note of any damage, such as water inside case, dirt on target, or physical injury.
- Disarm the mothbox with disarming wires.
- Disconnect external storage from the USB port and check out all your cool photos!
- Backup and organize all the photos from the external storage, and then clean this storage device, deleting all the old folders so it is ready for the next deployment.
- Charge for the next deployment.
Manually Turning the Mothbox On and Off
The Mothbox has an internal schedule that let’s it stay in a low-power state until it is ready to turn itself on. Sometimes you may wish to manually trigger the Mothbox to start running a photo session. Or you may wish to manually turn off a mothbox that has started running.
Turn It On
You can turn the Mothbox ON by just pressing the “On” button located next to the LED on the Raspberry Pi. Just tap it once, and it will start up.
Turn It Off
You can turn the Mothbox OFF by pressing and holding the “On” button for 10 seconds. Just press the button and hold it until the mothbox has shut off.
Data Organization
Documenting Deployments
Equally as important as the photographic data you collect is the metadata about your deployments.
We have printable forms field technicians can take to their sites,
or alternatively fill out the online version of the form (bilingue).
Remember to collect this metadata for EVERY SINGLE DEPLOYMENT or else it is not useful in the end!
All photos from a single deployment should be in a folder named with the convention: “AREA_POINT_MOTHBOXID_YYYY-MM-DD”
#Mothbox ID The Mothboxes all have a unique, persistant name (based on the Pi’s serial number). The names are in the format of (descriptiveword+animal) and are made from the thousand most common descriptive words and animals in both english and spanish.
This is why you will have names like “CoolJirafa” or “PrizeCrab” The name should be written on a sticker on the Mothbox. Like “FondoGorila”
Structuring Data
Semi-Automated Insect Identification is still a relatively new field so there’s not many standard to follow to help us organize our data. So, we are trying to base our meta-data formats off existing types of scientific data collection and processing such as camera trap data.
All the data collected is unique in a specific time and place. Each time-period that a Mothbox is set into the field and then collected is called a “Deployment.” A deployment could last several days or even weeks.
In physical space, we currently organize deployments into different zones.
Country-> Area -> Point
The Country is the country the mothboxes are deployed in. The “Area” is the broader region or group it is being deployed with. For instance it might be “Gamboa” or “Totumas.
The “Point” is a specific descriptive name for where the mothbox is actually being used. For instance “GuasimoTreeBackyard” or “VineNearRioFrijoles.”
Photo and MetaData
A “raw photo” data looks like this:
We send those images to an insect detecting AI, which then creates “individual photos” of each creature detected in the raw image. It would look like this:
For each individual photo of a single insect we collect, we eventually want it tied to the following information as well:
- occurrenceID (file name with unique timestamp of the specific individual photo “gradoVerdín_2024_07_25__21_12_05_HDR0_crop_0.jpg”)
- basisOfRecord (i.e. MACHINE_DETECTED)
- deployment ID
- eventDate (timestamp)
- GPS data
- raw_photo (location of the original “raw photo”)
- identifier (Who did the most up to date ID? i.e. “Mothbot” or “Hubert Szczygiel”
- cv_confidence (how confident the AI was in detecting this if machine detected)
- Taxonomic information: class order family genus species commonName scientificName
Inventory of Mothboxes
If you are running a project with many Mothboxes (more than let’s say, 4) you probably want to start keeping an inventory. Field equipment can get lost, forgotten, or busted up, so it’s handy to know what you have available if a new opportunity strikes! Here’s an example of how we organize our inventory of mothboxes. (Maybe you have suggestions for better organization?)
Deployments (So Far!)
Here's a fun list of where the Mothbox is already being used! If you build one and start using it, maybe we can add it!
This is a list of just some places the Mothbox has been so far!
Panama
Gamboa, Panama
Near Dinalab has been one of the main testing groundds for its development. It has a harsh tropical environment of heat, humidity, salty air, and microbes that the US Military used to use for materials testing and means that things that can survive being left outside here stand a great chance in other parts of the world! This includes “urban” Gamboa which, because it is in the Canal zone, gets fumigated regularly and seems to have not as much insect Biodiversity these days :( . This also includes areas deeper in the forest like pipeline road or plantation trail which have an abundance of rainforest insects.
Azuero Penninsula
Pro-Eco Azuero, Panama
One of the first big projects to use the Mothbox is the large community reforestation project headed up by Pro-eco Azuero.
The Mothbox is being used by Hubert Szczgiel as part of a multi-modal biodiversity assay to monitor the impact of the reforestation.
La Alza, Cambutal, Panama
Another reforestation project at the very bottom of the Azuero Penninsula!
Reserva Ecologia, Azuero, Panama
A private reserve for maintaining the forest.
Mt. Totumas, Panama
A reserve/reforestation project/ award winning organic coffee farm on top of a mountain in western panama. It’s also run by Jeff Dietrich who is a huge moth nerd :). Jessie and Mulget are currently deploying mothboxes there to study the moth biodiversity (and there’s a ton!)
Barro Colorado Island, Panama
The world famous research island has also been home to Mothbox tests!
La Fortuna Ecological Reserve, Panama
Several mothboxes are being deployed by the technician, Bady, at a massive reserve with an incredible elevation gradient. This unique forest in western panama goes from 90m to over 2000m, and features weather that seems to change every 10 minutes.
Accoring to the PI overseeing work in this area, Jim Daling, it’s probably one of the most moth-rich places in Panama!
Ecuador
Amazonas, Ecuador
We went to the ELEN tropical butterfly conference and set up some mothboxes overnight in the rainforest.
(We also set one up in Quito, but it is chilly and urban and it got exactly one moth the entire night.)
#Peru
Madre De Dios, Peru
The Mothbeam was also tested to a resounding success in Madre De Dios
USA
Providence, Rhode Island
Our friends are building at the libraries there with their Wildlives class that sets up camera traps with children
Columbus, Ohio
We deployed a mothbox there as part of Beetlepalooza 2024 at OSU! Got to set one up in the backyard of art-science awesome people Amy Youngs and Ken Rinaldo!
Alaska
Hubert works up in Alaska in the summer and brought a mothbox with him!