Wile E. Coyote's ACME catalog may have never listed a coffee grinder, but if it had, it would probably have looked a bit like this.

This is the guide to controlling a coffee grinder with a TNT blasting plunger you never knew you needed! It is admittedly pretty darned specific -- however! you can use the techniques here to use nearly any high-powered AC device as a switch for your microcontroller projects. Plus, the addition of the controllable power outlet module means you can instruct your microcontroller to turn on and off a second AC powered device, such as a blender, drill, lamp, or pump.


Besides the electronics parts listed above, you'll need a 1000uF electrolytic capacitory, and need a source of AC power that you'd like to use as a switch, such as a TNT blasting machine or hand-cranked generator.

You'll also need something that can be plugged into AC to trigger, such as a coffee grinder, blender, lamp, or pump.

A small wooden, cardboard, or plastic box to use as enclosure will be helpful, as well as a pair of #6 x 1" screws, nuts, washers, lock washers, and wing nuts to use as terminal posts. 

The blasting machine works like this: you lift and then push down (hard!) on the plunger which has a rack gear on its shaft. This in turn rotates a type of generator called a magneto. Which converts your kinetic energy into electrical energy -- around 30-60V of AC (alternating current) at about 1.5A! This is enough to send a decent amount of power down a long line to a set of blasting caps embedded inside sticks of TNT. 

This is also enough to totally fry a microcontroller! So, we need to build a circuit do a couple of things for us to make the signal microcontroller friendly.


 The first thing we'll do is take the AC current and convert it to DC. For more detail, check out this guide on power supplies!

This image shows us how alternating current is a sine wave that moves from zero to positive to negative voltage. It also shows how a direct current is ideally constant and positive, for our needs.

An easy way to convert the AC signal is with power diodes, such as the 1N4001, which only allows current to flow through in one direction, effectively clamping it to the positive-only half of the waves.

Turns into this:

This is called a "half-wave rectifier" because we end up with half of the original AC wave

Not bad, but we want to smooth out that signal. Enter: the capacitor.

The capacitor acts like a fast charging/discharging battery, so the wave doesn't dip down as badly as it did before.

We can do one more simple thing to improve that wave from the half wave into a full wave, by essentially mirror the negative peeks of the original AC current up to positive.

Four diodes arranged like this will give us what we need.

Including the capacitor for smoothing, here's what the wave now looks like:

This is called a "full-wave" rectifier because we capture the full wave from the original AC wave, but just keep it all positive!

Depending on your setup, you may not actually need a full-wave rectifier. If you're just sensing the device, a half-wave will probably be fine. If you're trying to charge or power your project, a full-wave will get you 2x as much power, so its more efficient!

Personally, I wasn't sure what I'd be using the prop for when I first started laying out the circuit so I went with the more-useful full-wave!

Voltage Divider

Now that the current coming from our blasting machine (or other AC source) has been converted to DC, we need to drop the voltage down to a lower level.

For this, we'll use a resistive voltage divider. This uses two resistors in series -- one connected to the positive source the other connected to ground. The voltage at the intersection of the two resistors will be the "divided" or reduced voltage we need. 

We just need to sense the voltage, not power something. If you want to actually power your device, use a regulator or buck converter to take the high voltage down to 12V or 5V, whatever you need.

By choosing a 100k resistor and a 4.7k resistor, we'll get our original, say, ~30-60VDC (maybe a little higher depending on how hard you push it) dropped down to around 1.3-2.6VDC.

You can calculate the resistors with this formula: Vout = Vin * (R2/(R1+R2))

Try building the above circuit on a breadboard and testing the voltage with a multimeter. Once it's working well, it's time to solder the circuit to a permanent FeatherWing Proto board that we can stack onto our Feather.

Solder 6" lengths of wire to the AC input pads on the FeatherWing Proto board as shown in the diagram -- these will be connected later to the blaster -- and solder 24" lengths of wires to the ground and pin 9 pads to run to the relay later.

By connecting the output of our circuit to an analog pin on our Feather (or other) microcontroller, we can use software to read the voltage level. Go ahead place the FeatherWing Proto board the Feather -- this will connect the circuit's divided DC output to pin A0 on your Feather microcontroller, as well as common ground.

Don't even *think* of connecting the 'raw' 30VAC or 30VDC to your microcontroller, you will blow it up!

Make sure you can upload code to your Feather -- use this guide if you are just getting started. Once you can successfully upload to the board, move on to the next step.

Copy the above code, and then paste it into a new Arduino sketch. Save it as acRead.ino and then upload it to the Feather. Open the Serial Monitor in the Arduino IDE (Tools > Serial Monitor) and you'll see the values mapped from 0 to 1023 showing up. Apply your AC current by plunging a TNT plunger, or spinning a bicycle wheel light generator, or however else you like, and you'll see the values increase temporarily.

Or, you can visualize things using the Arduino Serial Plotter Tools > Serial Plotter

Now, we can create code to read the voltage level and wait for it to hit a certain threshold before sending the signal to the relay in the power strip.

//Coffee Detonator
// Reads TNT blasting cap detonator voltage levels and 
// triggers a relay to power a coffee grinder
// by John Edgar Park
// for Adafruit Industries
//MIT License
const int analogInPin = A0;  // Analog input pin attached to voltage divider
int sensorValue = 0;        // value read from the pot
int controlPin = 12; // pin attached to relay
int RUNTIME = 5000; //time to grind in millis
void setup() {
  pinMode(controlPin, OUTPUT); //set pin attached to relay as output
  Serial.begin(9600); //use for monitoring and debugging
void loop() {
  sensorValue = analogRead(analogInPin); // read the analog in value
  //Serial.print("sensor = ");
  delay(2);// wait for converter to settle down
  if(sensorValue>=1000){ //anything above this threshold will trigger it
    digitalWrite(controlPin, HIGH);
    digitalWrite(controlPin, LOW);

Copy the above code and save it as a new Arduino sketch called coffeeDetonator.ino. Upload it to the Feather. Now, when the voltage goes up to a certain level, the Feather will close the relay inside the power strip for five seconds. You can adjust this time by changing the "RUNTIME" variable.

We can make a neat little enclosure to hold the circuit, microcontroller, and battery, as well as provide posts onto which to clip the leads coming from the detonator.

I modified a small wooden box I got at the thrift store for $1.97, but you can use any type of non-conductive enclosure you want.

Mark for holes on your box, leaving some room from the interior walls for the nuts to fit.

Drill out the wholes with an appropriately sized bit.

This is a good stacking order for the posts, with the screw and first washer of each going inside the box, and the remaining hardware on the top.

Drill out and/or chisel a hole for the panel mount USB extension to fit.

Plug the LiPoly battery into the Feather's battery connector.

Wrap the wires for the AC input on the FeatherWing Proto board onto the posts on the inside of the wiring box. (Alternately, you can us crimped spade lugs.)

Connect the FeatherWing onto the Feather, plug the USB panel mount extension into the Feather, and place them and the battery inside the wiring box.

Leave the relay wires running out of the box, and then close its lid.

Connect leads from the terminal posts on the wiring box to the posts on the detonator or other AC source.

Strip some insulation from the ends of the relay output wire coming from the wiring box, and screw them into the screw terminals on the power strip. Polarity matters here, so make sure you follow your color coding.

You're ready for action! Plug the relay controlled power module into a wall outlet, then flip its switch from OFF to RESET (which means "on").

Now, plug your coffee grinder into on of the normally off outlets on the power module. Flip the grinder's own power switch to ON. 

Dramatically raise the detonator hands. Yell "Fire in the hole!" or some other appropriate warning. Give the plunger a good plunge, and BOOOOM your coffee is grinding!

Beautifully ground coffee always tastes best when it's been initiated with a TNT blasting machine plunger.

This guide was first published on Apr 12, 2017. It was last updated on Apr 12, 2017.