[Home]Pi Config

HomePage | RecentChanges | Preferences | My Website home page

Pi config

setting up

iic

//
/*
comment out i2c in black list in /etc/modprobe.d and reboot 
then run:
sudo modprobe i2c-dev
sudo chmod o+rw /dev/ic*
*/

	int fd;
											// File descrition
	//char *fileName = "/dev/i2c-0";
	// I nneded to change the device
	char *fileName = "/dev/i2c-1";

	// address C6 so 63 is 								// Name of the port we will be using
	int  address = 0x63;										// Address of LCD03 shifted right one bit
	//int  address = 0xC6;										// Address of LCD03 shifted right one bit
	char buf[10];

	if ((fd = open(fileName, O_RDWR)) < 0) {					// Open port for reading and writing
		printf("Failed to open i2c port\n");
                printf(" run: \n");
                printf(" sudo modprobe i2c-dev  \n");
                printf(" sudo chmod o+rw /dev/i2c* \n");
		exit(1);
	}

	if (ioctl(fd, I2C_SLAVE, address) < 0) {					// Set the port options and set the address of the device we wish to speak to
		printf("Unable to get bus access to talk to slave\n");
		exit(1);
	}

	buf[0] = 0;													// Commands to clear the screen
	buf[1] = 12;

	if ((write(fd, buf, 2)) != 2) {								// clear the screen
		printf("Error writing to i2c slave\n");
		exit(1);
	}
	printf("Sending text to LCD03\n");

http://www.dougrice.plus.com/dev/rlcd1.c

GPIO

  http://hertaville.com/2012/11/18/introduction-to-accessing-the-raspberry-pis-gpio-in-c/

==========================================

  http://www.hobbytronics.co.uk/arduino/arduino-lcd-keypad-shield
  http://elinux.org/RPi_BCM2835_GPIOs

  http://pmb.neongrit.net/blog/?p=64 - LCD2x16 page

  http://log.liminastudio.com/writing/tutorials/tutorial-how-to-use-your-raspberry-pi-like-an-arduino

This is a document about driving the GPIO.

  http://quick2wire.com/2012/05/safe-controlled-access-to-gpio-on-the-raspberry-pi/

This is a document about driving the GPIO.

  http://elinux.org/RPi_Low-level_peripherals#GPIO_Driving_Example_.28Bash_shell_script.2C_using_sysfs.2C_part_of_the_raspbian_operating_system.29

sudo -i

  1. sleep 1
echo "0" > /sys/class/gpio/gpio22/value echo "1" > /sys/class/gpio/gpio23/value

sleep 1 echo "1" > /sys/class/gpio/gpio22/value echo "0" > /sys/class/gpio/gpio23/value

sleep 1 echo "0" > /sys/class/gpio/gpio22/value echo "0" > /sys/class/gpio/gpio23/value =========================================================

  1. !/bin/sh

  1. GPIO numbers should be from this list
  2. 0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25

  1. Note that the GPIO numbers that you program here refer to the pins
  2. of the BCM2835 and *not* the numbers on the pin header.
  3. So, if you want to activate GPIO7 on the header you should be
  4. using GPIO4 in this script. Likewise if you want to activate GPIO0
  5. on the header you should be using GPIO17 here.

  1. Set up GPIO 4 and set to output
echo "4" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio4/direction

  1. Set up GPIO 7 and set to input
echo "7" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio7/direction

  1. Write output
echo "1" > /sys/class/gpio/gpio4/value

  1. Read from input
cat /sys/class/gpio/gpio7/value

  1. Clean up
echo "4" > /sys/class/gpio/unexport echo "7" > /sys/class/gpio/unexport

echo "22" > /sys/class/gpio/unexport echo "23" > /sys/class/gpio/unexport echo "24" > /sys/class/gpio/unexport

</pre>

One wire - DS18S20 reader

Used GPIO4 pin 7 - middle pin. 3v3 to power gnd to gnd

		/ 3v3  
+
DS18S20 - top (|- buss --GPIO4--[4k7]--/
	  	\ gnd

http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/hardware http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/hardware http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/ds18b20

sudo modprobe w1-gpio sudo modprobe w1-therm cd /sys/bus/w1/devices ls

cat 10-*/w1*

cd 28-xxxx (change this to match what serial number pops up) cat w1_slave

cat: power: Is a directory cat: subsystem: Is a directory DRIVER=w1_slave_driver W1_FID=10 W1_SLAVE_ID=00000000000000080189EF05 22 00 4b 46 ff ff 0c 10 3f : crc=3f YES 22 00 4b 46 ff ff 0c 10 3f t=17000 pi@raspberrypi /sys/bus/w1/devices/10-00080189ef05 $ cd .. pi@raspberrypi /sys/bus/w1/devices $ ls 10-00080189ef05 10-0008018a44f7 w1_bus_master1 pi@raspberrypi /sys/bus/w1/devices $ cd 10-0008018a44f7 pi@raspberrypi /sys/bus/w1/devices/10-0008018a44f7 $ ls driver id name power subsystem uevent w1_slave pi@raspberrypi /sys/bus/w1/devices/10-0008018a44f7 $ cat * cat: driver: Is a directory </pre>


HomePage | RecentChanges | Preferences | My Website home page
This page is read-only | View other revisions
Last edited April 13, 2015 8:55 pm by dougrice.plus.com
Search: