====== Raspberry Pi Peripherals ====== {| style="" ! Device !! Conn. / Type !! Interface |- | [[#Temp. Sensor DS18B20]] || Chip || [[#1 Wire Interface]] |- | [[#MCP3008 10 Bit ADC]] || Chip || [[#SPI Interface]] |- | [[#Waveshare 1.8" LCD Using ST7735 Controller]] || Chip || [[#SPI Interface]] |- | Ultraschall-Abstandssensor || 4-pol. || GPIO |- | Relais 1x 250V / 10 A || Grove 4-pol. || ??? |- | Relais 2x 250V / 10 A || 4-pol. || GPIO |- | Temperature & Humidity || Grove 4-pol. || ??? |- | Bodenfeuchtigkeit / Moisture || Grove 4-pol. || Analog |} ===== 1 Wire Interface ===== * RaspBian Stretch: Enable Interface by running ''sudo raspi-config'' * Module ''w1_gpio'' is loaded automatically * Some other modules are loaded automatically if a well-known device is detected * **GPIO4** / Pin 7 is used for 1 wire data ==== Temp. Sensor DS18B20 ==== * 3.3 V operation * Module ''w1_therm'' is loaded automatically if a **DS18B20** compatible device is detected * Detected devices are listed below **''/sys/bus/w1/devices/''** * For each DS18B20 compatible device a link to a subdirectory is created with name ''28-*'', e.g. ''28-03177144feff'' * The device subdirectory contains a text file ''w1_slave'' that returns the data read when the file is read $ cat 28-0000092bd91e/w1_slave 58 01 4b 46 7f ff 08 10 f9 : crc=f9 YES 58 01 4b 46 7f ff 08 10 f9 t=21500 where ''crc=.. YES'' incicates that the data CRC is OK, and ''t='' is the temperature in 1/1000 °C **Links:** * Jürgen Plate: Raspberry Pi: 1-Wire Temperatursensor DS1820\\ [[http://www.netzmafia.de/skripten/hardware/RasPi/Projekt-Onewire/index.html]] ===== SPI Interface ===== * **''MOSI''**: Master Out Slave In (data output from master) * **''MISO''**: Master Master In Slave Out (data output from slave) ==== MCP3008 10 Bit ADC ==== * 2.7V - 5.5V operation * Connect to SPI0 with CS0 --> SPI0.0 * Edit ''/boot/config.txt'' and add line ''dtoverlay=mcp3008:spi0-0-present''.\\ This loads module ''mcp320x'', which also supports the MCP3008. * Once the module is loaded the device appears under ''/sys/bus/iio/devices/iio\:'' * Read channel 0: ''cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw'' **Links:** * Using MCP3008 ADCs with Raspberry Pis\\ [[http://www.jumpnowtek.com/rpi/Using-mcp3008-ADCs-with-Raspberry-Pis.html]] * Interfacing an SPI ADC (MCP3008) chip to the Raspberry Pi using C++ (spidev)\\ [[http://hertaville.com/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c.html]] ==== Waveshare 1.8" LCD Using ST7735 Controller ==== {| style="" ! Pin !! Raspi GPIO !! Signal !! Cable Color |- | VCC || +3.3 V || Power Supply || violet |- | GND || GND || Ground || white |- | DIN || MOSI || || green |- | CLK || SCLK || || orange |- | CS || SPI0 CS0 || || yellow |- | DC || GPIO24 || Command / Data || blue |- | RST || GPIO25 || Reset || black |- | BL || +5V? || || red |} sudo modinfo fbtft_device # list module parameters sudo modprobe fbtft_device name=sainsmart18 busnum=1 # Use SPI0 CS1 instead of SPI0 CS0 sudo modprobe fbtft_device name=sainsmart18 speed=16000000 sudo modprobe fbtft_device name=sainsmart18 speed=16000000 rotate=270 **Links:** * ST7735 + Raspberry Pi (framebuffer) (Video)\\ https://www.youtube.com/watch?v=AbCuPrYhETw ---- --- //Martin Burnicki [[martin.burnicki@burnicki.net]] 2018-02-11//