Oxoscript turns into NanoPy - more infos

Sensor functions

Overview

Each Oxocard hardware has different sensors. The table shows an overview of which values are available in each case.

FunctionConnectArtwork/GalaxyScienceScience+
getButtonyesyesyesyesyes
getButtonsyesyesyesyes
getAcceleration-yesyesyes
getAccelerationXY-yesyesyes
getTemperaturewith AIR-yesyes
getHumiditywith AIR-yesyes
getHumidityAbsolutewith AIR-yesyes
getPressure--yesyes
getAmbientRGB--yesyes
getAmbientIR--yesyes
getAmbientLux--yesyes
getCO2with AIR-calculatedyes
getIAQwith AIR-yesyes
getTVOCwith AIR-yesyes
getETOH--yes-
getVOCwith AIR--yes
getVOCIndexwith AIR--yes
getNOxwith AIR--yes
getNOxIndexwith AIR--yes
getMicrophoneAmplitude--yesyes
getMicrophoneDecibel--yesyes
getMicrophoneFrequency--yesyes
getTOF8x8with ToF--yes
getTOF4x4with ToF--yes

getTOF4x4

  getTOF4x4()->int[16]

Oxocard- Science+, Connect+ToF-Cartridge only

The STMicroelectronics VL53L5CX is an 8 x 8 multi-zone time-of-flight (ToF) sensor. This allows depth images of up to 4m to be taken with a resolution of 64 pixels.

The areas of application are diverse. It can be used to scan the environment and create a 3D image, recognize gestures, measure distances or program motion detectors.

const THRESHOLD_DISTANCE = 500 # in mm

def onDraw():
    data = getTOF4x4()# reads the 64 (8x8) sensor data
    clear()
   
    for i in 16:
        distance = data[i]
            if distance < THRESHOLD_DISTANCE:
                x = 48*(i/4)
                y = 48*(i%4)
                drawRectangle(24+x, 24+y, 48, 48)
    update()
    delay(5)

getTOF8x8

  getTOF8x8()->int[64]

Oxocard- Science+, Connect+ToF-Cartridge only

The STMicroelectronics VL53L5CX is an 8 x 8 multi-zone time-of-flight (ToF) sensor. This allows depth images of up to 4m to be taken with a resolution of 64 pixels.

The areas of application are diverse. It can be used to scan the environment and generate a 3D image, recognize gestures, measure distances or program motion detectors.

const THRESHOLD_DISTANCE = 500 # in mm

def onDraw():
    data = getTOF8x8()# reads the 64 (8x8) sensor data
    clear()
    for i in 8+1:
        drawLine(24, 24+i*24, 240-24, 24+i*24)
        drawLine(24+i*24, 24, 24+i*24, 240-24)
    stroke(50,50,50)
    fill(255,0,0)
    for i in 64:
        distance = data[i]
            if distance < THRESHOLD_DISTANCE:
                x = 24*(i/8)
                y = 24*(i%8)
                drawRectangle(24+x, 24+y, 24, 24)
    update()
    delay(5)

getNOxIndex

  getNOxIndex()->float

Only Oxocard-Science+, Connect+AIR-Cartridge

Returns the current NOx index value between 0 and 500.

NOx stands for nitrogen oxide compounds, such as those produced by smoke or fire.

This card uses the high-quality and very precise Sensirion SGP41 sensor. The values are displayed within a few seconds.

Example:

def onDraw():
    v = getNOxIndex()
    print(v)
    delay(10000)

This example prints the value to the terminal every 10 seconds.

Further information on the value can be found in the data sheet.

(source)

getNOx

  getNOx()->float

Only Oxocard-Science+, Connect+AIR-Cartridge

Returns the current NOx raw value.

NOx stands for nitrogen oxide compounds, such as those produced by smoke or fire.

This card uses the high-quality and very precise Sensirion SGP41 sensor. The values are displayed within a few seconds.

Example:

def onDraw():
    v = getNOx()
    print(v)
    delay(10000)

This example prints the value to the terminal every 10 seconds.

Further information on the value can be found in the data sheet.

(source)

getVOCIndex

  getVOCIndex()->float

Only Oxocard-Science+, Connect+AIR-Cartridge

Returns the current VOC index value between 0 and 500.

VOC stands for Volatile Organic Compounds and describes the amount of gaseous and vaporous substances of organic origin in the air.

This card uses the high-quality and very precise Sensirion SGP41 sensor. The values are displayed within a few seconds.

Example:

def onDraw():
    v = getVOCIndex()
    print(v)
    delay(10000)

This example prints the value to the terminal every 10 seconds.

Further information on the value can be found in the data sheet.

(source)

getVOC

  getVOC()->float

Only Oxocard-Science+

Returns the current VOC raw value.

VOC stands for Volatile Organic Compounds and describes the amount of gaseous and vaporous substances of organic origin in the air.

This card uses the high-quality and very precise Sensirion SGP41 sensor. The values are displayed within a few seconds.

Example:

def onDraw():
    tvoc = getVOC()
    print(tvoc)
    delay(10000)

This example outputs the VOC value to the terminal every 10 seconds.

More detailed information on the value can be found in the data sheet. The manufacturer recommends the getVOCIndex function for measurements.

(source)

getHumidityAbsolute

  getHumidityAbsolute()->float

Only Oxocard-Science, Science+, Connect+AIR-Cartridge

Returns the current absolute humidity in g/m^3. This value indicates the amount of water vapor (humidity) in the air, regardless of the temperature.

The maximum absolute humidity of warm air at 30°C is about 30g of water vapor.
The maximum absolute humidity of cold air at 0°C is approx. 5 g of water vapor.

The absolute humidity was calculated using the following formula:

image (source)

getAmbientLux

  getAmbientLux()->long

Only Oxocard-Science, Science+

Returns the light intensity in lux.

Lux Areas
0.0001 Moonless, overcast night sky (starlight)
0.002 Moonless, clear night sky with air glow
0.05-0.3 Full moon on a clear night
3.4 Dark limit of civil twilight under a clear sky
20-50 Public areas with dark surroundings
50 Family living room lighting (Australia, 1998)
80 Office building corridor/toilet lighting
100 Very dark, overcast day
150 Platform of a train station
320-500 Office lighting
400 Sunrise or sunset on a clear day
1000 Day with overexposure; typical TV studio lighting
10'000–25'000 Full daylight (no direct sunlight)
32'000–100'000 Direct sunlight

getAccelerationXY

  getAccelerationXY()->vector

Same as the getAcceleration() function, but without the Z axis.

The return value is of type vector. This class contains two object variables x and y which are of type float.

v:vector
v = getAccelerationXY()

getMicrophoneFrequency

  getMicrophoneFrequency()->int

Only Oxocard-Science, Science+

Returns the currently most dominant frequency in Hz.

The frequency is calculated using the Fast Fourier Transformation (fft). Possible values are: 250Hz, 375Hz, 500Hz, …, 15375Hz

getMicrophoneDecibel

  getMicrophoneDecibel()->byte

Only Oxocard-Science, Science+

Returns the current noise level as a byte value in decibels.

The noise level is calculated based on the microphone amplitude:

noise = 20 * log10(micAmp) - 20

Example:

def onDraw():
    db = getMicrophoneDecibel()
    h = map(db, 0, 150, 0, 255)
    clear()
    fill(255,255,255)
    drawRectangle(110, 240-h, 20, 240)
    update()

This example draws a bar on the display whose height depends on the current noise level. Blow on the microphone or cover it to see the effect.

getMicrophoneAmplitude

  getMicrophoneAmplitude()->long

Only Oxocard-Science, Science+

Returns the currently most dominant microphone amplitude as a long value.

The amplitude is calculated using the Fast Fourier Transformation (fft).

Example:

def onDraw():
    amp = getMicrophoneAmplitude()
    h = map(amp, 0, 50000, 0, 255)
    clear()
    fill(255,255,255)
    drawRectangle(110, 240-h, 20, 240)
    update()

This example draws a bar on the display with a height that depends on the microphone amplitude. Blow on the microphone to see the effect.

getETOH

  getETOH()->float

Oxocard-Science only

Returns the current ETOH in ppm.

ETOH (respectively Ethanol) is a volatile, flammable, colorless liquid and belongs to the organic chemical compound.

Note that the ZMOD4410 sensor needs a warm up time of around 2 minutes. In this time -1 is returned.

Example:

def onDraw():
    etoh = getETOH()
    print(etoh)
    delay(10000)

This example prints the ETOH value every 10 seconds in the terminal.

getTVOC

  getTVOC()->float

Only Oxocard-Science, Science+

Returns the current TVOC in mg/m3.

TVOC stands for Total Volatile Organic Compounds and describes the amount of gaseous and vaporous substances of organic origin in the air.

For reference:

Value State
<0.3 Very good
0.3-1.0 Good
1.00-3.00 Medium
3.0-10.0 Bad
>10.0 Very bad

Oxocard Science: Note that the ZMOD4410 sensor requires a warm-up time of about 2 minutes. During this time, -1 is always returned.

Oxocard Science+: This card uses the high-quality and very precise Sensirion SGP41 sensor. The values are displayed within a few seconds.

Example:

def onDraw():
    tvoc = getTVOC()
    print(tvoc)
    delay(10000)

This example displays the TVOC value in the terminal every 10 seconds.

getIAQ

  getIAQ()->float

Only Oxocard-Science, Science+

Returns the current IAQ classification.

IAQ stands for Indoor Air Quality and normally assumes a value between 0 and 5:

Value Level State
≤1.99 1 Very good
2.00-2.99 2 Good
3.00-3.99 3 Medium
4.00-4.99 4 Bad
≥5.00 5 Very bad

Note that the ZMOD4410 sensor of the Science card requires a warm-up time of about 2 minutes. During this time, -1 is always returned. The Science+ card responds within a few seconds.

Example:

def onDraw():
    iaq = getIAQ()
    print(iaq)
    delay(10000)

This example displays the IAQ value in the terminal every 10 seconds.

getCO2

  getCO2()->float

Only Oxocard-Science, Science+, Connect+AIR-Cartridge

Returns the current CO2 value in ppm.

The Oxocard Science contains the ZMOD4410 sensor. This has a warm-up time of about 2 minutes. During this time, -1 is always returned. The CO2 value is not measured directly with this sensor, but with a special algorithm. The starting value is always 400ppm and changes over time. Values below 1000ppm are good and values below 800ppm are excellent. The algorithm improves the longer the measurement is taken (from several hours).

The Oxocard Science + and the AIR-Cartridge have a Sensirion sensor (SCD41). This is highly precise and delivers exact values within seconds.

Example:

def onDraw():
    co2 = getCO2()
    print(co2)
    delay(10000)

This example displays the CO2 value in the terminal every 10 seconds.

getAmbientIR

  getAmbientIR()->long

Only Oxocard-Science, Science+

Returns a number depending on the strength of the infrared radiation (value range 0 to 2^18).

As most TV remote controls communicate with infrared, these signals can be made visible with a simple program:

def onDraw():
    ir = getAmbientIR()
    clear()
    textFont(FONT_ROBOTO_32)
    drawText(10,10,ir)
    update()

getAmbientRGB

  getAmbientRGB()->color

Only Oxocard-Science, Science+

Returns the current ambient light as red, green and blue (RGB) color values. The ambient light is measured with the APDS-9251 sensor and calculated so that it fits into the 0… 255 range.

Example:

def onDraw():
    ambient:color
    ambient = getAmbientRGB()
    print("R = " + ambient.r + "; G = " + ambient.g + "; B = " + ambient.b)
    delay(5000)

This example outputs the measured RGB colors to the terminal every 5 seconds.

getPressure

  getPressure()->float

Only Oxocard-Science, Science+

Returns the current barometric pressure in mbar. The barometric pressure is measured with the MS560702BA03-50 sensor with an accuracy of ±1.5 mbar.

Example:

def onDraw():
    pres = getPressure()
    print(pres)
    delay(10000)

This example displays the measured air pressure in the terminal every 10 seconds.

getHumidity

  getHumidity()->float

Only Oxocard-Science, Science+, Connect+AIR-Cartridge

Returns the current humidity in %RH. The humidity is measured with the SHTC3 sensor with an accuracy of ±2 %RH.

As humidity sensors can generally have a significant offset, it is recommended to calibrate the offset via the Oxocard-Science settings menu.

Example:

def onDraw():
    humi = getHumidity()
    print(humi)
    delay(10000)

This example displays the measured humidity in the terminal every 10 seconds.

getTemperature

  getTemperature()->float

Only Oxocard-Science, Science+, Connect+AIR-Cartridge

Returns the current temperature as a float in °C. The temperature is measured with the SHTC3 sensor with an accuracy of ±0.2 °C.

As temperature sensors can generally have a significant offset, it is recommended to calibrate the offset via the settings menu on the Oxocard-Science.

Example:

def onDraw():
    temp = getTemperature()
    print(temp)
    delay(10000)

This example displays the measured temperature in the terminal every 10 seconds.

getAcceleration

  getAcceleration()->vector3D

Determines the current acceleration values in the three axes x,y and z. The values are in G (G ~ 9.81m/s^2). Depending on the direction, the values >0 or <0 are given.

The return value is of type vector3D. This class contains three object variables x,y, and z which are of type float.

Example:

def onDraw():
    push()
    background(0,0,0)
    stroke(255,255,255)
    v:vector3D
    v = getAcceleration()
    v1 = vector(x=v.x,y=v.y)
    v1.mulScalar(90)
    translate(120,120)
    noStroke()
    fill(100,100,100)
    drawCircle(0,0,28)
    noFill()
    stroke(255,255,255)
    drawCircle(-v1.x,v1.y,30)
    update()
    delay(50)
    pop()

This example draws a water clock. When the card is nicely aligned horizontally, the two circles are centered.

getButton

  getButton()->byte

Checks whether a button has been pressed.

0 = no button 1 = middle 2 = up 3 = right 4 = down 5 = left

b = getButton()

Only ONE button can be retrieved at a time with this function.

getButtons

  getButtons()->buttons

Checks if multiple buttons have been pressed.

The function creates an object of the class buttons.

The class has the following object variants: up, down, left, right, middle. These values all have the type “bool”, i.e. can be true or false.

This function can be used to query multiple button clicks at the same time.

def onDraw():
    background(0,0,0)
    b:buttons = getButtons()
    if b.left and b.right:
        background(255,0,0)
    update()

(The screen only lights red when left and right are pressed at the same time).