AD

AD Class Reference
AD API Reference

AD reads analog voltage applied on each io. Usage example is reading brightness from light sensor which output light level as voltage.

ad.getWait() return current voltage once like io.inputWait(). ad0 means ad for io0. Normally, ad is not available on each io. Please refer to device detail.

// Javascript Example
var voltage = await obniz.ad0.getWait();

Measurable voltage range depends on device. obniz Board series measure 0 to 5v(vcc). And

ad.start() function start monitoring and receive voltage changes.

// Javascript Example

obniz.ad0.start(function(voltage){
 console.log("changed to "+voltage+" v")
});

Frequency depends on network speed. But Maximum is 30 Samples/sec.

About obniz Board Series AD

obniz Board series has specially designed AD circuit.

AD is independent. It also works while IO is used for another function.

AD also monitors vdd of obniz Board itself(normally 5v). Each ad result will be calibrated regarding below.

obnizOS version calibration method
under 1.2 Always
1.2 or higher Only Vdd is under 4.5v