Make a DIY Sensor of Your Choice and Display the Measurement on Your Android Phone Via Bluetooth
by Practical Techonlogy in Circuits > Sensors
12822 Views, 65 Favorites, 0 Comments
Make a DIY Sensor of Your Choice and Display the Measurement on Your Android Phone Via Bluetooth
Do you need a sensor to measure something, such as body temperature, outside temperature, UV radiation, light intensity, solar irradiance, magnetic field, pressure, etc. etc. ? With today's technology, it becomes very easy to make a sensor and display it on your cell phone with Bluetooth. I would like to show you here the basics of building such a device that allows you to plug in various sensors of your choice. All the components are readily available off the shelf (or off the web). The total cost is less than $20. Figure 1 shows such a device I built that can be either used as a sunphotometer or a UV sensor. Figure 2 shows the Android App that I built to display the calibrated measurements on my Samsung cell phone.
Design Your Sensor
Figure 2 shows the basic diagram of the sensor device I built. It is very simple, in the case of a sunphotometer, you can simply use a LED to detect the sunlight, which will generate about 1 V to be sent to the Attiny45. The voltage signal is proportional to the sunlight intensity and is converted to a digital number by the ADC converter inside the Attiny45. The digital number is then sent out through Tx to the Bluetooth module. The Bluetooth is connected to my Android phone and the App "Sensor View" (available from https://play.google.com/store/apps/details?id=com.chavatech.chavasensor) takes the data, converts it to physical quantity using a calibration equation. Then it displays the measurement on the cellphone screen dynamically. In my case, I didn't even need to use any amplifier but that certainly is an option for weak detectors before sending the signal to the Attiny45.
Getting the Parts for Your Sensor
Here is the list of the minnimum number of parts needed:
1. Detector: for a sunphotometer ($0.5), you can simply use a green LED which measures the solar intensity at about 0.5um. You can also get a UVA sensor for about $5 which is what I got from some web site. I also tested the device using thermisters which are pretty cheap for measuring body temperatures. The sensor choice is only limited by your imagination and price.
2. Microcontroller ($1): I choose Attiny45 because it is cheap, small, and does the job. It has ADC channels. It lacks a serial interface but I was able to manage to do it with software implementation so it can send data to the Bluetooth. I can make the .hex file available for those who are interested.
3. Voltage regulator ($0.5): I choose 78L33 which provides 3.3v for the Bluetooth module and the Attiny45 is also happy.
4. Battery: Any battery with voltage above 5v should be ok but I choose a 9V common type for easy handling.
5. Breadboard ($8) or PCB ($4): Initially you probably want to use a breadboard to save you a lot of headaches from soldering etc. A small PCB works fine of course if you are good as soldering. Both are RadioShack parts.
6. A plastic box: I choose a plastic light switch box from Homedepot for about one dollar.
7. Bluetooth module: I choose HC-06 or HC-07, which costs about $8 each at dealextreme.
7. The android App "Sensor View" which costs $0.99.
8. Some wire (Free): I just use the old phone wire. Who need the analog phone now a days.
So the total cost is about $16. Of course your actual cost will vary depending on what you choose.
Now plug everything into your breadboard and it's ready.
1. Detector: for a sunphotometer ($0.5), you can simply use a green LED which measures the solar intensity at about 0.5um. You can also get a UVA sensor for about $5 which is what I got from some web site. I also tested the device using thermisters which are pretty cheap for measuring body temperatures. The sensor choice is only limited by your imagination and price.
2. Microcontroller ($1): I choose Attiny45 because it is cheap, small, and does the job. It has ADC channels. It lacks a serial interface but I was able to manage to do it with software implementation so it can send data to the Bluetooth. I can make the .hex file available for those who are interested.
3. Voltage regulator ($0.5): I choose 78L33 which provides 3.3v for the Bluetooth module and the Attiny45 is also happy.
4. Battery: Any battery with voltage above 5v should be ok but I choose a 9V common type for easy handling.
5. Breadboard ($8) or PCB ($4): Initially you probably want to use a breadboard to save you a lot of headaches from soldering etc. A small PCB works fine of course if you are good as soldering. Both are RadioShack parts.
6. A plastic box: I choose a plastic light switch box from Homedepot for about one dollar.
7. Bluetooth module: I choose HC-06 or HC-07, which costs about $8 each at dealextreme.
7. The android App "Sensor View" which costs $0.99.
8. Some wire (Free): I just use the old phone wire. Who need the analog phone now a days.
So the total cost is about $16. Of course your actual cost will vary depending on what you choose.
Now plug everything into your breadboard and it's ready.
Connecting Your Cell Phone to the Sensor.
You need to install "Sensor View" App from the play.google.com/store.
After installation, you start the App and need to configure it as follows:
1) Press the menu button on your android phone (button on the left side) to go to the "Settings". There you can input the calibration coefficients to convert the digital numbers it receives from the sensor to physical units. The calibration uses the following equation:
Y = offset slope* X Quadratic*X^2
Where Y is the physical quantity to be displayed; X is the digital number received from the sensor; Offset, slope, and Quadratic are the coefficients that you need to either estimate or determine based on a calibration. For example, for temperature, you can calibrate it against your body temperature. When you set offset and quadratic to zeros, and slope to 1, you can see what the sensor is producing (as a 16 bit digital number).
After entering these coefficients, you hit return to go back to the display screen.
2) Bluetooth connection: inside the "Sensor View" App, you click the bluetooth connection icon on the top, find the bluetooth module by its ID or name and connect to it. After it's connected. You should start seeing numbers displayed on the screen. The measurements are updated every half a second.
Enjoy!
After installation, you start the App and need to configure it as follows:
1) Press the menu button on your android phone (button on the left side) to go to the "Settings". There you can input the calibration coefficients to convert the digital numbers it receives from the sensor to physical units. The calibration uses the following equation:
Y = offset slope* X Quadratic*X^2
Where Y is the physical quantity to be displayed; X is the digital number received from the sensor; Offset, slope, and Quadratic are the coefficients that you need to either estimate or determine based on a calibration. For example, for temperature, you can calibrate it against your body temperature. When you set offset and quadratic to zeros, and slope to 1, you can see what the sensor is producing (as a 16 bit digital number).
After entering these coefficients, you hit return to go back to the display screen.
2) Bluetooth connection: inside the "Sensor View" App, you click the bluetooth connection icon on the top, find the bluetooth module by its ID or name and connect to it. After it's connected. You should start seeing numbers displayed on the screen. The measurements are updated every half a second.
Enjoy!