This website is available for multi language.

Document

obnizのハードウェアやクラウドの仕様や特徴について


i2c

available only i2c0

request: init_master

internal pull-up is available. But, We recommend use external pull-up resistor.

path type conditions description
i2cX.mode string
  • required
  • const "master"
 
i2cX.sda pinSetting
  • required
 
i2cX.scl pinSetting
  • required
 
i2cX.clock integer
  • required
  • 1 ≤ value ≤ 1000000
frequency (Hz) 
// Json Example
[
    {
        "i2c0": {
            "mode": "master",
            "sda": 0,
            "scl": 1,
            "clock": 500000
        }
    }
]

request: init_slave

Related item

path type conditions description
i2cX.mode string
  • required
  • enum
    • "master"
    • "slave"
 
i2cX.sda pinSetting
  • required
 
i2cX.scl pinSetting
  • required
 
i2cX.slave_address integer
  • required
  • 0 ≤ value ≤ 1023
 
i2cX.slave_address_length integer
  • default 7
  • const 7
 
i2cX.address integer
  • 0 ≤ value ≤ 1023
 
i2cX.address_bits integer
  • default 7
  • const 7
 
i2cX.data dataArray    
i2cX.read integer
  • 0 ≤ value
 
// Json Example
[
    {
        "i2c0": {
            "mode": "master",
            "sda": 0,
            "scl": 1,
            "slave_address": 511,
            "slave_address_length": 7,
            "address": 511,
            "address_bits": 7,
            "data": [16, 34, 242],
            "read": 500
        }
    }
]

request: write

if address over 0b01111111; then address treated as 10bit address automatically. or specify address_bits: 10 to force 10bit address mode.

path type conditions description
i2cX.address integer
  • required
  • 0 ≤ value ≤ 1023
 
i2cX.address_bits integer
  • default 7
  • const 7
 
i2cX.data dataArray1024
  • required
 
// Json Example
[
    {
        "i2c0": {
            "address": 511,
            "address_bits": 7,
            "data": [100, 255, 21, 0, 21]
        }
    }
]

request: read

if address over 0b01111111; then address treated as 10bit address automatically. or specify address_bits: 10 to force 10bit address mode.

Related item

path type conditions description
i2cX.address integer
  • required
  • 0 ≤ value ≤ 1023
 
i2cX.address_bits integer
  • default 7
  • const 7
 
i2cX.read integer
  • required
  • 0 ≤ value ≤ 1024
 
// Json Example
[
    {
        "i2c0": {
            "address": 511,
            "address_bits": 7,
            "read": 512
        }
    }
]

request: deinit

path type conditions description
i2cX null
  • required
 
// Json Example
[
    {
        "i2c0": null
    }
]

response: master

path type conditions description
i2cX.mode string
  • required
  • const "master"
 
i2cX.address integer
  • required
  • 0 ≤ value ≤ 1023
 
i2cX.data dataArray
  • required
 
//Response Example
[
    {
        "i2c0": {
            "mode": "master",
            "address": 511,
            "data": [16, 34, 242]
        }
    }
]

response: slave

path type conditions description
i2cX.mode string
  • required
  • const "slave"
 
i2cX.address integer
  • required
  • 0 ≤ value ≤ 1023
 
i2cX.is_fragmented boolean
  • required
 
i2cX.data dataArray
  • required
 
//Response Example
[
    {
        "i2c0": {
            "mode": "slave",
            "address": 511,
            "is_fragmented": true,
            "data": [16, 34, 242]
        }
    }
]

type defines

dataArray

type conditions examples description
array
  • items
    • 0 ≤ value ≤ 255
  • [16, 34, 242]
  • [100, 255, 21, 0, 21]
Binary data array. 

dataArray1024

type conditions examples description
array
  • length ≤ 1024
  • items
    • 0 ≤ value ≤ 255
  • [100, 255, 21, 0, 21]
 

pinSetting

type conditions examples description
integer
  • 0 ≤ value ≤ 11
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6