dev

package
v0.0.0-...-d12e797 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 24 Imported by: 2

Documentation

Overview

bmw280 reads sensor data from Bosh BME280 sensor. taken from https://github.com/quhar/bme280

Package dev ...

ADS1015 is the driver for ADS1015 module. https://wenku.baidu.com/view/308f9a69a9114431b90d6c85ec3a87c240288aa7

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:

  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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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:

  1. sudo vim /boot/config.txt
  2. add following line to the end of config.txt -------------------------- dtoverlay=dht11,gpiopin=4 --------------------------
  3. 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:

  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 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:

  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 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 ...

GY25 is the driver of GY25, an angle sensor which can be used to detect yaw, pitch and roll angle.

Config Your 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 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 ...

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 ...

Connect to Pi:

  • +V5: any 5v
  • GND: any gnd pin
  • SM : any data pin
  • Rx: PCF8591->AIN0
  • Ry: PCF8591->AIN1

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:

  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 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:

  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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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:

  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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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:

  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: -- -- -- -- -- -- -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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:

  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 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:

  • S: any data pin
  • M: 5v
  • -: any ground

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:

  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 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:

  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 Pi:

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

Index

Constants

View Source
const (
	T1 byte = 0x88 + iota*2
	T2
	T3
	P1
	P2
	P3
	P4
	P5
	P6
	P7
	P8
	P9
	H1 byte = 0xA1
	H2 byte = 0xE1
	H3 byte = 0xE3
	H4 byte = 0xE4
	H5 byte = 0xE5
	H6 byte = 0xE7
)

Compensation registers addresses.

View Source
const (
	TempCompAddr  byte = 0x88
	PressCompAddr byte = 0x8E
	H1CompAddr    byte = 0xA1
	H2CompAddr    byte = 0xE1
)
View Source
const (
	HumAddr   byte = 0xFD
	TempAddr  byte = 0xFA
	PressAddr byte = 0xF7
	DataAddr  byte = 0xF7
)

Data registers addresses.

View Source
const (
	IDAddr       byte = 0xD0
	ResetAddr    byte = 0xE0
	CtrlHumAddr  byte = 0xF2
	StatusAddr   byte = 0xF3
	CtrlMeasAddr byte = 0xF4
	ConfigAddr   byte = 0xF5
)

Other registers addresses.

View Source
const (
	// I2CAddr is default BME280 I2C address.
	I2CAddr int = 0x77
	// ResetVal is a value which when written to ResetAddr resets the sensor.
	ResetVal byte = 0xB6
	// IDVal is a ID value of the sensor.
	IDVal byte = 0x60
)

General constants.

View Source
const (
	OverSmpl1 byte
	OverSmpl2
	OverSmpl4
	OverSmpl8
	OverSmpl16
)

Oversampling constants.

View Source
const (
	SleepMode  byte = 0x00
	ForcedMode byte = 0x01
	NormalMode byte = 0x03
)

Modes of operation.

View Source
const (
	FilterOff byte = iota << 2
	Filter2
	Filter4
	Filter8
	Filter16
)

Filter settins

View Source
const (
	// Standby for 0.5 ms.
	Stndby05 byte = iota << 5
	// Standby for 62.5 ms.
	Stndby625
	// Standby for 125 ms.
	Stndby125
	// Standby for 250 ms.
	Stndby250
	// Standby for 500 ms.
	Stndby500
	// Standby for 1000 ms.
	Stbdby1000
	// Standby for 10 ms.
	Stndby10
	// Standby for 20 ms.
	Stndby20
)

Normal mode standby modes.

View Source
const (
	Celsius = iota
	Fahrenheit
	Kelvin
)

Available temperature units.

View Source
const (
	HPa = iota
	Bar
	PSI
)

Available pressure units.

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
)

Variables

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

func NewSevenColorLed

func NewSevenColorLed(pin uint) *sevenColorLed

func NewTapModule

func NewTapModule(pinNumber uint8) *tap

Types

type ADS1015

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

ADS1015 ...

func NewADS1015

func NewADS1015() (*ADS1015, error)

NewADS1015 ...

func (*ADS1015) Close

func (m *ADS1015) Close()

Close ...

func (*ADS1015) Read

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

Read ...

func (*ADS1015) SetConfig

func (m *ADS1015) SetConfig(config uint16)

SetConfig ...

type BME280

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

BME280 is an object representing BME280 sensor.

func New

func New(dev bus, opts ...Option) *BME280

New returns new BME280 object. New object has following default values: mode = ForcedMode tempOverSmpl = 16 pressOverSmpl = 16 humOverSmpl = 16 filter = off standby = 500ms Temperature units Celsius Presure units hPa

func (*BME280) EnvData

func (b *BME280) EnvData() (temp, press, hum float64, err error)

EnvData returns compensated temperature, pressure and humidity.

func (*BME280) Hum

func (b *BME280) Hum() (float64, error)

Hum returns humidity

func (*BME280) Init

func (b *BME280) Init() error

init initializes BME280 and loads calibration data

func (*BME280) Press

func (b *BME280) Press() (float64, error)

Press returns pressure in set units.

func (*BME280) RawData

func (b *BME280) RawData() (temp, press, hum int32, err error)

RawData returnes un-compensated data read from the sensor.

func (*BME280) SetPressUnit

func (b *BME280) SetPressUnit(unit int)

SetPressUnit sets pressure unit.

func (*BME280) SetTempUnit

func (b *BME280) SetTempUnit(unit int)

SetTempUnit sets temperature unit.

func (*BME280) Temp

func (b *BME280) Temp() (float64, error)

Temp returns temperature in set units.

type Button

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

Button ...

func NewButton

func NewButton(pin uint8) *Button

NewButton ...

func (*Button) Pressed

func (b *Button) Pressed() bool

Pressed ...

type Buzzer

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

Buzzer ...

func NewBuzzer

func NewBuzzer(pin int8) *Buzzer

NewBuzzer ...

func (*Buzzer) Beep

func (b *Buzzer) Beep(n int, interval int)

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

func (*Buzzer) Off

func (b *Buzzer) Off()

Off ...

func (*Buzzer) On

func (b *Buzzer) On()

On ...

type Camera

type Camera struct {
}

Camera ...

func NewCamera

func NewCamera() *Camera

NewCamera ...

func (*Camera) TakePhoto

func (c *Camera) TakePhoto() (string, error)

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 Collision

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

Collision ...

func NewCollision

func NewCollision(pin uint8) *Collision

NewCollision ...

func (*Collision) Collided

func (c *Collision) Collided() bool

Collided ...

type ComMode

type ComMode int

ComMode ...

const (
	// UartMode ...
	UartMode ComMode = iota
	// TTLMode ...
	TTLMode
)

type DHT11

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

DHT11 ...

func NewDHT11

func NewDHT11() *DHT11

NewDHT11 ...

func (*DHT11) TempHumidity

func (d *DHT11) TempHumidity() (float64, float64, error)

TempHumidity ...

type DS18B20

type DS18B20 struct {
}

DS18B20 ...

func NewDS18B20

func NewDS18B20() *DS18B20

NewDS18B20 ...

func (*DS18B20) GetTemperature

func (d *DS18B20) GetTemperature() (float32, 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 DistMeter

type DistMeter interface {
	Dist() float64
	Close()
}

DistMeter ...

type Encoder

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

Encoder ...

func NewEncoder

func NewEncoder(pin uint8) *Encoder

NewEncoder ...

func (*Encoder) Count1

func (e *Encoder) Count1() int

Count1 ...

func (*Encoder) Detected

func (e *Encoder) Detected() bool

Detected ...

func (*Encoder) Start

func (e *Encoder) Start()

Start ...

func (*Encoder) Stop

func (e *Encoder) Stop()

Stop ...

type GPS

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

GPS ...

func NewGPS

func NewGPS(dev string, baud int) *GPS

NewGPS ...

func (*GPS) Close

func (g *GPS) Close()

Close ...

func (*GPS) Loc

func (g *GPS) Loc() (*geo.Point, error)

Loc ...

type GY25

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

GY25 ...

func NewGY25

func NewGY25(dev string, baud int) *GY25

NewGY25 ...

func (*GY25) Angles

func (g *GY25) Angles() (float64, float64, float64, error)

Angles ...

func (*GY25) Close

func (g *GY25) Close()

Close ...

func (*GY25) IncludedAngle

func (g *GY25) IncludedAngle(yaw, yaw2 float64) float64

IncludedAngle ...

func (*GY25) SetMode

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

SetMode ...

type GY25Mode

type GY25Mode []byte

GY25Mode ...

type HCSR04

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

HCSR04 ...

func NewHCSR04

func NewHCSR04(trig int8, echo int8) *HCSR04

NewHCSR04 ...

func (*HCSR04) Close

func (h *HCSR04) Close()

Close ...

func (*HCSR04) Dist

func (h *HCSR04) Dist() float64

Dist is to measure the distance in cm

type Infrared

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

Infrared ...

func NewInfrared

func NewInfrared(pin uint8) *Infrared

NewInfrared ...

func (*Infrared) Detected

func (i *Infrared) Detected() bool

Detected ...

type Joystick

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

Joystick ...

func NewJoystick

func NewJoystick(sw uint8) (*Joystick, error)

NewJoystick ...

func (*Joystick) X

func (j *Joystick) X() (x float64)

X ...

func (*Joystick) Y

func (j *Joystick) Y() (y float64)

Y ...

func (*Joystick) Z

func (j *Joystick) Z() (z int)

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

type KY026

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

func NewKY026

func NewKY026(pin uint8) *KY026

func (KY026) Detected

func (f KY026) Detected() bool

type L298N

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

L298N ...

func NewL298N

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

NewL298N ...

func (*L298N) Backward

func (l *L298N) Backward()

Backward ...

func (*L298N) Forward

func (l *L298N) Forward()

Forward ...

func (*L298N) Left

func (l *L298N) Left()

Left ...

func (*L298N) Right

func (l *L298N) Right()

Right ...

func (*L298N) Speed

func (l *L298N) Speed(s uint32)

Speed ...

func (*L298N) Stop

func (l *L298N) Stop()

Stop ...

type LC12S

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

LC12S ...

func NewLC12S

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

NewLC12S ...

func (*LC12S) Close

func (l *LC12S) Close()

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 Laser

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

Laser ...

func NewLaser

func NewLaser(pin uint8) *Laser

NewLaser...

func (l *Laser) Blink(n int, interval int)

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

func (*Laser) Off

func (l *Laser) Off()

Off ...

func (*Laser) On

func (l *Laser) On()

On ...

type Led

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

Led ...

func NewLed

func NewLed(pin uint8) *Led

NewLed ...

func (l *Led) Blink(n int, interval int)

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

func (*Led) Fade

func (l *Led) Fade(n uint8)

Fade ...

func (*Led) Off

func (l *Led) Off()

Off ...

func (*Led) On

func (l *Led) On()

On ...

type LedDisplay

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

LedDisplay ...

func NewLedDisplay

func NewLedDisplay(dioPin, rclkPin, sclkPin uint8) *LedDisplay

NewLedDisplay ...

func (*LedDisplay) Close

func (d *LedDisplay) Close()

Close ...

func (*LedDisplay) Display

func (d *LedDisplay) Display(text string)

Display ...

func (*LedDisplay) Open

func (d *LedDisplay) Open()

Open ...

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()

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 MockGPS

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

MockGPS ...

func NewMockGPS

func NewMockGPS(csv string) *MockGPS

NewMockGPS ...

func (*MockGPS) Close

func (m *MockGPS) Close()

Close ...

func (*MockGPS) Loc

func (m *MockGPS) Loc() (*geo.Point, error)

Loc ...

type OLED

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

OLED ...

func NewOLED

func NewOLED(width, heigth int) (*OLED, error)

NewOLED ...

func (*OLED) Clear

func (o *OLED) Clear() error

Clear ...

func (*OLED) Close

func (o *OLED) Close()

Close ...

func (*OLED) Display

func (o *OLED) Display(text string, fontSize float64, x, y int) error

Display ...

func (*OLED) Off

func (o *OLED) Off()

Off ...

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an interface used to set various options in BME280 object.

func Filter

func Filter(f byte) Option

Filter sets default IIR filter value.

func HumOverSmpl

func HumOverSmpl(o byte) Option

HumOverSmpl sets default oversampling for humidity.

func Mode

func Mode(m byte) Option

Mode sets default sensors Mode of operation (Sleep, Standby, Forced).

func PressOverSmpl

func PressOverSmpl(o byte) Option

PressOverSmpl sets default oversampling for pressure.

func PressUnit

func PressUnit(u int) Option

PressUnits set default pressure units.

func Standby

func Standby(s byte) Option

Standby sets default Tstandby for Normal mode.

func TempOverSmpl

func TempOverSmpl(o byte) Option

TempOverSmpl sets default oversampling for temperature.

func TempUnit

func TempUnit(u int) Option

TempUnits set default temperature units.

type PCF8591

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

PCF8591 ...

func NewPCF8591

func NewPCF8591() (*PCF8591, error)

NewPCF8591 ...

func (*PCF8591) Close

func (m *PCF8591) Close()

Close ...

func (*PCF8591) ReadAIN0

func (m *PCF8591) ReadAIN0() []byte

ReadAIN0 ...

func (*PCF8591) ReadAIN1

func (m *PCF8591) ReadAIN1() []byte

ReadAIN1 ...

func (*PCF8591) ReadAIN2

func (m *PCF8591) ReadAIN2() []byte

ReadAIN2 ...

func (*PCF8591) ReadAIN3

func (m *PCF8591) ReadAIN3() []byte

ReadAIN3 ...

type PMS7003

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

PMS7003 ...

func NewPMS7003

func NewPMS7003(dev string, baud int) *PMS7003

NewPMS7003 ...

func (*PMS7003) Close

func (p *PMS7003) Close()

Close ...

func (*PMS7003) Get

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

Get returns pm2.5 and pm10 in ug/m3

func (*PMS7003) MockGet

func (p *PMS7003) MockGet() (uint16, uint16, error)

MockGet mocks Get()

type RGBLED

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

RGBLed ...

func NewRGBLed

func NewRGBLed(redPin uint8, greenPin uint8, bluePin uint8) *RGBLED

NewRGBLed ...

func (*RGBLED) BlueOff

func (r *RGBLED) BlueOff()

func (*RGBLED) BlueOn

func (r *RGBLED) BlueOn()

func (*RGBLED) GreenOff

func (r *RGBLED) GreenOff()

func (*RGBLED) GreenOn

func (r *RGBLED) GreenOn()

func (*RGBLED) RedOff

func (r *RGBLED) RedOff()

func (*RGBLED) RedOn

func (r *RGBLED) RedOn()

type RX480E4

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

RX480E4 ...

func NewRX480E4

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

NewRX480E4 ...

func (*RX480E4) PressA

func (r *RX480E4) PressA() bool

PressA ...

func (*RX480E4) PressB

func (r *RX480E4) PressB() bool

PressB ...

func (*RX480E4) PressC

func (r *RX480E4) PressC() bool

PressC ...

func (*RX480E4) PressD

func (r *RX480E4) PressD() bool

PressD ...

type Relay

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

Relay ...

func NewRelay

func NewRelay(pin uint8) *Relay

NewRelay ...

func (*Relay) Off

func (r *Relay) Off()

Off ...

func (*Relay) On

func (r *Relay) On()

On ...

type SG90

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

SG90 ...

func NewSG90

func NewSG90(pin uint8) *SG90

NewSG90 ...

func (*SG90) Roll

func (s *SG90) Roll(angle int)

Roll ... angle: [-90, 90] angle < 0: left angel = 0: ahead angle > 0: right e.g.

-30  0   30
  \  |  /
   \ | /
    \|/
     *
    eye

type SW420

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

SW420 ...

func NewSW420

func NewSW420(pin uint8) *SW420

NewSW420 ...

func (*SW420) KeepShaking

func (s *SW420) KeepShaking() bool

KeepShaking returns true if the sensor detects the object keeps shaking in 100 millisecond, or returns false

func (*SW420) Shaked

func (s *SW420) Shaked() bool

Shaked returns true if the sensor detects a shake, or return false

type ShockSensor

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

Collision ...

func NewShockSensor

func NewShockSensor(pin uint8) *ShockSensor

func (*ShockSensor) Shock

func (s *ShockSensor) Shock() bool

Shocked ...

type StepMotor

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

StepMotor ...

func NewStepMotor

func NewStepMotor(in1, in2, in3, in4 uint8) *StepMotor

NewStepMotor ...

func (*StepMotor) Roll

func (s *StepMotor) Roll(angle float32)

Roll ...

func (*StepMotor) Stop

func (s *StepMotor) Stop()

Stop ...

type US100

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

US100 ...

func NewUS100

func NewUS100(cfg *US100Config) *US100

NewUS100 ...

func (*US100) Close

func (u *US100) Close()

Close ...

func (*US100) Dist

func (u *US100) Dist() float64

Dist is to measure the distance in cm

func (*US100) DistByTTL

func (u *US100) DistByTTL() float64

DistByTTL is to measure the distance in cm

func (*US100) DistByUart

func (u *US100) DistByUart() float64

DistByUart is to measure the distance in cm

type US100Config

type US100Config struct {
	Mode  ComMode
	Trig  int8
	Echo  int8
	Dev   string
	Baud  int
	Retry int
}

US100Config ...

type VoiceDetector

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

VoiceDetector ...

func NewVoiceDetector

func NewVoiceDetector(pin uint8) *VoiceDetector

NewVoiceDetector ...

func (*VoiceDetector) Detected

func (v *VoiceDetector) Detected() bool

Detected ...

type ZE08CH2O

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

ZE08CH2O ...

func NewZE08CH2O

func NewZE08CH2O() *ZE08CH2O

NewZE08CH2O ...

func (*ZE08CH2O) Close

func (p *ZE08CH2O) Close()

Close ...

func (*ZE08CH2O) Get

func (p *ZE08CH2O) Get() (float64, error)

Get returns ch2o in mg/m3

func (*ZE08CH2O) Mock

func (p *ZE08CH2O) Mock() (float64, error)

Mock ...

Jump to

Keyboard shortcuts

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