In my first blog post relating to using a Spark Core, I was controlling LEDs from my phone over the Internet, essentially using the cloud to control lights. It still boggles my mind to think that something I built (hardware! from a software guy!) could attach itself to WiFi, and allow itself to be remotely (and securely!) controlled from a handheld device. Fantastic!
In my slow and steady quest to determine how I can use Spark Cores to take over the world and become a James Bond Supervillain, my next step was to figure out how to rig up an analog sensor, as shown in the picture below:
I used the temperature sensor that comes in the Spark “maker kit”, which is basically a Spark Core (the Photons ship next month) in a box along with a pile of sensors, jumper wires, resistors, capacitors, and other doo-dads. Following the example that Spark has up on their website, I rigged up the breadboard as follows:
- 3.3* power pin to the left leg of the temp sensor (there’s a 3.3V and a 3.3*V, and Spark’s instructions indicate that 3.3* gives you a cleaner power, but there’s no explanation beyond that. As a software guy, I have no idea what the hell that means, so I remain in lemming mode and do as I am told without question).
- GND to the right leg of the temp sensor
- Analog pin A7 to the middle leg of the sensor.
So I rigged all this up, flipped the switch, and much to my surprise, I got a temperature reading. However, the reading was around 140C, which is actually pretty damn hot. I thought it was something I screwed up, so I wiggled wires, touched the sensor, and burned the living shit out of my finger. So, my reading was accurate. 140C felt about right as I stuck my finger in a tub of butter.
I quickly unplugged the Spark and let the breadboard sit for about 10 minutes to cool down. Once it had cooled, I checked and re-checked the instructions on Spark’s website and compared my work. It all looked good, except the rounded edge of the temp sensor was facing the wrong way. I flipped it around and turned the Spark back on.
No heat. This time, nothing heated up. I checked the temp reading and got 11C. Checked again, got 23C. Checked again and got 12C. I kept checking and I kept getting widely varied readings. But, I wasn’t burning the house down, so that’s a bonus.
From this I can only gather that the temperature sensor has a specific positive and negative leg and I had them reversed. Of course, none of this is labeled on the sensor, nor is it mentioned on the Spark website examples. I’m sure electronics guys know this, but absolute newbs like myself are likely to catch themselves on fire if people don’t mention these crucially important details. It’s also pretty damn annoying if the sensor can only accept positive in one place and that place isn’t labeled.
So now, with my temp sensor no longer dangerous, I followed Spark’s instructions and added a .01u capacitor to the breadboard rail between pin A7 and ground. They say that this stabilizes the erratic or “noisy” readings from the temperature sensor. However, they don’t tell me why this works, or why this sensor might need it and others won’t, or why a .01u capacitor works but a .1u capacitor will cause the sensor not to provide any data at all. This crap infuriates me! I need to know how crap works and why it works, not just that it works. I question everything, and dislike when answers are not readily available.
Now, after correcting the polarity (I couldn’t help but laugh at the irony that I had literally solved a problem by reversing the polarity in classic Star Trek fashion) I was able to query the temperature of my sensor using the cloud.
An Internet thermometer!!! Next step – world domination.