Electronic kit

July 17, 2016 ยท View on GitHub

I bought this kit: https://www.amazon.co.jp/gp/product/B00MRQ5U1Y/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

##Parts

mcp3008_4

mcp9700_2

cds_and_register

sg90

I have installed pi-blaster to enable PWM on my Raspberry Pi 3.

I modified the constant in "pi-blaster.c" to adjust PWM frequency to 50Hz:

- #define CYCLE_TIME_US   10000
+ #define CYCLE_TIME_US   20000
  #define SAMPLE_US               10
  #define NUM_SAMPLES             (CYCLE_TIME_US/SAMPLE_US)
  #define NUM_CBS                 (NUM_SAMPLES*2)

I connected my servo motor (SG90) to GPIO21, 5V and GND, then I tested that the motor rotates its arm from -90 degree to +90 degree:

$ sudo ./pi-blaster -g 21
$ sudo echo "21=0.025" > /dev/pi-blaster
$ sudo echo "21=0.125" > /dev/pi-blaster

Temperature calculation

####MCP9700 DC electrical characteristics mcp9700_1

####MCP3008 digital output code calculation mcp3008_1

####Temperature calculation equation

##Luminousity calculation

cds

##Communicating with MCP3008 via SPI

Control bit: 1000

mcp3008_2

Send [0x01, 0x80, 0x00] from your Raspberry Pi to MCP3008 via SPI. MCP3008 returns 10bit data (value range: 0 - 1023).

mcp3008_3

##Code I made this code to obtain the output from MCP3008(CH0 and CH1) and calcuate the temperature and luminousity.

##Wirling

PinNameDirectionPart
9GND
173.3V
19SPI0 MOSIAD converter
21SPI0 MISOAD converter
23SPI0 SCLKAD converter
24SPI0 CS0AD converter
29GPIO5outLED green
31GPIO6outLED red
33GPIO13outpiezo buzzer
35GPIO19intactile switch

Note: one analog thermistor and one CdS are connected to the AD converter.