Documentation ¶
Overview ¶
Package dev ...
Connect to Pi:
- vcc: any 3.3v pin
- gnd: any gnd pin
- out: any data pin
Package dev ...
Connect to Pi:
- vcc: any v3.3 pin
- gnd: and gnd pin
- i/o: any data pin
Package dev ...
Connect to Pi:
- vcc: any 3.3v or v5 pin
- gnd: any gnd pin
- out: any data pin
Package dev ...
DHT11 is an sensor for getting temperature and humidity. config:
- sudo vim /boot/config.txt
- add following line to the end of config.txt -------------------------- dtoverlay=dht11,gpiopin=4 --------------------------
- connect dht11 to raspberry pi: SIGNAL: must connect to pin 7(gpio 4) GND: any gnd pin VCC: any 3.3v pin
-----------------------------------------------------------------------
+-------------+ | | | DHT11 | | | +-+----+----+-+ | | | S | VCC | - | | | | | | +-----------+ | +----|--------------+ * 1 2 o | | | | * 3 o | | | | o o | +---------|--------------+ * 7 o | +--------------+ * 9 o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o 39 40 o | +-----------+
-----------------------------------------------------------------------
Package dev ... DS18B20 is a tempeture sensor.
Config Your Pi:
- $ sudo vim /boot/config.txt
- add following line at the end of the file ~~~~~~~~~~~~~~~~~~~~~~~~~~~ dtoverlay=w1-gpio,gpiopin=4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
- $ sudo reboot now
- check: $ cat /sys/bus/w1/devices/28-d8baf71d64ff/w1_slave should saw: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ca 01 55 00 7f ff 0c 10 bf : crc=bf YES ca 01 55 00 7f ff 0c 10 bf t=28625 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connect to Pi:
- vcc: any 3.3v pin
- gnd: any gnd pin
- dat: must connect to pin 7(gpio 4)
Package dev ...
Connect to Pi:
- vcc: any 3.3v or v5 pin
- gnd: any gnd pin
- out: any data pin
Package dev ...
GPS is the driver of NEO-M6 module.
Config Your Pi:
- $ sudo raspi-config -> [P5 interface] -> P6 Serial: disable -> [no] -> [yes]
- $ sudo vim /boot/config.txt add following two lines: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enable_uart=1 dtoverlay=pi3-miniuart-bt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- $ sudo reboot now
- $ sudo cat /dev/ttyAMA0 should see somethings output
Connect NEO-6M GPS Sensor to Raspberry Pi:
- VCC: any 5v pin
- GND: any gnd pin
- RXT: must connect to pin 8(gpio 14) (TXD)
- TXD: must connect to pin 10(gpio 15) (RXD)
-----------------------------------------------------------------------
+-----------------+ | GPS | | NEO-M6 | | | +--+---+---+---+--+ | | | | GND TXD RXD VCC +-----------+ | | | | | o 1 2 * +---------|---|---|---+ | o o | | | | | 8 6 * +---------+ | | | o 8 * |-------------|---+ | o 10 * +-------------+ | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o 39 40 o | +-----------+
-----------------------------------------------------------------------
Package dev ...
HC-SR04 is an ultrasonic distance meter which can measure the distance to the an object like a box.
Spec:
- power supply: +5V DC
- range: 2 - 450cm
- resolution: 0.3cm ___________________________ | | | HC-SR04 | | | |___________________________| | | | | vcc trig echo gnd
Connect to Pi:
- vcc: any 5v pin
- trig: any data pin for triggering(input)
- echo: any data pin for echoing(output)
- gnd: any gnd pin
Package dev ...
Connect to Pi:
- vcc: any 3.3v pin
- gnd: any gnd pin
- out: any data pin
Package dev ...
L298N is an motor driver which can be used to control the direction and speed of DC motors.
Spec:
_________________________________________ | | | | OUT1 -| L298N |- OUT3 OUT2 -| |- OUT4 | | |_________________________________________| | | | | | | | | | 12v GND 5V EN1 IN1 IN2 IN3 IN4 EN2
Pins:
OUT1: dc motor A+
OUT2: dc motor A-
OUT3: dc motor B+
OUT4: dc motor B-
IN1: input 1 for motor A
IN2: input 2 for motor A
IN3: input 3 for motor B
IN4: input 1 for motor B
EN1: enable pin for motor A
EN2: enable pin for motor B
Package dev ...
LC12S is wireless transceiver module. https://world.taobao.com/item/594554513623.htm
Config Your Pi:
- $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
- $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
- $ sudo reboot now
- $ sudo cat /dev/ttyAMA0 should see somethings output
Connect to Pi:
- VCC: any 3.3v
- GND: any gnd pin
- CS: any data pin. high-level: sleep, low-level: work
- TX: must connect to pin 10(gpio 15) (RXD)
- RX: must connect to pin 8(gpio 14) (TXD)
Package dev ...
Connect to Pi:
- positive(the longer pin): any data pin
- negative(she shorter pin): any gnd pin
Package dev ...
LedDisplay let you display text on an led digital module which bases on the 74HC595 dirver. Please note that I only test it on a 4-bit led digital module. Andy Only following chars were supported. The any char which didn't be spported will be displayed as '-'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0 1 2 3 4 5 6 7 8 9 A B C D E F H I J L O P R S U Y Z a b c d h i j l o p q s t u y . - _ = (and blank char ' ') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connect to Pi:
- VCC: any v3.3 pin
- GND: any gnd pin
- DIO: any data pin
- SCLK: any data pin
- RCLK: any data pin
Package dev ...
mpu6050 is the driver of mpu6050 module.
connect to raspberry pi: VCC: pin 1 or any 3.3v pin GND: pin 9 or and GND pin SDA: pin 3 (SDA) SCL: pin 5 (SCL)
Config Your Pi:
- $ sudo apt-get install -y python-smbus
- $ sudo apt-get install -y i2c-tools
- $ sudo raspi-config
- -> [5 interface options] -> [p5 i2c] ->[yes] -> [ok]
- $ sudo reboot now
- check: $ sudo i2cdetect -y 1 it works if you saw following message: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Package dev ...
OLED is the driver of an oled screen. Please NOTE that current version only supports the oled module with ssd1306 driver.
connect to raspberry pi: VCC: pin 1 or any 3.3v pin GND: pin 9 or and GND pin SDA: pin 3 (SDA) SCL: pin 5 (SCL)
+--------------------+ | OLED | | | +--+----+----+----+--+ | | | | GND VCC SCL SDA | | | | | | | | | | | | +-----------+ | +----|----|------------+ * 1 2 o | | | +------------| * 3 o | | +-----------------+ * 5 o | | | o o | +---------------------------+ * 9 o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o o | | o 39 40 o | +-----------+
Config Your Pi:
- $ sudo apt-get install -y python-smbus
- $ sudo apt-get install -y i2c-tools
- $ sudo raspi-config
- -> [5 interface options] -> [p5 i2c] ->[yes] -> [ok]
- $ sudo reboot now
- check: $ sudo i2cdetect -y 1 it works if you saw following message: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Package dev ...
PCF8591 is the driver of PCF8591 module.
connect to raspberry pi: - VCC: pin 1 or any 3.3v pin - GND: pin 9 or and GND pin - SDA: pin 3 (SDA) - SCL: pin 5 (SCL)
Jumper: - remove jumpers on P4 & P5, keep the jumper on P6
Config Your Pi:
- $ sudo apt-get install -y python-smbus
- $ sudo apt-get install -y i2c-tools
- $ sudo raspi-config
- -> [5 interface options] -> [p5 i2c] ->[yes] -> [ok]
- $ sudo reboot now
- check: $ sudo i2cdetect -y 1 it works if you saw following message: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Package dev ...
PMS7003 is the driver of PMS7003, an air quality sensor which can be used to detect PM2.5 and PM10.
Config Your Pi:
- $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
- $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
- $ sudo reboot now
- $ sudo cat /dev/ttyAMA0 should see somethings output
Connect to Pi:
- VCC: any 5v pin
- GND: any gnd pin
- TXD: must connect to pin 10(gpio 15) (RXD)
- RXT: must connect to pin 8(gpio 14) (TXD)
Package dev ...
Connect to Pi:
- vcc: any 5v pin
- gnd: any gnd pin
- in: pin 26(gpio 7) or any data pin
- on: the outside device
- com: the bettery
Package dev ...
Connect to Pi:
- +v: any v3.3 or 5v pin
- gnd: any gnd pin
- d0: any data pin
- d1: any data pin
- d2: any data pin
- d3: any data pin
- vt: null
Package dev ... SG90 is the driver of servo motor
Connect to Pi:
- the red line: any 5v pin
- the brown line: any gnd pin
- the yellow line: any pwn pin(must be one of gpio 12, 13, 18, 19)
Package dev ...
Connect to Pi:
- vcc: any 5v pin
- gnd: any gnd pin
- in1: any data pin
- in2: any data pin
- in3: any data pin
- in4: any data pin
Package dev ...
SW-420 is an sensor which is able to detect shaking.
Connect to Pi:
- vcc: any 3.3v pin
- gnd: any gnd pin
- do : any data pin
Package dev ...
US-100 is an ultrasonic distance meter, which can measure the distance to the an object like a box. US-100 works in both modes of UART and Electrical Level. This program uses UART mode to drive the module.
Config Your Pi:
- $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
- $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
- $ sudo reboot now
- $ sudo cat /dev/ttyAMA0 should see somethings output
Connect to Pi:
- VCC: any 3.3v or 5v pin
- GND: any gnd pin
- ...............................................
- !!! NOTE: TX->TXD, RX-RXD, NOT TX->RXD, RX-TXD
- ...............................................
- Trig/TX: must connect to pin 8(gpio 14) (TXD)
- Echo/RX: must connect to pin 10(gpio 15) (RXD)
Package dev ...
ZE08CH2O is the driver of ZE08CH2O, an air quality sensor which can be used to detect PM2.5 and PM10.
Config Your Pi:
- $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
- $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
- $ sudo reboot now
- $ sudo cat /dev/ttyAMA0 should see somethings output
Connect to Pi:
- VCC: any 5v pin
- GND: any gnd pin
- TXD: must connect to pin 10(gpio 15) (RXD)
Index ¶
- type Button
- type Buzzer
- type Camera
- type Car
- type CarOp
- type CollisionSwitch
- type DHT11
- type DS18B20
- type Encoder
- type GPS
- type GPSLogger
- type HCSR04
- type Infrared
- type Joystick
- type L298N
- type LC12S
- type Led
- type LedDisplay
- type MPU6050
- type OLED
- type Option
- func WithCSwitchs(cswitchs []*CollisionSwitch) Option
- func WithCamera(cam *Camera) Option
- func WithEncoder(e *Encoder) Option
- func WithEngine(engine *L298N) Option
- func WithHorn(horn *Buzzer) Option
- func WithLed(led *Led) Option
- func WithLight(light *Led) Option
- func WithServo(servo *SG90) Option
- func WithUlt(ult *US100) Option
- type PCF8591
- type PMS7003
- type RX480E4
- type Relay
- type SG90
- type SW420
- type StepMotor
- type US100
- type VoiceDetector
- type ZE08CH2O
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buzzer ¶
type Buzzer struct {
// contains filtered or unexported fields
}
Buzzer ...
type Camera ¶
type Camera struct { }
Camera ...
func (*Camera) TakePhoto ¶
TakePhoto take a photo using motion service. in default, the created photo file will be in folder: /var/lib/motion you can change the directory in the config of motion. the config file is in /etc/motion/motion.conf and you need to change the 'snapshot_filename' to 'lastsnap.jpg' after changing, this will be look like: ----------------------------------------- target_dir /var/lib/motion snapshot_filename lastsnap.jpg -----------------------------------------
type Car ¶
type Car struct {
// contains filtered or unexported fields
}
Car ...
type CollisionSwitch ¶
type CollisionSwitch struct {
// contains filtered or unexported fields
}
CollisionSwitch ...
func NewCollisionSwitch ¶
func NewCollisionSwitch(pin uint8) *CollisionSwitch
NewCollisionSwitch ...
type DS18B20 ¶
type DS18B20 struct { }
DS18B20 ...
func (*DS18B20) GetTemperature ¶
GetTemperature ... temperature file: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ca 01 55 00 7f ff 0c 10 bf : crc=bf YES ca 01 55 00 7f ff 0c 10 bf t=28625 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^~~~~~~~~
type Joystick ¶
type Joystick struct {
// contains filtered or unexported fields
}
Joystick ...
type Led ¶
type Led struct {
// contains filtered or unexported fields
}
Led ...
type LedDisplay ¶
type LedDisplay struct {
// contains filtered or unexported fields
}
LedDisplay ...
func NewLedDisplay ¶
func NewLedDisplay(dioPin, rclkPin, sclkPin uint8) *LedDisplay
NewLedDisplay ...
type OLED ¶
type OLED struct {
// contains filtered or unexported fields
}
OLED ...
type PMS7003 ¶
type PMS7003 struct {
// contains filtered or unexported fields
}
PMS7003 ...
type SW420 ¶
type SW420 struct {
// contains filtered or unexported fields
}
SW420 ...
func (*SW420) KeepShaking ¶
KeepShaking returns true if the sensor detects the object keeps shaking in 100 millisecond, or returns false
type VoiceDetector ¶
type VoiceDetector struct {
// contains filtered or unexported fields
}
VoiceDetector ...
Source Files ¶
- button.go
- buzzer.go
- camera.go
- car.go
- collisionswitch.go
- dht11.go
- ds18b20.go
- encoder.go
- gps.go
- gpslogger.go
- hcsr04.go
- infrared.go
- joystick.go
- l298n.go
- lc12s.go
- led.go
- leddisplay.go
- mpu6050.go
- oled.go
- pcf8591.go
- pms7003.go
- relay.go
- rx480e4.go
- sg90.go
- stepmotor.go
- sw420.go
- us100.go
- voice.go
- ze08ch2o.go