Building crickets

2015-August-03– I wrote up this Cricket article for a Maker Camp project I created for the Novato library, July 2015.

What we’re building

A “cricket”! It’s all digital, using an 8-pin microcontroller and just a few other components. A “microcontroller” is like a tiny computer, complete with processor controleld by a program, some memory, and peripherals like timers and inputs and outputs.

I wrote a program for the microcontroller to make it act like a cricket. That means it will chirp when the lights go down. When it gets really dark it chirps louder and faster. If the lights come on, it gets scared so it stops. If it’s been chirping for a few minutes and the lighting has not changed at all it will fall asleep.

Before we start: How solder joints should look.

These were done by someone (Julie, my wife) who practiced soldering for about 20 minutes. They are not perfect but they work. Your solder joints need to have a smooth shiny appearance. If they are dull grey or rough, they might not work. You can reflow the joint by heating it again and applying a little more solder.

You need ENOUGH solder but not big massive blobs.

battery solder joint

We’re using “dead bug” style construction. We turn the PIC upside down so its legs stick up in the air like a dead bug.

PIC solder joints

Bill of materials

  1. Microchip 10LF322 microcontroller in the 8-pin DIP package
  2. 1/4 watt carbon film resistors: 1K and 10K
  3. Piezo buzzer
  4. CR2032 button battery and holder
  5. Four pieces of hookup wire, about an inch long each. I used 24 gauge solid conductor.
  6. Something to hold all the parts; I used an Altoids tin, it’s sort of traditional

All cricket parts

PIC 10LF322 is an 8-bit microcontroller made by Microchip.
The piezo speaker bends when voltage is applied to it, bend it fast enough and it makes a sound.
Resistors are devices that limit current.
A photoresistor is a special resistor that can detect light and varies its resistance.

Each resistor has a color code to tell you what its value is in ohms. For the cricket we need two, 1K = 1000 ohms and 22K = 22,000 ohms.

Resistor color codes

For Maker Camp, I preloaded a program into the PIC microcontroller that makes everything work. If you are reading this on the web site, I would be happy to provide more information on the program and how it gets loaded, or to send you a pre-programmed PIC. The program is written entirely in the C language and it’s maybe a hundred lines of code.

The build

We’re using “dead bug” construction. It’s called that because when you flip the PIC upside down with its legs sticking up in the air, it looks like a dead bug.

Using dead bug construction will make this project cheap and quick to build. The downside is, it’s also easier to break pins off the PIC and harder to reuse parts.

To reduce the chances of messing up, we will build parts first into 2 subassemblies, then attach those subassemblies to the PIC.

The first subassembly is the speaker.

We have to attach a wire to one lead of the speaker and the 1K (RED-BLACK-BROWN-GOLD) resistor to the other lead.
It’s easiest to solder the resistor to the speaker and then the wire to the speaker as two steps.

Step 1: attach resistor to speaker; use either pin on the speaker.

Soldering resistor to speaker

Step 2. Attach a wire to the other speaker lead.

Speaker + 1K resistor
Speaker + 1K resistor

The second subassembly is the light sensor.

Together, the photoresistor and the 22K resistor form a circuit known as a “voltage divider”.
When we’re done, the photoresistor goes to the + side of the battery and the resistor to the – side.
The wire lead goes to the input on the PIC controller. Put the three parts together like this then solder. That is, attach a wire and the 22K resistor to one of the leads on the photoresistor by crimping them with needle nose pliers, then solder the joint in one step, this is better than trying to solder one part, adding the second and soldering it, because the first joint will fall apart when you heat it the second time.

Photo resistor + 22K resistor + wire
Photo resistor + 22K resistor + wire

Next The sensor gets attached to the battery. DON’T SOLDER YET. There are more wires to add.

Attach sensor to battery

Add a wire to each terminal on the battery holder. Use a light color (I used yellow) for “+” and a dark (purple) for “-“. The standard is to use red for “+” and black for “-” but I did not have red and black.
The battery holder has a little “-” in a circle near the “-” terminal. Of course, if you get the wires backwards, nothing will work.

After connecting the resistors and wires your battery should look something like this.

Attach wires to battery

If the wires don’t fit through the battery tab holes then just attach them onto the resistor leads, near the battery holder tabs.
Now solder everything. Solder should flow over the whole joint, you need more here than anywhere else in the project.

Here is the back of the battery holder. Solder flowed down over the whole tab.

Solder everything

Now onto the heart of the project. The controoler. The PIC controller has eight pins. Pin 1 is marked by a little dimple.

Finding PIN 1

From the top… (I need to add a diagram here.)

1      8
2      7
3      6
4      5

As a dead bug… upside down

8     1
7     2
6     3
5     4

You HAVE to keep track of pin 1 once you turn things upside down else NOTHING WILL WORK!!!


The way I did this was by putting a DOT on the can with a Sharpie marker, then gluing the PIC down so that PIN 1 is NEAR the DOT. Another way is to actually color pin one with the Sharpie– we won’t be soldering anything to it anyway. Here’s how I marked my tin can.

Mark the lid

Next you need to glue the PIC into the can. Use hot melt glue, and do this QUICKLY — the cold metal can will cause the glue to glob up and harden fast. If that happens just peel off the glue and try again. You DON’T want the PIC to fall off in the next step, so use a good size blob.

Glue down the PIC

Now attach the leads for the speaker assembly to the PIC.

8      1
7      2
6      3 ———– speaker
5      4 ———– 1k resistor

Attach speaker subassembly

After soldering, carefully bend leads to position the speaker inside the lid. It has to be far enough inside so the lid can still close.

Fit speaker inside

Then glue the speaker down. This will just help keep everything together so it won’t get broken as easily.
Don’t short out the metal connections to the can.

Glue down speaker

Mount the battery in the can.

Some of these cans have paint on them but to be on the safe side, I put a piece of tape down to insulate the battery terminals from the metal. If you short the battery terminals together, the battery will go dead in about a second.

So first put down a piece of tape and then glue the battery to the tape. Pin 2 on the PIC gets the “-” wire and pin 7 gets “+” so position the battery / sensor assembly to make it
convenient to hook the wires up.

Glue down battery

After the glue has set, carefully bend each wire around and attach them to the PIC. Solder.

DONE, ready for battery

Again that’s PIN 7 = YELLOW (“+”)
and PIN 2 = PURPLE (“-“)

As I said earlier, normally RED = “+” and BLACK = “-” but I did not have red and black. The electrons only care if the wires are hooked up correctly.

All the wiring is now done. The battery looks like this.

Note the plus, this side goes UP
Note the plus, this side goes UP

Pop in the battery with the “+” side UP (visible when in the holder).
The cricket will make a beep as soon as the battery is plugged in. Then it will start chirping.  The cricket wants to be in dark places, so if it does not start chirping try closing the lid on the tin or turn out the lights in the room.

It should start chirping now...
It should start chirping now…

To make the battery last longer (and to be less annoying!) if the
lighting is not changing then the cricket will stop in a few
minutes. Waving a flashlight at it or shading the sensor (any significant change in lighting) will wake it up and it will start chirping again.

That’s it, we’re done!

This device is a “cricket” only because of the program loaded into it. With this hardware, it has the ability to sense light and temperature and to make simple sounds. (I did not use the temperature sensor in the final version of the cricket program.)

What else could this hardware do?

Example: it could be an alarm for an open door on a refrigerator. It would sense light when the door has been open for say 5 minutes and then start beeping. Then when you close the door and it’s dark, it would stop.

All you’d need to do to make the cricket into a refrigerator alarm would be to write and load a new program into it.

What is your idea? Leave me a comment.

College of Marin, from the hills

Macbook and NanoBeam and College of Marin
Macbook and NB M5/15 on the hill near College of Marin

On today’s geocaching hike I carried my NanoBeam M5/16 up into the hills.

Now I am sitting on a hillside, the temp is about 74, a gentle breeze is blowing, and I am connected to the College of Marin network at 40 Mbps. Whoo whoo! A turkey vulture is circling in front of me about 40 feet away! Wow!

The NanoBeam works well for this application because the whole radio is housed in the small dome antenna you see in the picture.  I used it with a power injector wired to a small 12 volt SLA battery. The mast is a piece of PVC tubing.

I bought the NanoBeam back in January to do testing when I was working with a certain local WISP, before learning 1/2 their network operates on nonstandard frequencies.

Time to break it all down though and go have lunch with Julie. Well – it would be better if Julie were HERE instead of work.  <3

Range according to my QGIS map is just over 1/2 mile. The NanoBeam is connecting with very good signal strength to a Ruckus Wireless access point located inside a campus building.

NanoBeam screenshot at College of Marin
NanoBeam screenshot at College of Marin


I am slowly moving away from public / free services and back onto my own servers. About a week ago I installed ownCloud at home, and now instead of 5 GB of Dropbox space I have 240 GB of ownCloud space, and I can easily increase that anytime I want.

If you don’t happen to run your own servers this might not make any sense, but I do, and so far it does make sense to me.

I get space limited only by my hard drive capacity, and I feel I have more privacy.

The more I use it, the more I like it. Since I move around a lot, my Mac always has copies of the projects I am working on. My desktop at home now keeps a local copy of the same projects.  I can create a folder for GIS data and sync it up between the home server, desktop, and laptop, so I no longer actually need a high speed server to deliver data across a 1G network at home. Now I can go back to running a smaller home server that uses less energy; it can spin down its hard drives nearly all the time, and I will never see that lag when they spin up to accept ownCloud updates.

The only downside so far is that my O’Reilly account is linked to Dropbox. I am thinking that I will set up an ownCloud server to be a Dropbox client, and it will serve that directory space to my ownCloud clients. This should make it transparent to my clients without duplicating any files.

Farebot and CyanogenMod and no Google

I just installed CyanogenMod CM12 on my Nexus 7 GSM (aka “Tilapia”), and it works now. Last time I tried (around December), the launcher would only run about 30 seconds. Crash restart crash restart. This made the device very hard to use. :-)

So a month or so ago Google released Lollypop for the Tilapia and I tested it. Two problems. (1) SLOW SLOW SLOW (2) Battery life is GONE.

To be fair, battery life might have to do with running a SIP phone program all the time. But it’s still too slow.

So last night I installed CM12 again, it works, and it’s snappy!

I am now in the process of installing apps WITHOUT Google Apps. This means no Play Store. I am 58 so I don’t want to go to the “Play Store” anyway. I go to F-Droid now instead.

The App of the Day is “FareBot”. It lets me read the data on my Clipper card (used for public transit in SF Bay Area, including buses and BART), and the really cool and creepy part – the card has a log of all the trips I have taken. Date, time, and fare paid.

Farebot Log
Farebot Log

I keep more detailed notes on my Nexus 7 here: Nexus 7

Building comms for Battle Mountain

Shortly after returning to Sonoma county, I got in touch with a friend
from my IHPVA/WHPVA, Steve Delaire of Rotator Recumbents. Though no longer in the recumbent business, Steve is still active with IHPVA.

From what I can tell IHPVA now pretty much just does one thing– they run a one-week speed event outside Battle Mountain, Nevada.
Speed events are fun but I have always been more interested in practical applications of human power, like commuting by bike.

Still and all, Steve told me he had volunteered to work on communications for the event.  Providing communication support is
interesting to me. So I signed on to help.

There is no cellular network out there in the middle of Nevada, so mobile phones are useless. They’ve already tried handy talkies, which do not have enough range.

There is a nearby 2m repeater, so my first idea was to enlist local
ham radio people. Turns out that approach had already been tried and they are not interested in helping.

Steve’s idea was to use WiFi and smart phones. I am not convinced this is the best approach but it is certainly interesting to me, so it’s
what we’re trying. Steve still has more optimism than I about the
limitations of WiFI in smart phones. :-) My experience indicates that
you need a good antenna to make wifi work over more than about a hundred feet and I’ve never seen a smart phone with a good WiFi antenna.

But I love working with all these goodies, so I dove in.

Continue reading Building comms for Battle Mountain

ArcGIS on a Mac

I should have written many posts by now, so much stuff is going on.

A hardware failure in June inclined me to retire my beloved 2009 13″ Mac Book Pro and to replace it with a brand-new 13″. It is better in just about every way. My beloved told me to get the top end model, so it has the fastest i7 processor, 16GB RAM, the 1GB SSD. I thought the Retina display was just hype but especially for my old eyes, but now I find every other screen looks blurry and faded.

It is smaller and lighter, in part because there is no built-in DVD drive. I got an external USB drive for $30 from Newegg.

Committed as I am to doing GIS on a Mac while living nomadically, I went through a week in July of testing VirtualBox, VMWare Fusion, and Parallels 9. Parallels 9 won the contest. I was able to directly import my existing VirtualBox VMs into Parallels and I have not looked back since.  For me, it’s the video driver. Parallels has the best out of the three. Very important for graphics intensive programs like ArcGIS and Topo.

ArcGIS 10.2 and Delorme Topo 9 work great. I was disappointed by VMWare Fusion, especially since ESRI specifically mentioned it in ArcUser magazine. Don’t bother. Use Parallels.

It was not clear to me at the Parallels site, but you can install it and select “trial” mode, just download and run the installer without paying for anything. The same is true for VMWare Fusion, and you can install them both at the same time, you just can’t run them at the same time.

Parallels 10 came out in September,  I upgraded, and yes, it really is better and faster. Upgrade if you have version 8 or 9 — it’s only $50. It’s worth it.

GIS on a Mac

I am between houses now and I miss my nice file server Dart and my nice desktop Laysan because they are in storage, so I want to work more with GIS on my laptop, a MacBookPro (Stellar).

The best set of instructions I have found for setting up the open source GIS tools I know and love on my Mac is here:   Installing Open Source Geo Software: Mac Edition These instructions are pretty complete and worked well for me on Mavericks.

I found I had to install pillow to satisfy the requirement in tilestache for PIL.

sudo pip install pillow

It took several hours to install Mapnik; skip that step if you don’t plan to use it.

In the past I used stackbuilder to install postgresql and postgis on my Mac. I removed that version and install with brew; what could be easier than

brew install postgresql

brew install postgis

I had to hack around a bit to get postgres set up. I created /usr/local/var/postgres/9.2/main by adding “export PGDATA=/usr/local/var/postgres/9.2/main” to my .bashrc and then running initdb. I had to do the command “createdb” to get my user created so that “psql -h localhost” would let me connect to the server.


Moving back to California

Our house is now (unofficially) for sale. We have not listed it anywhere yet. It’s at 415 SE Alexander Ave in Corvallis, Oregon


Trulia lists it at $309,000.  See their listing for more detailed information.  The house is less than a mile to the city center, yet it’s on a huge .63 acre lot.

Most rooms have original hardwood flooring (refinished a few years ago). The master bedroom has carpet over the hardwood, One bedroom has cork. The kitchen has marmoleum flooring and paperstone and formica counters and custom-made cabinets. It has a solartube skylight to let in extra light as does the bathroom.

Off the kitchen is a room that has a french door opening onto a new 8×12′ composite deck.

The yard is split roughly 50/50 between the front section with landscaping (lots of natives) and the back which is about a 1/4 acre used for veggie garden. The last 30 feet or so at the back is a buffer zone behind the deer fence; there is roughly 5 acres of space back there that is undeveloped.  Yes, that’s right, right here in Corvallis there is 5 acres of open space behind our house!

We have producing cherry trees and plum trees and apple trees. We have blueberries and marion berries. We have a young walnut tree and a young persimmon tree.

When we moved in, it was mostly a big lawn front and back, there is still enough lawn in the back to enjoy but you won’t need to spend all weekend walking behind your lawnmower.

We have a well to provide house and garden with water, but we are connected to the city for sewer service. There is a water softener for the house. The water heater is electric.

We have a 96% efficient gas furnace (about 4 years old now) and new ducts. All windows are double pane or better. We have full insulation including under floor.  The house is warm and snug and energy efficient.

The 2.8 KW photovoltaic solar panels are installed on a steel roof. The panels and roof are 2 years old.

The solar panels still have two years to go on the state tax credit, which means the new owner can get a state tax reduction of $1500 per year for 2014 and 2015.

The solar panels are making about 1200 watts right now. Since installation 2 years ago we have generated over 7 megawatts. Our summer bill is the minimum, $10.26 and in the dark of winter it’s about $50. Basically we make all our own electricity.


We put speakers into the ceiling in two rooms and wired them to the living room, 4 rooms total are wired for speakers.

It has the usual tv cable installed but also has gigabit ethernet wiring installed. There is an infrastructure cabinet in the hall closet to contain a Comcast compatible modem, an ethernet switch, and I keep a WiFi access point in there.

Today we are moving stuff into a PODS shipping container that’s waiting for me in the driveway right now!

Brian Wilson brian @, Julie Skopal  julie @ 541-368-7383