This will be a pretty long entry, but I'd like to get this blog post out. I think it is really cool and I am hoping that other people think so too.
On my previous blog I have documented how I was trying to read the temperature in my office using a TMP36 sensor and a MCP3008 A/D converter with no success. But after posting my problem to the Java Embedded OTN Forum I got some really good help from a colleague and now I think I got it working properly (what's missing is that I need to bring in a regular thermometer to verify my results).
The first thing I learned was that there is a problem with the current SPI implementation on the Raspberry Pi, so I needed to move the MCP3008 CS to GPIO18 (instead of GPIO8 which is the CE in the documentation) and then control the CS manually.
Secondly I needed to decrease the clock frequency and change the mode of the SPI interface. I am not 100% sure why I need to do this (read: I am no HW expert but I am trying to read up why I needed to do this).
So now is the system wired up like this:
- MCP3008 VDD --> 3.3V
- MCP3008 VREF --> 3.3V
- MCP3008 AGND --> GND
- MCP3008 CLK --> SCLK (GPIO11)
- MCP3008 DOUT --> MISO (GPIO9)
- MCP3008 DIN --> MOSI (GPIO10)
- MCP3008 CS --> CE0 (GPIO18)
- MCP3008 DGND --> GND
The TMP36 sensor is very easy to wire up, with the flat side upwards:
- Pin 1: 2.7-5.5V In -> 3.3V
- Pin 2: Analog Voltage Out -> CH0 on MCP3008
- Pin 3: Ground -> GND
That's all for now folks, next post will give you the source code for this little but extremely cool project.
<<Andy>>