I need some help on the ADS 1115 config register setting with i2cset and i2cget I dont understand the how to set the ads1115 to continious mode and then read it with i2cget.

There is the default setting on the config register of 0x8583 when I i2cget the config register setting its 0x8385 There is a change /swapping of the values I know its got something to do with the LSB but now I cant change the config register because I dont understand how to send the right adress to the ads1115

i get

# i2cget -y 0 0x49 1 w

I want to read all four channels and am aware I must set config register for each channel I know I must set MUX for each channel but the problem I am having is converting the binary 16 bit to a hex that the ADS will understand from another forum I got

# i2cget -y 0 0x49 1 w

The LSB is first, so this is equivalent to 0b1000010110000011

I'd like to do a single-ended conversion on AIN0, so I need to write bits[14:12] as 0b100. ie 0b1100010110000011

# i2cset -y 0 0x49 1 0xC385 w
# i2cget -y 0 0x49 0 w

The LSB is first, so this is equal to 2979 decimal

courtesy John La Rooy"

How is 0x8385 equivalent to 0b1000010110000011 Hex calculator gives 0x8583 Have they swopped the two around How is 0b1100010110000011 equivalent to 0xC385

bin to hex calculator gives 0xc583

as you con see I am confused with the LSB first to convert to hex

Please help noob The ads1115 is working fine can read it with the above commands when to gnd and 3,3v conversion from the The conversion from the conversion reg I seems to have the same misunderstanding wrt


The LSB is first, so this is equal to 2979 decimal

how do you get from 0xa30b I know 2979 is once again it swopped around 0xba3

Please help with my misunderstanding ( Im a noob)

  • Unless you give clear information about what you are doing we can not help. – joan Jan 27 '17 at 9:37
  • I am trying to write to the config register of the ads1115 – Kallie Jan 27 '17 at 10:13
  • I cant get it write to understand why you need to swop the hex numbers aroung – Kallie Jan 27 '17 at 10:14
  • When you read the config registe at startup it should be 0x8583 but its 0x8385 with I2cget -y 1 0 0x49 1 w why is the hex number swopped around? – Kallie Jan 27 '17 at 10:16
  • I presume its got something to do with the LSb but I dont understand how it works – Kallie Jan 27 '17 at 10:17

So here is the answer to my own Question

When Pi returns the value from a register on the ads1115 it gives the LSB first Thus the reason for 8385 being returned in stead of 8583 as per datasheet The conversion done by the poster of the one I am quoting made a mistake in his conversion of the Binary number which should be 0xc583 (* not c385) this caused my confusion After much surfing and learning I now know how to convert the turned around hex number to the correct value ( called little endian - they eat their eggs from the little side)

$hex1 = "a30b";
$a1 = implode('', array_reverse(str_split($hex1, 2))); echo ($a1);

but now its a string and I want a decimal

$a2 = hexdec($a1);

$a2 = 2979

PHP by the way

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.