P1   P2   P3

This is an interesting project to show the effect of a "Robot Invasion."
Each "Talk To Me" can listen and emit a tone. The object of the concept is to have a number of these in a room and see what happens.
In this project, the piezo diaphragm is used as both a transmitter, to send out a beep, as well as a detecting medium, to listen for sounds.
The process starts by one of the "Talk To Me's" sending out a beep. The other "Talk To Me" will hear the beep and reply. The duration between the talk and reply decreases each time a response is made and eventually the beeps will become chatter.
The more "Talk To Me's" you have in a room, the more beeping will take place. It will be interesting to see what happens.
Of course, you can use the project as a "whistle detector" for your keys, but that would destroy the concept of the project.



The amplifier for the piezo needs to have a very high gain as the output from the piezo is very low.
The circuit we have designed is an AC coupled amplifier with the output sitting HIGH. This allows us to generate a waveform equal to almost full rail voltage and this is ideal for the input of a microcontroller.
The first transistor is self-biased and sits at approximately half-rail voltage.
The output of the piezo is about 5mV and the first stage produces a waveform of about 200mV when no other components are connected.
When the 22n capacitor is connected, the waveform drops to about 100mV p-p, but this is sufficient to drive the second stage into full conduction.
The second transistor is biased at the point where it is just-turned-off and any waveform from the first stage will turn it on and produce a waveform that travels towards the 0v rail. In other words it is negative-going.
The end result is a 5,000mV output from the circuit for a 5mV input from the piezo and this is equivalent to a gain of 1,000. The first stage has a gain of approx 20 and the second stage has a gain of about 50. This is the maximum gain you can obtain from2 transistors.
The low gain of the first stage is mainly due to the energy taken from it to drive the second stage, via the 22n capacitor.
This is a special type of circuit called a DIGITAL CIRCUIT as it converts an analogue waveform from the piezo into a signal that is suitable for detection by a microcontroller.
If you connected an audio amplifier to the output it would be very distorted and thus is it not suited for audio amplification.
The circuit is simple but it took a lot of experimenting to come up with the design as all other combinations have to be tried to determine which is the most suitable. This is the only design that gives rail-to-rail output.
Because the output transistor is not self-biased, the circuit is voltage sensitive in that the rail voltage needs to be a maximum of 5v-5.5v for the circuit to work. If the rail voltage is over 7v, the output transistor becomes biased "ON" in the quiescent mode. If the rail voltage is lower than 5v, the biasing of the second transistor will be less and it will require a larger signal to create an output signal.
The circuit also relies on the sensitivity of the piezo diaphragm. The size of the diaphragm has an effect on the output waveform as well as the quality of the substrate coating the diaphragm.
The diaphragm for the prototype was taken from a "whistle-key-finder" that detects when you whistle and sends out a beep to let you know where your keys are located. 

Piezo Amplifier

The input and output waveforms are not to scale and not in the correct phase. They are intended to show a 5mV waveform will turn on the output transistor FULLY.
The first transistor is self-biased and the collector will be at approx half-rail voltage. This voltage is due to the value of the collector-load resistor and 2M2 base-bias resistor. It is also due to the gain of the transistor.
The piezo diaphragm is effectively a 22n capacitor and plays no part in the biasing of the transistor.
Without using any mathematics, the 47k is added and then a base resistor is added. You will need a high-impedance multimeter to measure the collector voltage. One clever way to measure the collector voltage is to measure the voltage between the collector and 0v, and then the voltage between the collector and top rail.  The voltage mid-way between these readings will be the exact voltage.
Next, if the collector voltage is too low, increase the base-bias resistor. When the collector is at mid-rail, the transistor will provide the greatest amplification.
Now we come to the output transistor. The two base resistors are in the ratio 10:1 and thus the 5v is divided by 11. The base will see 0.45v

You can create a program in the chip to detect the LOW and by counting the number of LOW's over a short period of time, you can determine the frequency.
If the frequency falls within a certain range, you can conclude the waveform is a whistle or a beep from another project, etc.