9.12 Arduino Sensors

9.12.1 arduinosensor.DS1307

: arduinosensor.DS1307

DS1307 realtime clock sensor

Methods

: obj = DS1307(arObj)
: obj = DS1307(arObj, propertyname, propertyvalue ....)

Constructor to create DS1307 sensor

Inputs

arObj - the arduino parent object

propertyname, propertyvalue - optional property name, value pairs. Current known properties are: Current properties are:

i2caddress

I2C address of the DS1307 (default 0x68)

Outputs

obj - created DS1307 object

Example

 
 a = arduino()
 rtc = arduinosensor.DS1307(a)
 
 
: date = clock(dsObj)
: clock(dsObj, date)

Get/set the DS1307 clock

Inputs

dsObj - the ds1307 object

date - a date vector in same format as datevec and clock

Outputs

date - a date vector in same format as datevec and clock

Example

 
 a = arduino()
 rtc = arduinosensor.DS1307(a)
 # get and display rtc time as a date string
 datestr(rtc.clock)
 
 

See also: datevec.

: ctrl = control(dsObj)
: control(dsObj, ctrl)

Get/set the DS1307 clock

Inputs

dsObj - the ds1307 object

ctrl - a structure containing the control bit fields.

Outputs

ctrl - a structure containing the control bit fields.

Control structure fields are: Current properties are:

out

Out bit in the control register

sqwe

Square wave enable bit in control register

rs

The combined RS0, RS1 value

: YN = isstarted(dsObj)

Get whether the RTC clock is currently counting time

Inputs

dsObj - the ds1307 object

Outputs

YN - returns true if the RTC is counting

See also: start, stop.

: start(dsObj)

Start the RTC counting

Inputs

dsObj - the ds1307 object

Outputs

None

See also: datevec.

: stop(dsObj)

Stop the RTC counting

Inputs

dsObj - the ds1307 object

Outputs

None

See also: datevec.

9.12.2 arduinosensor.GUVAS12SD

: arduinosensor.GUVAS12SD

A thin wrapper for the GUVAS12SD analog UV-B sensor

Methods

: obj = GUVAS12SD(arObj, pin)

Constructor to create GUVAS12SD sensor

Inputs

arObj - the arduino parent object

pin - the analog pin that the sensor is connected to

Outputs

obj - created GUVAS12SD object

Example

 
 a = arduino()
 # create sensor attached to pin a0.
 sensor = arduinosensor.GUVAS12SD(a, "a0")
 
 
: V = read(dsObj)

Read the voltage of the sensor

Inputs

dsObj - the GUVAS12SD object

Outputs

V - read voltage - effectively equivalent to readAnalogPin(arObj, pin).

Example

 
 a = arduino()
 s = arduinosensor.GUVAS12SD(a)
 # voltage
 volts = s.read
 
 

See also: arduinosensor.GUVAS12SD.

: Idx = readIndex(dsObj)

Read the UV index

Inputs

dsObj - the GUVAS12SD object

Outputs

Idx - the sensor reading as a UV index reading

: uA = readuA(dsObj)

Read the uA of the sensor

Inputs

dsObj - the GUVAS12SD object

Outputs

uA - the sensor reading as a uAmp value

9.12.3 arduinosensor.MPC3002

: arduinosensor.MPC3002

MCP3002 ADC sensor

Methods

: obj = MPC3002(arObj, selectPin)
: obj = MPC3002(arObj, selectPin, propertyname, propertyvalue ....)

Constructor to create MPC3002 sensor

Inputs

arObj - the arduino parent object

selectPin - the SPI cs select pin

propertyname, propertyvalue - optional property name, value pairs.

Current properties are:

referenceVoltage

Reference voltage for scaling the ADC inputs (default 5.0)

Outputs

obj - created MCP3002 object

Example

 
 a = arduino()
 sensor = arduinosensor.MPC3002(a, "d10")
 
 
: voltage = readVoltage(dsObj, chan)

Read the voltage from a channel

Inputs

dsObj - the MPC3002 object

chan - the channel to read (0 or 1)

Outputs

voltage - read voltage.

Example

 
 a = arduino()
 s = arduinosensor.MPC3002(a, "d10")
 volts = readVoltage(s, 0)
 
 

See also: arduinosensor.MPC3002.

9.12.4 arduinosensor.SI7021

: arduinosensor.SI7021

SI7021 temperature and humidity sensor

Methods

: obj = SI7021(arObj)
: obj = SI7021(arObj, propertyname, propertyvalue ....)

Constructor to create SI7021 sensor

Inputs

arObj - the arduino parent object

propertyname, propertyvalue - optional property name, value pairs. Current known properties are: Current properties are:

i2caddress

I2C address of the SI7021 (default 0x40)

Outputs

obj - created SI7020 object

Example

 
 a = arduino()
 sensor = arduinosensor.SI7021(a)
 
 
: C = temperature(dsObj)

Read the temperature

Inputs

dsObj - the si7021 object

Outputs

C - read temperature in deg C.

Example

 
 a = arduino()
 s = arduinosensor.SI7021(a)
 # get temp
 temp = s.temperature
 
 

See also: arduinosensor.SI7021.

: relH = humidity(dsObj)

Read the relative humidity

Inputs

dsObj - the si7021 object

Outputs

relH - relative humidity as a percentage (0 - 100.0)

: relH = info(dsObj)

Read the sensor info

Inputs

dsObj - the si7021 object

Outputs

inf - structure containing the sensor information.

Structure fields are:

version

Chip firmware version

id

sensor id1,id2 value

type

String for detected chip type


Next: Arduino I/O package, Previous: Arduino Addons, Up: Function Reference   [Contents][Index]