Example Code for Intel Joule-Analog Read
Last revision 2026/01/24
This article explains how to read analog values using Intel Joule and the Gravity sensor kit, detailing hardware setup, wiring diagrams, and sample code for periodic readings using the MRAA library.
Hardware Preparation
Find the "Gravity:Analog Rotation Potentiometer Sensor V1 For Arduino" module in the "Gravity Sensor kit for Intel Joule" and connect to Analog pin 0 as the hardware connection showed above.
Software Preparation
Refer to Blink a LED example for software preparation. For this demo, we assume that you have successfully finished the blink demo above.
Wiring Diagram

Sample Code
Run the following code to get the analog result. JS+MRAA check version, I2C read ADS1115 A0 analog value periodically
var mraa = require('mraa');
var version = mraa.getVersion();
if (version >= 'v0.6.1') {
console.log('mraa version (' version ') ok');
}
else {
console.log('mraa version(' version ') is old - this code may not work')
}
var ads1115 = new mraa.I2c(0);
//A0~A3
ads1115.address(0x48)
//A4~A7
// ads1115.address(0x49)
setInterval(function(){
//A0 if i2c address is 0x48
//A4 if i2c address is 0x49
ads1115.writeWordReg(1, 0x83C1);
//A1 if i2c address is 0x48
//A5 if i2c address is 0x49
// ads1115.writeWordReg(1, 0x83D1);
//A2 if i2c address is 0x48
//A6 if i2c address is 0x49
// ads1115.writeWordReg(1, 0x83E1);
//A3 if i2c address is 0x48
//A7 if i2c address is 0x49
// ads1115.writeWordReg(1, 0x83F1);
var raw = ads1115.readWordReg(0);
var analogValue = ((raw&0xff00)>>8) ((raw&0x00ff)<<8);
console.log(analogValue);
}, 200);
Result
Print MRAA version state, output ADS1115 A0 value every 200ms.
Was this article helpful?
