You can download this script directly to your Pi using : wget Print("Light: deg C".format(temp_level,temp_volts,temp)) Light_volts = ConvertVolts(light_level,2) # rounded to specified number of decimal places. # Function to convert data to voltage level, # Function to read SPI data from MCP3008 chip To read the data I used this Python script : Our 0-3.3V range would equate to a temperature range of -50 to 280 degrees C using the TMP36. A reading of 0 means the input is 0V and a reading of 1023 means the input is 3.3V. The ADC is 10bit so it can report a range of numbers from 0 to 1023 (2 to the power of 10). So 0 degrees will give 0.5V and 100 degrees will give 1.5V. Each degree results in 10mV of output voltage. You can power it with 3.3V and the middle Vout pin will provide a voltage proportional to the temperature.Ī temperature of 25 degrees C will result in an output of 0.750V. The TMP36 temperature sensor is a 3 pin device ( datasheet). When it is dark the LDR resistance increases resulting in the output voltage increasing towards 3.3V. When there is lots of light the LDR has a low resistance resulting in the output voltage dropping towards 0V. Under normal lighting its resistance is approximately 10Kohm while in the dark this increases to over 2Mohm. I chose a nice chunky LDR (NORPS-12, datasheet). Here is a photo of my test circuit on a small piece of breadboard : It uses CH0 for the light sensor and CH1 for the TMP36 temperature sensor. The CH0-CH7 pins are the 8 analogue inputs. It requires 4 GPIO pins on the Pi P1 Header. The following list shows how the MCP3008 can be connected. Please follow my Enabling The SPI Interface On The Raspberry Pi article to setup SPI and install the SPI Python wrapper. The first step is enabling the SPI interface on the Pi which is usually disabled by default. In the example circuit below I use my MCP3008 to read a temperature and light sensor. This article explains how to use an MCP3008 device to provide 8 analogue inputs which you can use with a range of sensors. It uses the SPI bus protocol which is supported by the Pi’s GPIO header. It is cheap, easy to connect and doesn’t require any additional components. The MCP3008 is a 10bit 8-channel Analogue-to-digital converter (ADC). I wanted to update my garage security system with the ability to use more sensors so I decided to investigate an easy and cheap way to do it. I can't tell if this an artefact of the way the decimal computation is done by the computer, or if it the result of some theorem about the convergence of this series.The Raspberry Pi has no built in analogue inputs which means it is a bit of a pain to use many of the available sensors. (I haven't tested enough values of n to deduce much more about this though) Furthermore, it seems that the number of incorrect digits in the first string of incorrect digits increases in some way with the difference between the power of $2$ and the power of $5$. It seems that when n has $2$ and $5$ as its only prime factors, there is a strange collection of correct digits after the first incorrect digit.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |