AD

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.

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.

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

Frequency depends on network speed. But Maximum is 30/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 versioncalibration method
under 1.2Always
1.2 or higherOnly Vdd is under 4.5v