dev

package
v0.0.0-...-533f13a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 18 Imported by: 66

Documentation

Overview

A4988 is a driver for A4988 driver board used to drive stepper motor such as NAME.

Connect to Pi:

  • vmot: 5v pin of rpi, or 5~35v power supply for motor

  • gnd : any gnd pin of rpi, or the gnd of power supply

  • vcc : any 5v pin

  • gnd : any gnd pin

  • step: any data pin

  • dir : any data pin

  • ms1 : any data pin

  • ms2 : any data pin

  • ms3 : any data pin

    NOTE:

  • This driver didn't implement reset, sleep and enable/disable.

  • You should typing [sleep] to [reset] pin to get the module always doesn't sleep.

  • And get [enable] tying nothing to get module always be enabled.

ADS1015 is a 12-bit analog-digital converter. It is a implement of ADC interface. More details about ADS1015, please ref to: https://www.adafruit.com/product/1083 https://cdn-learn.adafruit.com/downloads/pdf/adafruit-4-channel-adc-breakouts.pdf

Config Raspberry Pi:

  1. $ sudo apt-get install -y python-smbus
  2. $ sudo apt-get install -y i2c-tools
  3. $ sudo raspi-config
  4. -> [5 Interface Options] -> [P5 I2C] -> [yes] -> [ok]
  5. $ sudo reboot now
  6. 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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Connect to Raspberry Pi: - VCC: any 3.3v pin - GND: any GND pin - SDA: GPIO-2 (SDA) - SCL: GPIO-3 (SCL)

Afuiot-B1 is a sensor used to measure the temperature of human or object through infrared ray.

Config Raspberry Pi:

  1. $ sudo raspi-config -> [P5 interface] -> P6 Serial: disable -> [no] -> [yes]
  2. $ sudo vim /boot/config.txt add following two lines: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enable_uart=1 dtoverlay=pi3-miniuart-bt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 3.3v or 5v pin
  • GND: any gnd pin
  • RXT: must connect to GPIO-14/TXD
  • TXD: must connect to GPIO-15/RXD

ButtonImp is a button module used to detect whether a button is pressed.

Connect to Raspberry Pi for a 3-pin buttom mobule:

  • vcc: any 3.3v pin
  • gnd: any gnd pin
  • out: any data pin

Connect to Raspberry Pi for a 2-pin buttom mobule:

  • port-1: any 3.3v pin
  • port-2: any data pin

BYJ2848 is a driver for stepper motor using ULN2003 driver board with 4-phase and 5-wire.

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

CollisionSwitch is used to detect a collision with an object or to detect the limit of travel.

Connect to Raspberry Pi:

  • vcc: any 3.3v or v5 pin
  • gnd: any gnd pin
  • out: any data pin

DHT11 is a sensor used to meature temperature and humidity.

Config Raspberry Pi:

  1. sudo vim /boot/config.txt
  2. add following line to the end of config.txt -------------------------- dtoverlay=dht11,gpiopin=4 --------------------------

Connect to Raspberry Pi:

VCC:	any 3.3v pin
GND:	any gnd pin
SIGNAL: must connect to GPIO-4

TM1637Display is a dirvier for digital led display module drived by TM1637 chip. Please note that I only test it on a 4-bit led digital module. And Only following chars were supported. 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 Raspberry Pi:

  • VCC: any v3.3 pin
  • GND: any gnd pin
  • DIO: any data pin
  • SCLK: any data pin
  • RCLK: any data pin

SSD1306Display is a driver for the oled display module drived by SSD1306 chip. Config Raspberry Pi:

  1. $ sudo apt-get install -y python-smbus
  2. $ sudo apt-get install -y i2c-tools
  3. $ sudo raspi-config
  4. -> [5 Interface Options] -> [P5 I2C] -> [yes] -> [ok]
  5. $ sudo reboot now
  6. 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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Connect to Raspberry Pi:

  • VCC: any 3.3v pin
  • GND: any GND pin
  • SDA: GPIO-2 (SDA)
  • SCL: GPIO-3 (SCL)

DS18B20 is sensor used to meature temperature.

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt
  2. add following line at the end of the file ~~~~~~~~~~~~~~~~~~~~~~~~~~~ dtoverlay=w1-gpio,gpiopin=4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. 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 Raspberry Pi:

  • vcc: any 3.3v pin
  • gnd: any gnd pin
  • dat: must connect to GPIO-4

Encoder is a sensor used to count number.

Connect to Raspberry Pi:

  • vcc: any 3.3v or v5 pin
  • gnd: any gnd pin
  • out: any data pin

Fan is a fan module using 3.3v power source.

Connect to Raspberry Pi:

  • vcc(red line) : any data pin(~3.3v)
  • gnd(black line): any gnd pin

Neo6mGPS is a GPS module used to get locations(lat/lon).

Config Raspberry Pi:

  1. $ sudo raspi-config -> [P5 interface] -> P6 Serial: disable -> [no] -> [yes]
  2. $ sudo vim /boot/config.txt add following two lines: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enable_uart=1 dtoverlay=pi3-miniuart-bt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 3.3v or 5v pin
  • GND: any gnd pin
  • RXT: must connect to GPIO-14/TXD
  • TXD: must connect to GPIO-15/RXD

Neo6mGPS is a GPS module used to get locations(lat/lon).

Config Raspberry Pi:

  1. $ sudo raspi-config -> [P5 interface] -> P6 Serial: disable -> [no] -> [yes]
  2. $ sudo vim /boot/config.txt add following two lines: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enable_uart=1 dtoverlay=pi3-miniuart-bt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 3.3v or 5v pin
  • GND: any gnd pin
  • RXT: must connect to GPIO-14/TXD
  • TXD: must connect to GPIO-15/RXD

GY25 is an accelerometer used to detect yaw, pitch and roll angles.

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
  2. $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 3.3v or 5v pin
  • GND: any gnd pin
  • RXT: must connect to GPIO-14/TXD
  • TXD: must connect to GPIO-15/RXD

HC-SR04 is an ultrasonic distance meter used to measure the distance to objects. min distance: 2cm max distance: 600cm

Spec:

  • power supply: +5V DC
  • range: 2 - 450cm
  • resolution: 0.3cm ___________________________ | | | HC-SR04 | | | |___________________________| | | | | vcc trig echo gnd

Connect to Raspberry Pi:

  • vcc: any 5v pin
  • gnd: any gnd pin
  • trig: any data pin
  • echo: any data pin

HDC1080 is a sensor used to measure temperature and humidity. It is a implement of TempHumidity interface.

Config Raspberry Pi:

  1. $ sudo apt-get install -y python-smbus
  2. $ sudo apt-get install -y i2c-tools
  3. $ sudo raspi-config
  4. -> [5 Interface Options] -> [P5 I2C] -> [yes] -> [ok]
  5. $ sudo reboot now
  6. 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: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Connect to Raspberry Pi: - VCC: any 3.3v pin - GND: any GND pin - SDA: GPIO-2 (SDA) - SCL: GPIO-3 (SCL)

IRCoder is an infrared(IR) encoder and decoder

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
  2. $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 5v pin
  • GND: any gnd pin
  • RXT: must connect to GPIO-14/TXD
  • TXD: must connect to GPIO-15/RXD

IRDetector is a sensor used to detected infrared ray.

Connect to Pi:

  • vcc: any 3.3v pin
  • gnd: any gnd pin
  • out: any data pin

JoystickImp is 2-axis joystick module.

Connect to Pi:

  • +V5: any 5v
  • GND: any gnd pin
  • SM : any data pin
  • Rx: ADS1015->A0
  • Ry: ADS1015->A1

L298N is a motor driver used to control the direction and speed of DC motors.

Spec:

       _________________________________________
      |                                         |
      |                                         |
OUT1 -|                 L298N                   |- OUT3
OUT2 -|                                         |- OUT4
      |                                         |
      |_________________________________________|
          |   |   |     |   |   |   |   |   |
         12v GND  5V   ENA IN1 IN2 IN3 IN4 ENB

Pins:

  • OUT1: dc motor A+

  • OUT2: dc motor A-

  • OUT3: dc motor B+

  • OUT4: dc motor B-

  • 12v: +battery

  • GND: -battery (and any gnd pin of raspberry pi if motors and raspberry pi use different battery sources)

  • IN1: any data pin

  • IN2: any data pin

  • IN3: any data pin

  • IN4: any data pin

  • EN1: must be one of GPIO 12, 13, 18 or 19 (pwn pins)

  • EN2: must be one of GPIO 12, 13, 18 or 19 (pwn pins)

LC12S is wireless transceiver used to send and receive data via electromagnetic wave. More details please ref to: https://world.taobao.com/item/594554513623.htm

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
  2. $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 3.3v
  • GND: any gnd pin
  • CS: any data pin. high-level: sleep, low-level: work
  • RX: must connect to GPIO-14/TXD
  • TX: must connect to GPIO-15/RXD

LD2410 is a sensor used to detected human existing or not.

Connect to Pi:

  • vcc: any 5v pin
  • gnd: any gnd pin
  • out: any data pin

LedImp is led light diodes module.

Connect to Raspberry Pi:

  • vcc(the longer pin) : any data pin(~3.3v)
  • gnd(the shorter pin): any gnd pin

mpu6050 is a 3-axis gyroscope and a 3-axis accelerometer.

Config Your Pi:

  1. $ sudo apt-get install -y python-smbus
  2. $ sudo apt-get install -y i2c-tools
  3. $ sudo raspi-config
  4. -> [5 Interface Options] -> [P5 i2c] -> [yes] -> [ok]
  5. $ sudo reboot now
  6. 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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Connect to Raspberry Pi:

  • VCC: any 3.3v pin
  • GND: any GND pin
  • SDA: GPIO-2 (SDA)
  • SCL: GPIO-3 (SCL)

MQ-7 is a sensor used to detected co gas.

Connect to Pi:

  • vcc: any 3.3v pin
  • gnd: any gnd pin
  • do: any data pin
  • ao: (don't support currently)

PCF8591 is the driver of PCF8591 module.

Jumper: - remove jumpers on P4 & P5, keep the jumper on P6

Config Raspberry Pi:

  1. $ sudo apt-get install -y python-smbus
  2. $ sudo apt-get install -y i2c-tools
  3. $ sudo raspi-config
  4. -> [5 Interface Options] -> [P5 I2C] -> [yes] -> [ok]
  5. $ sudo reboot now
  6. 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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Connect to Raspberry Pi:

  • VCC: any 3.3v pin
  • GND: any GND pin
  • SDA: GPIO-2 (SDA)
  • SCL: GPIO-3 (SCL)

PMS7003 is an air quality sensor which can be used to measure PM2.5 and PM10.

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
  2. $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 5v pin
  • GND: any gnd pin
  • RX: must connect to GPIO-14/TXD
  • TX: must connect to GPIO-15/RXD

PumpImp is a driver for ~3.3v pump motor module.

Connect to Raspberry Pi:

  • vcc(red line) : any data pin(~3.3v)
  • gnd(black line): any gnd pin

relay is an electrically operated switch module.

Connect to Raspberry Pi:

  • vcc: any 5v pin
  • gnd: any gnd pin
  • in: any data pin
  • on: the outside device
  • com: the bettery

RFP-602 is a sensor used to detected pressure.

Connect to Pi:

  • vcc: any 3.3v pin
  • gnd: any gnd pin
  • do: any data pin
  • ao: (don't support currently)

RX480E4 is a transmitter receiver decoding module with 4 channels.

Connect to Raspberry 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

SG90 is servo motor which can roll angels from 0~180 degree.

Connect to Raspberry Pi:

  • the red line: any 5v pin
  • the brown line: any gnd pin
  • the yellow line: must be one of gpio 12, 13, 18 or 19 (pwn pins)

SW-420 is an sensor used to detect shaking.

Connect to Pi:

  • vcc: any 3.3v pin
  • gnd: any gnd pin
  • do : any data pin

US-100 is an ultrasonic distance meter used to measure the distance to objects. US-100 supports both of interfaces: GPIO and UART. min distance: 2cm max distance: 450cm

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
  2. $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi: GPIO Interface:

  • VCC: any 3.3v or 5v pin

  • GND: any gnd pin

  • Trig: any gnd pin

  • Echo: any gnd pin

    UART Interface:

  • VCC: any 3.3v or 5v pin

  • GND: any gnd pin

  • ...............................................

  • !!! NOTE: TX->TXD, RX-RXD, NOT TX->RXD, RX-TXD

  • ...............................................

  • TX: must connect to GPIO-14 (TXD)

  • RX: must connect to GPIO-15 (RXD)

ZE08CH2O is a sensor used to detect CH2O.

Config Raspberry Pi:

  1. $ sudo vim /boot/config.txt add following new line: ~~~~~~~~~~~~~~~~~ enable_uart=1 ~~~~~~~~~~~~~~~~~
  2. $ sudo vim /boot/cmdline.txt remove following contexts: ~~~~~~~~~~~~~~~~~~~~~~~~~~ console=serial0,115200 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 5v pin
  • GND: any gnd pin
  • TXD: must connect to GPIO-15 (RXD)

ZP16 is a gas detect module.

Config Raspberry Pi:

  1. $ sudo raspi-config -> [P5 interface] -> P6 Serial: disable -> [no] -> [yes]
  2. $ sudo vim /boot/config.txt add following two lines: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enable_uart=1 dtoverlay=pi3-miniuart-bt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. $ sudo reboot now
  4. $ sudo cat /dev/ttyAMA0 should see somethings output

Connect to Raspberry Pi:

  • VCC: any 3.3v or 5v pin
  • GND: any gnd pin
  • RXT: must connect to GPIO-14/TXD
  • TXD: must connect to GPIO-15/RXD

Index

Constants

View Source
const (
	// ConversionRegiserPointer ...
	ConversionRegiserPointer byte = 0x00
	// ConfigRegiserPointer ...
	ConfigRegiserPointer byte = 0x01
	//LoThreshRegiserPointer ...
	LoThreshRegiserPointer byte = 0x10
	// HiThreshRegiserPointer ...
	HiThreshRegiserPointer byte = 0x11

	// ComparatorQueueAssertAfterOne Assert after one conversion
	ComparatorQueueAssertAfterOne uint16 = 0x0000
	// ComparatorQueueAssertAfterTwo Assert after two conversions
	ComparatorQueueAssertAfterTwo uint16 = 0x0001
	// ComparatorQueueAssertAfterFour Assert after four conversions
	ComparatorQueueAssertAfterFour uint16 = 0x0002
	// ComparatorQueueDisable Disable comparator and set ALERT/RDY pin to high-impedance (default)
	ComparatorQueueDisable uint16 = 0x0003

	// LatchingComparatorLatching The ALERT/RDY pin does not latch when asserted (default)
	LatchingComparatorLatching uint16 = 0x0000
	// LatchingComparatorNonLatching The asserted ALERT/RDY pin remains latched until
	LatchingComparatorNonLatching uint16 = 0x0004

	// ComparatorPolarityActiveLow This bit controls the polarity of the ALERT/RDY pin (default)
	ComparatorPolarityActiveLow uint16 = 0x0000
	// ComparatorPolarityActiveHigh This bit controls the polarity of the ALERT/RDY pin
	ComparatorPolarityActiveHigh uint16 = 0x0008

	// ComparatorModeTraditional this bit configures the comparator operating mode. (default)
	ComparatorModeTraditional uint16 = 0x0000
	// ComparatorModeWindow this bit configures the comparator operating mode.
	ComparatorModeWindow uint16 = 0x0010

	// DataRate128 control the data rate setting. 128 Sample Per Seconds
	DataRate128 uint16 = 0x0000
	// DataRate250 control the data rate setting. 250 Sample Per Seconds
	DataRate250 uint16 = 0x0020
	// DataRate490 control the data rate setting. 490 Sample Per Seconds
	DataRate490 uint16 = 0x0040
	// DataRate920 control the data rate setting. 64 Sample Per Seconds
	DataRate920 uint16 = 0x0060
	// DataRate1600  control the data rate setting. 128 Sample Per Seconds
	DataRate1600 uint16 = 0x0080
	// DataRate2400 control the data rate setting. 250  Sample Per Seconds
	DataRate2400 uint16 = 0x00A0
	// DataRate3300_0 control the data rate setting. 475 Sample Per Seconds
	DataRate3300_0 uint16 = 0x00C0
	// DataRate3300_1 control the data rate setting. 475 Sample Per Seconds
	DataRate3300_1 uint16 = 0x00E0

	// DeviceOperationModeContinous Continuous-conversion mode
	DeviceOperationModeContinous uint16 = 0x0000
	// DeviceOperationModeSingleShot  Single-shot mode or power-down state
	DeviceOperationModeSingleShot uint16 = 0x0100

	// ProgramableGainAmplifier6144 These bits set the FSR of the programmable gain amplifier. For voltages in the range ±6.144
	ProgramableGainAmplifier6144 uint16 = 0x0000
	// ProgramableGainAmplifier4096 set the FSR of the programmable gain amplifier. For voltages in the range ±4.096
	ProgramableGainAmplifier4096 uint16 = 0x0200
	// ProgramableGainAmplifier2048 set the FSR of the programmable gain amplifier. For voltages in the range ±2.048
	ProgramableGainAmplifier2048 uint16 = 0x0400
	// ProgramableGainAmplifier1024 set the FSR of the programmable gain amplifier. For voltages in the range ±1.024
	ProgramableGainAmplifier1024 uint16 = 0x0600
	// ProgramableGainAmplifier0512 set the FSR of the programmable gain amplifier. For voltages in the range ±0.512
	ProgramableGainAmplifier0512 uint16 = 0x0800
	// ProgramableGainAmplifier0256_0 set the FSR of the programmable gain amplifier. For voltages in the range ±0.256
	ProgramableGainAmplifier0256_0 uint16 = 0x0A00
	// ProgramableGainAmplifier0256_1 set the FSR of the programmable gain amplifier. For voltages in the range ±0.256
	ProgramableGainAmplifier0256_1 uint16 = 0x0C00
	// ProgramableGainAmplifier0256_2 set the FSR of the programmable gain amplifier. For voltages in the range ±0.256
	ProgramableGainAmplifier0256_2 uint16 = 0x0E00

	// MultiplexerConfigurationAIN0 AINP = AIN0 and AINN = GND
	MultiplexerConfigurationAIN0 uint16 = 0x4000
	// MultiplexerConfigurationAIN1 AINP = AIN1 and AINN = GND
	MultiplexerConfigurationAIN1 uint16 = 0x5000
	// MultiplexerConfigurationAIN2 AIN2 = AIN2 and AINN = GND
	MultiplexerConfigurationAIN2 uint16 = 0x6000
	// MultiplexerConfigurationAIN3 AIN3 = AIN3 and AINN = GND
	MultiplexerConfigurationAIN3 uint16 = 0x7000
)
View Source
const (
	// Recommended Minimum Specific Data from GPS
	GPRMC = "$GPRMC,"
	// Recommended Minimum Specific Data from GPS & Beidou/China
	GNRMC = "$GNRMC,"
)

Variables

View Source
var (
	SetAfuiotB1Uart       = []byte{0xAA, 0xA5, 0x04, 0x05, 0x01, 0x0A, 0x55}
	SetAfuiotB1I2C        = []byte{0xAA, 0xA5, 0x04, 0x05, 0x02, 0x0A, 0x55}
	SetAfuiotB1ObjectTemp = []byte{0xAA, 0xA5, 0x04, 0x02, 0x01, 0x07, 0x55}
	SetAfuiotB1HumanTemp  = []byte{0xAA, 0xA5, 0x04, 0x02, 0x02, 0x08, 0x55}
)
View Source
var (
	// GY25QueryMode ...
	GY25QueryMode = GY25Mode{0xA5, 0x51}
	// GY25AutoMode ...
	GY25AutoMode = GY25Mode{0xA5, 0x52}
	// GY25AutoTextMode ...
	GY25AutoTextMode = GY25Mode{0xA5, 0x53}
	// GY25CorrectionPitchAndRollMode ...
	GY25CorrectionPitchAndRollMode = GY25Mode{0xA5, 0x54}
	// GY25CorrectionYawMode ...
	GY25CorrectionYawMode = GY25Mode{0xA5 + 0x55}
)

Functions

This section is empty.

Types

type A4988

type A4988 struct {
	// contains filtered or unexported fields
}

A4988 ...

func NewA4988

func NewA4988(step, dir, ms1, ms2, ms3 uint8) *A4988

NewA4988 ...

func (*A4988) Roll

func (a *A4988) Roll(angle float64)

Roll gets the motor rolls angle degree. roll in clockwise direction if angle > 0, or roll in counter-clockwise direction if angle < 0, or motionless if angle = 0.

func (*A4988) SetMode

func (a *A4988) SetMode(mode StepperMode) error

SetMode sets the stepping mode

func (*A4988) Step

func (a *A4988) Step(n int)

Step gets the motor rolls n steps. roll in clockwise direction if n > 0, or roll in counter-clockwise direction if n < 0, or motionless if n = 0.

type ADC

type ADC interface {
	Read(channel int) (float64, error)
	Close() error
}

ADC is the interface of Analog DigitalC onverter

type ADS1015

type ADS1015 struct {
	// contains filtered or unexported fields
}

ADS1015 is a 12-bit analog-digital converter. It implements ADC interface

func NewADS1015

func NewADS1015() (*ADS1015, error)

NewADS1015 create a driver for ADS1015 module

func (*ADS1015) Close

func (m *ADS1015) Close() error

Close ...

func (*ADS1015) Read

func (m *ADS1015) Read(channel int) (float64, error)

Read ...

func (*ADS1015) SetConfig

func (m *ADS1015) SetConfig(config uint16)

SetConfig ...

type Accelerometer

type Accelerometer interface {
	Angles() (yaw, pitch, roll float64, err error)
	Close() error
}

Accelerometer ...

type AfuiotB1

type AfuiotB1 struct {
	// contains filtered or unexported fields
}

AfuiotB1 implements Thermometer interface

func NewAfuiotB1

func NewAfuiotB1(dev string, baud int) (*AfuiotB1, error)

NewAfuiotB1 ...

func (*AfuiotB1) Close

func (b1 *AfuiotB1) Close() error

Close ...

func (*AfuiotB1) Set

func (b1 *AfuiotB1) Set(bytes []byte) error

Set ...

func (*AfuiotB1) Temperature

func (b1 *AfuiotB1) Temperature() (float64, error)

Temperature ...

type BYJ2848

type BYJ2848 struct {
	// contains filtered or unexported fields
}

BYJ2848 implements StepperMotor interface

func NewBYJ2848

func NewBYJ2848(in1, in2, in3, in4 uint8) *BYJ2848

NewBYJ2848 ...

func (*BYJ2848) Roll

func (byj *BYJ2848) Roll(angle float64)

Roll gets the motor rolls angle degree. roll in clockwise direction if angle > 0, or roll in counter-clockwise direction if angle < 0, or motionless if angle = 0.

func (*BYJ2848) SetMode

func (byj *BYJ2848) SetMode(mode StepperMode) error

SetMode sets the stepping mode. Please NOTE only FullMode is supported currently, and FullMode is used by default.

func (*BYJ2848) Step

func (byj *BYJ2848) Step(n int)

Step gets the motor rolls n steps. roll in clockwise direction if n > 0, or roll in counter-clockwise direction if n < 0, or motionless if n = 0.

type Button

type Button interface {
	Pressed() bool
}

Button ...

type ButtonImp

type ButtonImp struct {
	// contains filtered or unexported fields
}

ButtonImp implements Button interface

func NewButtonImp

func NewButtonImp(pin uint8) *ButtonImp

NewButtonImp ...

func (*ButtonImp) Pressed

func (b *ButtonImp) Pressed() bool

Pressed ...

type Buzzer

type Buzzer interface {
	On()
	Off()
	Beep(n int, intervalMs int)
}

Buzzer ...

type BuzzerImp

type BuzzerImp struct {
	// contains filtered or unexported fields
}

BuzzerImp implements Buzzer interface

func NewBuzzerImp

func NewBuzzerImp(pin uint8, trigBy LogicLevel) *BuzzerImp

NewBuzzerImp ...

func (*BuzzerImp) Beep

func (b *BuzzerImp) Beep(n int, intervalMs int)

Beep beeps [n] times with an interval in [interval] millisecond

func (*BuzzerImp) Off

func (b *BuzzerImp) Off()

Off ...

func (*BuzzerImp) On

func (b *BuzzerImp) On()

On ...

type CH2OMeter

type CH2OMeter interface {
	Value() (float64, error)
	Close() error
}

CH2OMeter ...

type Camera

type Camera interface {
	Photo() ([]byte, error)
}

camera ...

type CollisionSwitch

type CollisionSwitch struct {
	// contains filtered or unexported fields
}

CollisionSwitch implements Detector interface

func NewCollisionSwitch

func NewCollisionSwitch(pin uint8) *CollisionSwitch

NewCollisionSwitch ...

func (*CollisionSwitch) Detected

func (c *CollisionSwitch) Detected() bool

Deteched ...

type DCMotor

type DCMotor struct {
	// contains filtered or unexported fields
}

func NewDCMotor

func NewDCMotor(driver MotorDriver) *DCMotor

NewDCMotor ...

func (*DCMotor) Backward

func (m *DCMotor) Backward()

Backward ...

func (*DCMotor) Forward

func (m *DCMotor) Forward()

Forward ...

func (*DCMotor) SetSpeed

func (m *DCMotor) SetSpeed(percent uint32)

Speed ...

func (*DCMotor) Stop

func (m *DCMotor) Stop()

Stop ...

type DHT11

type DHT11 struct {
	// contains filtered or unexported fields
}

DHT11 implements Thermohygrometer interface

func NewDHT11

func NewDHT11() *DHT11

NewDHT11 ...

func (*DHT11) TempHumidity

func (d *DHT11) TempHumidity() (temp, humi float64, err error)

TempHumidity ...

type DS18B20

type DS18B20 struct {
}

DS18B20 implements Thermometer interface

func NewDS18B20

func NewDS18B20() *DS18B20

NewDS18B20 ...

func (*DS18B20) Temperature

func (d *DS18B20) Temperature() (float64, error)

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 Detector

type Detector interface {
	Detected() bool
}

Detector ...

type Display

type Display interface {
	Image(img image.Image) error
	Text(text string, x, y int) error
	On() error
	Off() error
	Clear() error
	Close() error
}

Display ...

type DistanceMeter

type DistanceMeter interface {
	Dist() (float64, error)
	Close() error
}

DistanceMeter ...

type Encoder

type Encoder interface {
	Count1() int
	Detected() bool
	Start()
	Stop()
}

Encoder ...

type EncoderImp

type EncoderImp struct {
	// contains filtered or unexported fields
}

EncoderImp implements Encoder interface

func NewEncoderImp

func NewEncoderImp(pin uint8) *EncoderImp

NewEncoderImp ...

func (*EncoderImp) Count1

func (e *EncoderImp) Count1() int

Count1 ...

func (*EncoderImp) Detected

func (e *EncoderImp) Detected() bool

Detected ...

func (*EncoderImp) Start

func (e *EncoderImp) Start()

Start ...

func (*EncoderImp) Stop

func (e *EncoderImp) Stop()

Stop ...

type Fan

type Fan struct {
	// contains filtered or unexported fields
}

Fan ...

func NewFan

func NewFan(pin uint8) *Fan

NewFan ...

func (*Fan) Off

func (f *Fan) Off()

Off ...

func (*Fan) On

func (f *Fan) On()

On ...

type GPS

type GPS interface {
	Loc() (lat, lon float64, err error)
	Close() error
}

GPS ...

type GPSSimulator

type GPSSimulator struct {
	// contains filtered or unexported fields
}

GPSSimulator implements GPS interface

func NewGPSSimulator

func NewGPSSimulator(latlons [][]float64) (*GPSSimulator, error)

NewGPSSimulator ...

func (*GPSSimulator) Close

func (gps *GPSSimulator) Close() error

Close ...

func (*GPSSimulator) Loc

func (gps *GPSSimulator) Loc() (lat, lon float64, err error)

Loc ...

type GY25

type GY25 struct {
	// contains filtered or unexported fields
}

GY25 implements Accelerometer interface

func NewGY25

func NewGY25(dev string, baud int) (*GY25, error)

NewGY25 ...

func (*GY25) Angles

func (gy *GY25) Angles() (yaw, pitch, roll float64, err error)

Angles ...

func (*GY25) Close

func (gy *GY25) Close() error

Close ...

func (*GY25) SetMode

func (gy *GY25) SetMode(mode GY25Mode) error

SetMode ...

type GY25Mode

type GY25Mode []byte

GY25Mode ...

type HCSR04

type HCSR04 struct {
	// contains filtered or unexported fields
}

HCSR04 implements DistanceMeter interface

func NewHCSR04

func NewHCSR04(trig int8, echo int8) *HCSR04

NewHCSR04 ...

func (*HCSR04) Close

func (hc *HCSR04) Close() error

Close ...

func (*HCSR04) Dist

func (hc *HCSR04) Dist() (float64, error)

Value returns distance in cm to objects

type HDC1080

type HDC1080 struct {
	// contains filtered or unexported fields
}

HDC1080 ...

func NewHDC1080

func NewHDC1080() (*HDC1080, error)

NewHDC1080 implement Thermohygrometer interface

func (*HDC1080) Close

func (hdc *HDC1080) Close() error

Close ...

func (*HDC1080) TempHumidity

func (hdc *HDC1080) TempHumidity() (temp, humi float64, err error)

TempHumidity ...

type HT1818GPS

type HT1818GPS struct {
	// contains filtered or unexported fields
}

HT1818GPS implements GPS interface

func NewHT1818GPS

func NewHT1818GPS(dev string, baud int) (*HT1818GPS, error)

NewHT1818GPS ...

func (*HT1818GPS) Close

func (gps *HT1818GPS) Close() error

Close ...

func (*HT1818GPS) Loc

func (gps *HT1818GPS) Loc() (lat, lon float64, err error)

Loc ...

type HumidityDetector

type HumidityDetector struct {
	// contains filtered or unexported fields
}

HumidityDetector implements Detector interface

func NewHumidityDetector

func NewHumidityDetector(pin uint8) *HumidityDetector

NewHumidityDetector ...

func (*HumidityDetector) Detected

func (h *HumidityDetector) Detected() bool

Detected ...

type Hygrometer

type Hygrometer interface {
	Humidity() (float32, error)
}

Hygrometer ...

type IRCoder

type IRCoder struct {
	// contains filtered or unexported fields
}

IRCoder ...

func NewIRCoder

func NewIRCoder(dev string, baud int) (*IRCoder, error)

NewIRCoder ...

func (*IRCoder) Close

func (ir *IRCoder) Close() error

Close ...

func (*IRCoder) Read

func (ir *IRCoder) Read() ([]byte, error)

func (*IRCoder) Send

func (ir *IRCoder) Send(data []byte) error

type IRDetector

type IRDetector struct {
	// contains filtered or unexported fields
}

IRDetector implements Detector interface

func NewIRDetector

func NewIRDetector(out uint8) *IRDetector

NewIRDetector ...

func (*IRDetector) Detected

func (ir *IRDetector) Detected() bool

Detected ...

type InterfaceType

type InterfaceType int
const (
	GPIO InterfaceType = iota
	I2C
	SPI
	UART
	USB
)

type Joystick

type Joystick interface {
	X() float64
	Y() float64
	Z() int
}

Joystick ...

type JoystickImp

type JoystickImp struct {
	// contains filtered or unexported fields
}

JoystickImp ...

func NewJoystickImp

func NewJoystickImp(sw uint8) (*JoystickImp, error)

NewJoystickImp ...

func (*JoystickImp) X

func (j *JoystickImp) X() float64

X ...

func (*JoystickImp) Y

func (j *JoystickImp) Y() float64

Y ...

func (*JoystickImp) Z

func (j *JoystickImp) Z() int

Z ... z = 1: pressed z = 0: home

type L298N

type L298N struct {
	MotorA MotorDriver
	MotorB MotorDriver
}

L298N implements MotorDriver interface

func NewL298N

func NewL298N(in1, in2, in3, in4, ena, enb uint8) *L298N

NewL298N ...

type LC12S

type LC12S struct {
	// contains filtered or unexported fields
}

LC12S implement Wireless interface

func NewLC12S

func NewLC12S(dev string, baud int, csPin uint8) (*LC12S, error)

NewLC12S ...

func (*LC12S) Close

func (l *LC12S) Close() error

Close ...

func (*LC12S) Receive

func (l *LC12S) Receive() ([]byte, error)

Receive ...

func (*LC12S) Send

func (l *LC12S) Send(data []byte) error

Send ...

func (*LC12S) Sleep

func (l *LC12S) Sleep()

Sleep ...

func (*LC12S) Wakeup

func (l *LC12S) Wakeup()

Wakeup ...

type LD2410

type LD2410 struct {
	// contains filtered or unexported fields
}

LD2410 implements Detector interface

func NewLD2410

func NewLD2410(out uint8) *LD2410

NewLD2410 ...

func (*LD2410) Detected

func (ld *LD2410) Detected() bool

Detected ...

type LcdDisplay

type LcdDisplay struct {
	// contains filtered or unexported fields
}

LcdDisplay is a driver for LCD Dispaly.

func NewLcdDisplay

func NewLcdDisplay(width, height int) (*LcdDisplay, error)

NewLcdDisplay creates a driver for LCD display. It is an implement of Display interface. Please NOTE that I only test it on a 1602A lcd display module.

func (*LcdDisplay) Clear

func (lcd *LcdDisplay) Clear() error

func (*LcdDisplay) Close

func (lcd *LcdDisplay) Close() error

func (*LcdDisplay) Image

func (lcd *LcdDisplay) Image(img image.Image) error

Image displays an image on the screen. NOTE: it isn't be implemented yet.

func (*LcdDisplay) Off

func (lcd *LcdDisplay) Off() error

func (*LcdDisplay) On

func (lcd *LcdDisplay) On() error

func (*LcdDisplay) Text

func (lcd *LcdDisplay) Text(text string, x, y int) error

Text display text on the screen

type Led

type Led interface {
	On()
	Off()
	Blink(n int, intervalMs int)
}

Led ...

type LedImp

type LedImp struct {
	// contains filtered or unexported fields
}

LedImp implements Led interface

func NewLedImp

func NewLedImp(pin uint8) *LedImp

NewLedImp ...

func (led *LedImp) Blink(n int, intervalMs int)

Blink is let led blink n time, interval Millisecond each time

func (*LedImp) Fade

func (led *LedImp) Fade(n uint8)

Fade ...

func (*LedImp) Off

func (led *LedImp) Off()

Off ...

func (*LedImp) On

func (led *LedImp) On()

On ...

type LogicLevel

type LogicLevel int
const (
	Low  LogicLevel = 0
	High LogicLevel = 1
)

type MPU6050

type MPU6050 struct {
	// contains filtered or unexported fields
}

MPU6050 ...

func NewMPU6050

func NewMPU6050() (*MPU6050, error)

NewMPU6050 ...

func (*MPU6050) Close

func (m *MPU6050) Close() error

Close ...

func (*MPU6050) GetAcc

func (m *MPU6050) GetAcc() (x int32, y int32, z int32)

GetAcc ...

func (*MPU6050) GetRot

func (m *MPU6050) GetRot() (x int32, y int32, z int32)

GetRot ...

type MQ7

type MQ7 struct {
	// contains filtered or unexported fields
}

MQ7 implements Detector interface

func NewMQ7

func NewMQ7(do uint8) *MQ7

NewMQ7 ...

func (*MQ7) Detected

func (mq7 *MQ7) Detected() bool

Detected ...

type MotionCamera

type MotionCamera struct {
}

MotionCamera implements Camera interface

func NewMotionCamera

func NewMotionCamera() *MotionCamera

NewMotionCamera ...

func (*MotionCamera) Photo

func (c *MotionCamera) Photo() ([]byte, error)

Photo takes 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' you also need to make sure webcontrol_port=8088 for this function working. after changing, this will be look like: ----------------------------------------- target_dir /var/lib/motion snapshot_filename lastsnap.jpg webcontrol_port 8088 -----------------------------------------

type Motor

type Motor interface {
	Forward()
	Backward()
	Stop()
	SetSpeed(percent uint32)
}

Motor ...

type MotorDriver

type MotorDriver interface {
	Motor
}

MotorDriver ...

type Neo6mGPS

type Neo6mGPS struct {
	// contains filtered or unexported fields
}

Neo6mGPS implements GPS interface

func NewNeo6mGPS

func NewNeo6mGPS(dev string, baud int) (*Neo6mGPS, error)

NewNeo6mGPS ...

func (*Neo6mGPS) Close

func (gps *Neo6mGPS) Close() error

Close ...

func (*Neo6mGPS) Loc

func (gps *Neo6mGPS) Loc() (lat, lon float64, err error)

Loc ...

type PCF8591

type PCF8591 struct {
	// contains filtered or unexported fields
}

PCF8591 ...

func NewPCF8591

func NewPCF8591() (*PCF8591, error)

NewPCF8591 ...

func (*PCF8591) Close

func (pcf *PCF8591) Close() error

Close ...

func (*PCF8591) ReadAIN0

func (pcf *PCF8591) ReadAIN0() ([]byte, error)

ReadAIN0 ...

func (*PCF8591) ReadAIN1

func (pcf *PCF8591) ReadAIN1() ([]byte, error)

ReadAIN1 ...

func (*PCF8591) ReadAIN2

func (pcf *PCF8591) ReadAIN2() ([]byte, error)

ReadAIN2 ...

func (*PCF8591) ReadAIN3

func (pcf *PCF8591) ReadAIN3() ([]byte, error)

ReadAIN3 ...

type PMS7003

type PMS7003 struct {
	// contains filtered or unexported fields
}

PMS7003 ...

func NewPMS7003

func NewPMS7003(dev string, baud int) (*PMS7003, error)

NewPMS7003 ...

func (*PMS7003) Close

func (pms *PMS7003) Close() error

Close ...

func (*PMS7003) Get

func (pms *PMS7003) Get() (uint16, uint16, error)

Get returns pm2.5 and pm10 in ug/m3

type Pump

type Pump interface {
	On()
	Off()
	Run(sec int)
}

Pump ...

type PumpImp

type PumpImp struct {
	// contains filtered or unexported fields
}

PumpImp implements Pump interface

func NewPumpImp

func NewPumpImp(pin uint8) *PumpImp

NewLedImp ...

func (*PumpImp) Off

func (p *PumpImp) Off()

Off ...

func (*PumpImp) On

func (p *PumpImp) On()

On ...

func (*PumpImp) Run

func (p *PumpImp) Run(sec int)

Run lets the pump keep running in sec time

type RFP602

type RFP602 struct {
	// contains filtered or unexported fields
}

RFP602 implements Detector interface

func NewRFP602

func NewRFP602(do uint8) *RFP602

NewRFP602 ...

func (*RFP602) Detected

func (rfp *RFP602) Detected() bool

Detected ...

type RFReceiver

type RFReceiver interface {
	Received(ch int) bool
}

RFReciver is the interface of radio-frequency receiver

type RX480E4

type RX480E4 struct {
	// contains filtered or unexported fields
}

RX480E4 implements RFReceiver

func NewRX480E4

func NewRX480E4(d0, d1, d2, d3 uint8) *RX480E4

NewRX480E4 ...

func (*RX480E4) Received

func (rx *RX480E4) Received(ch int) bool

PressA ...

type Relay

type Relay interface {
	On()
	Off()
}

Relay ...

type RelayImp

type RelayImp struct {
	// contains filtered or unexported fields
}

RelayImp ...

func NewRelayImp

func NewRelayImp(pin uint8) *RelayImp

NewRelayImp ...

func (*RelayImp) Off

func (r *RelayImp) Off()

Off ...

func (*RelayImp) On

func (r *RelayImp) On()

On ...

type SG90

type SG90 struct {
	// contains filtered or unexported fields
}

SG90 implements Motor interface

func NewSG90

func NewSG90(pin uint8) *SG90

NewSG90 ...

func (*SG90) Roll

func (sg *SG90) Roll(angle float64)

Roll ... angle: [-90, 90] angle < 0: roll anticlockwise angel = 0: ahead angle > 0: roll clockwise e.g.

    -30  0   30
      \  |  /
       \ | /
        \|/
-90 ---- * ---- 90
      +-----+
      |     |
      |     | sg90
      | (*) |
      +-----+

func (*SG90) SetSpeed

func (sg *SG90) SetSpeed(speed int)

type SSD1306Display

type SSD1306Display struct {
	// contains filtered or unexported fields
}

SSD1306Display is a driver for the oled display module drived by SSD1306 chip. It is an implement of Display interface.

func NewSSD1306Display

func NewSSD1306Display(width, heigth int) (*SSD1306Display, error)

NewSSD1306Display creates a driver for the oled display module drived by SSD1306 chip

func (*SSD1306Display) Clear

func (display *SSD1306Display) Clear() error

Clear ...

func (*SSD1306Display) Close

func (display *SSD1306Display) Close() error

Close ...

func (*SSD1306Display) Image

func (display *SSD1306Display) Image(img image.Image) error

Image displays an image on the screen

func (*SSD1306Display) Off

func (display *SSD1306Display) Off() error

Off ...

func (*SSD1306Display) On

func (display *SSD1306Display) On() error

On ...

func (*SSD1306Display) Text

func (display *SSD1306Display) Text(text string, x, y int) error

Text displays the text on the screen. NOTE: It isn't implemented. It is here just for implementing the Display interface. Please draw your text to an image first, and then use DisplayImage()

type ST7789Display

type ST7789Display struct {
	// contains filtered or unexported fields
}

ST7789Display is a driver for the tft lcd display module drived by ST7789 chip. It is an implement of Display interface.

func NewST7789Display

func NewST7789Display(res, dc, blk uint8, width, height int) (*ST7789Display, error)

NewST7789Display create a driver for the tft lcd display module drived by ST7789 chip. Note that you should disable SPI interface in raspi-config first!

func (*ST7789Display) Clear

func (display *ST7789Display) Clear() error

Clear clears the image

func (*ST7789Display) Close

func (display *ST7789Display) Close() error

Close closes the module

func (*ST7789Display) Image

func (display *ST7789Display) Image(img image.Image) error

Image displays an image on the screen

func (*ST7789Display) Off

func (display *ST7789Display) Off() error

On turns the blacklight off

func (*ST7789Display) On

func (display *ST7789Display) On() error

On turns the blacklight on

func (*ST7789Display) Text

func (display *ST7789Display) Text(text string, x, y int) error

Text displays the text on the screen. NOTE: It isn't implemented. It is here just for implementing the Display interface. Please draw your text to an image first, and then use DisplayImage()

type SW420

type SW420 struct {
	// contains filtered or unexported fields
}

SW420 implements Detector interface

func NewSW420

func NewSW420(pin uint8) *SW420

NewSW420 ...

func (*SW420) Detected

func (sw *SW420) Detected() bool

Detected returns true if the sensor detects shaking, or return false

type ServoMotor

type ServoMotor interface {
	// Roll gets the servo motor rolls angle dregee in clockwise direction if angle > 0,
	// or roll in counter-clockwise direction if angle < 0,
	// motionless if angle = 0.
	Roll(angle float64)
}

ServoMotor ...

type StepperMode

type StepperMode int
const (
	FullMode StepperMode = iota
	HalfMode
	QuarterMode
	EighthMode
	SixteenthMode
)

type StepperMotor

type StepperMotor interface {
	// Step gets the stepper motor rolls n steps in clockwise direction if angle > 0,
	// or roll in counter-clockwise direction if n < 0,
	// or motionless if n = 0.
	Step(n int)
	// Roll gets the stepper motor rolls angle dregee in clockwise direction if angle > 0,
	// or roll in counter-clockwise direction if angle < 0,
	// motionless if angle = 0.
	Roll(angle float64)
	// SetMode sets sets the stepping mode.
	// For example: Full, Half, Quarter, Eighth, Sixteenth.
	// Please NOTE not all steppers support all modes. Some steppers only support one or two modes.
	SetMode(mode StepperMode) error
}

Stepper ...

type TM1637Display

type TM1637Display struct {
	// contains filtered or unexported fields
}

TM1637Display is a dirvier for digital led display module drived by TM1637 chip. It is an implement of Display interface.

func NewTM1637Display

func NewTM1637Display(dioPin, rclkPin, sclkPin uint8) *TM1637Display

NewTM1637Display creates a TM1637Display driver. Please NOTE that I only test it on a 4-bit digital led module.

func (*TM1637Display) Clear

func (display *TM1637Display) Clear() error

Clear ...

func (*TM1637Display) Close

func (display *TM1637Display) Close() error

Close ...

func (*TM1637Display) Image

func (display *TM1637Display) Image(img image.Image) error

Image displays an image on the screen. NOTE: Digital led display module can't be used to display an image. It is here just for implementing the Display interface.

func (*TM1637Display) Off

func (display *TM1637Display) Off() error

Off ...

func (*TM1637Display) On

func (display *TM1637Display) On() error

On ...

func (*TM1637Display) Text

func (display *TM1637Display) Text(text string, x, y int) error

Text display text on the screen. NOTE: (x, y) never be used. They are here just for implementing the Display interface.

type Thermohygrometer

type Thermohygrometer interface {
	TempHumidity() (temp, humi float64, err error)
}

Thermohygrometer ...

type Thermometer

type Thermometer interface {
	Temperature() (float64, error)
}

Thermometer ...

type US100

type US100 struct {
	// contains filtered or unexported fields
}

US100 ...

func NewUS100GPIO

func NewUS100GPIO(trig, echo uint8) (*US100, error)

NewUS100GPIO creates US100 using GPOI interface

func NewUS100UART

func NewUS100UART(dev string, baud int) (*US100, error)

NewUS100UART creates US100 using UART interface

func (*US100) Close

func (us *US100) Close() error

Close ...

func (*US100) Dist

func (us *US100) Dist() (float64, error)

Value returns the distance in cm to objects

type VoiceDetector

type VoiceDetector struct {
	// contains filtered or unexported fields
}

VoiceDetector implements Detector interface

func NewVoiceDetector

func NewVoiceDetector(pin uint8) *VoiceDetector

NewVoiceDetector ...

func (*VoiceDetector) Detected

func (v *VoiceDetector) Detected() bool

Detected ...

type Wireless

type Wireless interface {
	Send(data []byte) error
	Receive() ([]byte, error)
	Sleep()
	Wakeup()
	Close() error
}

Wireless ...

type ZE08CH2O

type ZE08CH2O struct {
	// contains filtered or unexported fields
}

ZE08CH2O implements CH2OMeter interface

func NewZE08CH2O

func NewZE08CH2O() (*ZE08CH2O, error)

NewZE08CH2O ...

func (*ZE08CH2O) Close

func (ze *ZE08CH2O) Close() error

Close ...

func (*ZE08CH2O) Value

func (ze *ZE08CH2O) Value() (float64, error)

Get returns ch2o in mg/m3

type ZP16

type ZP16 struct {
	// contains filtered or unexported fields
}

ZP16 ...

func NewZP16

func NewZP16(dev string, baud int) (*ZP16, error)

NewZP16 ...

func (*ZP16) CO

func (zp *ZP16) CO() (float64, error)

Loc ...

func (*ZP16) Close

func (zp *ZP16) Close() error

Close ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL