Oxoscript turns into NanoPy - more infos

Sensor functions

getHumidityAbsolute

  getHumidityAbsolute()->float

Oxocard-Science only

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

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

The absolute humidity was calculated using the following formula:

image (Source)

getAmbientLux

  getAmbientLux()->long

Only Oxocard Science

Returns the light intensity in lux.

lux Surfaces
0.0001 Moonless, overcast night sky (starlight)
0.002 Moonless clear night sky with airglow
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 lights (Australia, 1998)
80 Office building hallway/toilet lighting
100 Very dark overcast day
150 Train station platforms
320–500 Office lighting
400 Sunrise or sunset on a clear day.
1000 Overcast day; typical TV studio lighting
10'000–25'000 Full daylight (not direct sun)
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

Oxocard-Science only

Returns the current 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

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

Returns the current 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

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 Poor
>10.0 Very poor

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

Example:

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

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

getIAQ

  getIAQ()->float

Oxocard-Science only

Returns the current IAQ rating.

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

Value Level Condition
≤1.99 1 Very Good
2.00–2.99 2 Good
3.00–3.99 3 Medium
4.00–4.99 4 Poor
≥5.00 5 Bad

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

The IAQ value is not directly measured but calculated with a special algorithm from Renesas.

Example:

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

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

getCO2

  getCO2()->float

Oxocard-Science only

Returns the current CO2 in ppm.

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

The CO2 value is not directly measured but calculated with a special algorithm from Renesas. The start value is always 400ppm and will change over time. Values below 1000ppm are good and values below 800ppm are excellent.

Example:

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

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

getAmbientIR

  getAmbientIR()->long

Only Oxocard Science

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

Since most remote controls of TV’s 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

Oxocard-Science only

Returns the current ambient light as red, green & blue (RGB) color values. The ambient light is measured with the APDS-9251 sensor and calculated to fit 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 prints the measured RGB colors every 5 seconds in the terminal.

getPressure

  getPressure()->float

Oxocard-Science only

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 prints the measured barometric pressure every 10 seconds in the terminal.

getHumidity

  getHumidity()->float

Oxocard-Science only

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

Since humidity sensors in general can have a significant offset, its recommended to calibrate the offset via the settings menu on the Oxocard-Science.

Example:

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

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

getTemperature

  getTemperature()->float

Oxocard-Science only

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

Since temperature sensors in general can have a significant offset, its recommended to calibrate the offset via the settings menu on the Oxocard-Science.

Example:

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

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

getAcceleration

  getAcceleration()->vector3D

Determines the current acceleration values in the three axes x,y and z. The values are in milli-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).