About a year ago, I wrote a simple library for interfacing AD7705/AD7706 with Arduino. The library works, but it requires some decent knowledge of the underlying chip, which had made it somewhat difficult to use. Most issues users reported can be resolved by adjusting the timing in user code, but I admit that it is somewhat difficult for users who are not familiar with the chip. For a library, I should have made it easier to use to begin with. So, I decided to add a few long-awaited features and hopefully these tweaks will make the library easier to use.

One of the changes to the original code is the addition of the dataReady function. This function queries the DRY bit in the communication register and returns true when the data ready bit is cleared.

bool AD770X::dataReady(byte channel) {
    setNextOperation(REG_CMM, channel, 1);

    digitalWrite(pinCS, LOW);
    byte b1 = spiTransfer(0x0);
    digitalWrite(pinCS, HIGH);

    return (b1 & 0x80) == 0x0;

Using this function, we can wait till the converted data is ready before reading out the conversion result (rather then using delay statements):

double AD770X::readADResult(byte channel, float refOffset) {
    while (!dataReady(channel)) {
    setNextOperation(REG_DATA, channel, 1);

    return readADResult() * 1.0 / 65536.0 * VRef - refOffset;

In readADResult, I added an optional parameter refOffset. If your Vref- is not tied to the ground then you can use this variable to set the offset voltage to be subtracted from the conversion result. The default operating mode is set to be bipolar. For AD7705 and AD7706, the difference between unipolar and bipolar operation is simply how the the input signal is referenced so by setting the input mode to bipolar, you can still measure unipolar voltages. All that is needed is to tie the Vref- to the ground and leave the refOffset with the default value (i.e. 0).

I have also added a reset function. By calling this function first in your setup code, you are guaranteed that the chip is brought to a known state. Some of the difficulties users faced using the original library is that, depending on how the system is powered up, the AD770x may not be in a consistent mode and thus the A/D results seemed to be random. The chip reset can be achieved by either using the RESET pin or code. In my opinion, implementing in code is the desired method unless you need highest performance possible. Another benefit is that this implementation requires one less MCU pin.

Finally, I added a few parameters to the alternative constructor. In case you want to fine-tune your setup (e.g. setup different gain/speed), you can use the alternative constructor instead.

The following example shows how to use this library to read ADC results from multiple channels:

#include <AD770X.h>

AD770X ad7706(2.5);
double v;

void setup()


void loop()
  v = ad7706.readADResult(AD770X::CHN_AIN1);

  v = ad7706.readADResult(AD770X::CHN_AIN2);
  Serial.print(" : ");

Download: AD770X1.1.tar.gz (compatible with Arduino 1.0 IDE)

Be Sociable, Share!

92 Thoughts on “AD7705/AD7706 Library Revisited”

  • Hallo Kerry D.Wong!
    It’s from Russia again :)
    Thank you for the new library! Now it is compiled into the first version of the Arduino! But I have a question, is it possible to increase the polling rate channels? Or you can tell which part of the code of your library, can I change the time delay? So I can experiment with delay …
    Thank you again! With the new library, all channels are working fine!

    • Yes, there is another constructor that takes the update rate as a parameter:

      init(byte channel, byte clkDivider, byte polarity, byte gain, byte updRate)

      and you can use the constants defined in the header to set your rates.
      static const byte UPDATE_RATE_20 = 0x0; // 20 Hz
      static const byte UPDATE_RATE_25 = 0x1; // 25 Hz
      static const byte UPDATE_RATE_100 = 0x2; // 100 Hz
      static const byte UPDATE_RATE_200 = 0x3; // 200 Hz
      static const byte UPDATE_RATE_50 = 0x4; // 50 Hz
      static const byte UPDATE_RATE_60 = 0x5; // 60 Hz
      static const byte UPDATE_RATE_250 = 0x6; // 250 Hz
      static const byte UPDATE_RATE_500 = 0x7; // 500 Hz

      The clock divider can be set accordingly based on your oscillator frequency.

  • Hello Kerry,

    Thanks for the library…very useful. I was wondering if it would be possible to use the library with an AD7715 which is pin compatible with the AD7706 but is only a single channel device. Which parts would need to be changed in order to make it work. I think the byte codes for accessing the different registers are the same??

    Thanks again


    • Thanks Alex. As you observered, AD7705 and AD7706 are almost identical. You can use the exact same code for either AD7705 and AD7706. The only change would be the interpretation of the input pin s used.

      For instance, if the channel setting is CH1=0 and CH0=0, for AD7705 AIN1+ and AIN- are used whereas for AD7706 AIN1 and COMMON are used.

      • Kerry,

        I was actually looking at using the AD7715 which is not quite the same as an AD7706 – it is very similar though but this device only has one channel not two like the AD7706. There are other differences too though, there is no clock register in the AD7715. How difficult would it be to modify the AD7706 library to work with the AD7715? Please note that my coding skill is almost zero!!



  • Kerry,

    My sincerest apologies, I have it working and it’s excellent!! I did not actually just try the library! Someday I will have to learn how to code properly and understand how libraries are written! Thank you so much for your library and your response…



    • First thanks for this library kwong!

      Alex, have you realy had success with this library and the AD7715? Because I didn’t…
      I suppose you modify it because of the difference between AD770X and the AD7715 like clock register, and channel…
      Would you offer us your modified code?
      (French man writing…)


      • Damien,

        My code used Kerry’s library without being modified. I’m not a very good programmer so I can’t be certain how it worked with the AD7715. The critical part was adding a 100ms delay to Kerry’s example code. Once I did that the device started to work. I tested it on a breadboard with minimal components as specified in the datasheet with a variable resistor to provide analogue data! It worked first time…best of Luck

        Here is my code:

        * AD770X Library
        * sample code (AD7706)
        * Kerry D. Wong
        * http://www.kerrywong.com
        * 3/2011


        AD770X ad7706(2.5f);
        unsigned int v;

        void setup()

        // ad7706.init(AD770X::CHN_AIN2);
        Serial.println(“Here we go…”);

        void loop()
        v = ad7706.readADResult(AD770X::CHN_AIN1);
        delay(100); //100ms delay for AD7715

        • Thanks Alex for replying!

          I can’t believe how it worked for you with the AD7715…
          I’ve tried you sketch, but it didn’t work for me…
          This library doesn’t work for me, but I wrote one for our AD7715.
          I didn’t spend a lot of time on, and even it seem’s to work quite
          well (thanks to kwong) there are a lots of difference between AD770X
          and AD770X…

  • Hi Kerry,
    i’m using your library for AD7705. I still don’t understand how to get data. To take data from AIN1, this is the code i use:

    #define LOOP_DELAY 120


    temp1 = ad7705.readADResult(AD770X::CHN_AIN1);
    temp2 = ad7705.readADResult(AD770X::CHN_AIN3);

    I’m working with UPDATE_RATE_60. Is there other way to get data?? If i only read AIN3 or AIN1, sometimes it doesn’t get data. Depending on the delay time (loop_delay), accuracy is higher or lower. When i read AIN1, i only have ground and i supposed that AIN1 and AIN3 should be for AIN1+/-. Why do i have to read AIN1 and AIN3 for AIN1+/-??.
    I’m working with a duemilanove ATM328.
    Thanks in advance

    • Hi Bodhi,

      You can configure the AD7705 in either differential (bipolar) or single-ended (unipolar) operation. The simple constructor you used defaults to unipolar. If you need to take differential measurement, you can use the overloaded constructor: AD770X::init(byte channel, byte clkDivider, byte polarity, byte gain, byte updRate) , you can take a look at the cpp file to see how it can be used.

      I am not sure why you need to include delay in your code though.

      • Hi kwong,
        If i don’t use the delay, sometimes it doesn’t measure anything and accuracy is lower. I have to measure thermocouples and accuracy is very important.
        I tried to use bipolar but values were wrong and the only way i could work was the one i wrote in the past post.
        Thanks for your response.

        • Hi again kwong,
          i tried to test your test program and i also need a delay. if i change the update_rate to other value different to 25 it doesn’t work, only measure 0.0000. With the gain, happens the same, measure something but out of the reality.
          I’m using a crystal of 4.000M, can this be the reason?.
          Thanks in advance

  • Hello ,

    Can you check you library for issuse :
    ad7706.init(AD770X::CHN_AIN1,AD770X::CLK_DIV_1, AD770X::BIPOLAR, AD770X::GAIN_4, AD770X::UPDATE_RATE_25);

    Init must setup CHN_AIN1 , but it sets CHN_AIN2 … The same with AIN2. This settings must be swaped.

  • Greetings!
    I will try to connect AD7705 to the arduino Leonardo. The question is, in the datasheet used DRDY. It is also connected to the arduino or leave free? Also the datasheet CS goes to the ground, and you have it connected to the arduino.
    Sorry for the horrible English. I’m from Ukraine.

    • Hi Bogdan,

      DRDY can either be read from the register or from the pin. The method I used was reading from the register and thus the pin is left unused. The CS pin is used in the SPI protocol and is controlled within the SPI library.

  • Hello! This again I am! Another question: what is the face value of capacitors that connect to ground quartz? I understand that stupid question, but thanks for the answer!)

    • I used a 2MHz ceramic oscillator so the caps were not used. But can also use a crystal with 2 load capacitors. The value varies based on the crystal you choose, but anything between 18pF and 33pF will work.

      • Hi! One more question on the library. I’m using the Arduino Leonardo. It SPI pins are different from UNO. For normal operation of A can change them in the file library?Thanks for the fast reply!

  • I have a quick question, I’m using the AD7705 with the arduino mega 2560 chip. I modified the header file to use the correct pins for the mega 2560: MISO(pin 50), MOSI(pin 51), and SCK(pin 52). I also set pinCS to pin 24 (since that is what the AD7705 CS pin is connected to) and I setup pin 10 to be a 2 MHz clock (using timers) to go into MCLK IN since I don’t have a crystal. My current issue is that I will only get values equal to 0 or whatever I pass in as the reference voltage. If I pass 2.5 as my reference voltage then my output randomly alternates between 0 and 2.5, if I pass in 5, then it flips between 0 and 5. So could this be an issue with the chip or is this an issue because I’m using the mega 2560?

    • Hard to tell… the first thing I’d do is short the input (or provide a steady voltage) of the ADC and see how the output behave. AD7705/06 does have a minimum recommended clock frequency of 4MHz so not sure if it would work with a 2MHz clock.

      • Right now I have the AD7705 connected to a simple voltage divider across a 10k pot, if I plug the input into ground or if I pull the input high the data coming in is still 0.00. I setup a 4 MHz clock and my serial output to my screen stopped altogether, any ideas?

        • Sorry, my bad. AD7705’s minimum operating freq is 400kHz not 4MHz so 2MHz should be fine (and that’s the clock frequency I was using). Could you try a reset() immediately before reading the ADC value? Also, could you add a small delay (e.g. delay(10)) before reading the ADC to see if you observe any difference?

          • Currently I have a 500ms delay in my loop between readings, I tried the reset just before reading the ADC value and still nothing. At this point I’m inclined to think that I may have a bad chip

          • Kwong,

            Firstly I’d like to thank you for putting together this library, I was wondering if you could help me with a problem I’ve got.

            I am in the exact same boat as drewman2000; I’m on a Mega2560, have altered the header file for the Mega pins (50-52), using pin 10 as a 2MHz clock with the AIN connected to a 50k pot and all I get out is 0.00 with about a ~100ms delay between readings. I’ve tried adding the small delay and also the reset but neither work, do you have any ideas?

            Is it also normal that it should take about 2-3 mins to complete the setup routine and start giving readings back?

            Separately, is it possible to read the analog input as a decimal number rather than as a voltage?


          • Assuming you are using the revisited library querying the DRY bit instead of using delays. Since I don’t have an Arduino mega board I can’t test for sure, but something is definitely not right.

            It shouldn’t take that long to get the initial reading, and the only way it could take that long is the dataReady function keeps returning “false”. In this case the readADResult function would be in a wait loop.

            Could you try using a crystal oscillator instead of clock generated via Mega? Although it really shouldn’t matter.

  • Hi kwong,
    i tried to operate your code program and i read H1= 0.0 H2=0.0 H1=0.0 H2=0.0 i can not reading Anything !!!!!!!!!!!!!!!


    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
    //set reference voltage to 2.5 V
    AD770X ad7705(2.5);
    float v1;
    float v2;
    float H1;
    float H2;
    void setup()
    //initializes channel 1
    //initializes channel 2
    lcd.begin(16, 2);
    void loop()
    //read the converted results (in volts)
    v1 = ad7705.readADResult(AD770X::CHN_AIN1);
    //read the converted results (in volts)
    v2 = ad7705.readADResult(AD770X::CHN_AIN2);
    H1 =(v1*1);
    H2 =(v2*1);

    lcd.print( H1);
    unsigned int data=0;

    • You must place before AD7705 initialisation this: void AD770X::reset() Input shift register of AD7705 must be in known state before initialisation and communicating.

      2Keryy: reset routine simplified:

      void AD770X::reset() {
      digitalWrite(pinCS, LOW);
      digitalWrite(pinCS, HIGH);

      I use cheap TM7705 modules from ebay. After corrrect interface reset this fake chips work fine.

  • Hello Brother,
    Your library is the only thing that I got to get my work done,Actually I am Building a Data Logger so I need to port this code to ATMEGA 32 Mcu But I am could not do this,Is there any way that this library can be ported to a Off the market Atmega32 Mcu.
    Thanks a lot for your work

  • Thank you very much for the AD770X library!
    Is it possible to use pins other than 11, 12, 13 for MOSI/MISO/SCK?
    I am asking because two of my devices do not seem to be compatible with each other (they work well independently with the Arduino), and I have extra digital lines available. I did not see a reference to SPI.h in your library and example, so I am hoping this is possible. Thanks again.

    • For ATMega328/or 328p those pins are fixed for SPI as this is a hardware function. But if you implement the SPI protocol on your own, you can use pretty much any pins.

  • Hi to to all,

    I’m using the AD7705 and i found this lib very helpful, thanks a lot!

    i just have quite a problem on the measuring:
    i have connected to the GND the ai1(-)
    i’m giving to the ai2(+) a known voltage from the arduino (voltage that i also measure with the multimeter)
    The configuration is exactly the one shown in the scheme by kerry wong.

    when i run the program, i get from the ad7705 a value lower than the one i expect, for example:

    if i set 1 V from the arduino, i measure 1.00V with the multimeter, but i get 0.95V on the AD7705.
    if i set 2 V from the arduino, i measure 2.00V with the multimeter, but i get 1.92V on the AD7705.

    it seems like i have a gain problem (i set a gain og 1 btw), because the ratio voltge_expected/volytage_measured=1.045 ish, which is averagely constat.

    Can it be a calibration problem? or am i making some stupid mistake? or is the IC broken?

    hope someone can help me,

  • Dear Kwong,
    Thanks a lot for your library it works fine when i connect a potentiometer to the channel where the middle pin is connected to the +ve In and -ve In is connected to ground , now when i try to enter a sine wave as an input i get very unreasonable values , I’ve tried both making an offset so that the value of the input is between 0 and 1V for example or without offsite such that the input would vary between -50 and +50 mV (because it is said in the data sheet that there won’t be correct readings below -100 mV) do u have any ideas where the problem could be ?!

    Best regards,

  • A question for anyone using the cheap boards off eBay that use the TM7705 chip (supposedly AD7705 compatible).

    I’m using both inputs, and when I do, the data from AIN1 data comes out when I request data from AIN2 and the data from AIN2 come out when I request data from AIN1.

    However when I use just AIN1 by itself, reading data from AIN1 works as expected, but when using only AIN2, the data can only be read by reading AIN1.

    Does the real AD7705 exhibit this behavior or this is probably just a problem because the chip is (probably) a Chinese knock off?


    • Hi, Jeff.

      I am using TM7705 module with Arduino MEGA 2560 board, the input is unipolar, both AIN1(-) and AIN2(-) connect to GND. But I ran into a similar situation as you mentioned above. I do not have any infomation about the usage of TM7705 module. Have you made any progress on sovling the problem?

      Based on MEGA 2560 schematic the pin connections are:
      MISO(50), MOSI(51), SCK(50) and CS(53)


    • Wondering how you got data from the tm7705 chip. perhaps you could send me a picture or schematic of your wiring and the code you used. I cannot figure out how to get data using the example code. my email is koryherber@gmail.com Thanks!

  • Hello Kwong!
    I have a module with AD 7705.
    It has AD 7705 and reference voltage of 2.5 V. I connect it to the Arduino Uno with your library. I connect outputs in accordance with the protocol library SPI. I use a simple sketch of an example for testing. On the input AIN 1, I tried to connect the various signal sources (electret microphone, temperature sensor, battery 1.5 V). All values displayed in the serial monitor – zero. Help me to understand, Why it’s not working?

  • Thank you Wong. Your library is very useful.
    I am also having problems with the module described by Amir (AD7705 Dual 16 bit ADC Data Acquisition Module Input Gain Programmable SPI Interface TM7705 ). I have changed the the bit CLK to account for the crystal of 4 MHz but still doesn’t work. It seems the module has some sort of hardware problem.
    Does anyone had success using the module 7705?

  • Hi,

    I am having compilation errors when using the program with the DUE. It has to do with the library. Has anybody made it work with a DUE? what modifications to the library are necessary? thank you

  • Since it was not working for the DUE I have tryed first with the UNO. It compiles correctly but all my readings are 0 (except for some which seem like noise). Has anyone had a similar problem? Any help? ty

    • Hi Jorge,

      A lot of people seemed to have similar issues like what you were having. I am not entire sure whether there was some slight change in the chip or what. The ones I developed my code with are all working fine… So unless I can get a sample of the ones that people are having trouble with, I am not quite sure what’s going on.

    • Hi Mark, how did you manage to make it work? Can you please tell us, I am desperately facing the same issue of other users…

  • Hi Kerry,
    I’m building an Arduino musical instrument, and I’m using your library and the AD7705.
    Will it be OK to publish the code, including your library, as a blog post or as an instructable?
    I’m asking because I couldn’t find a license reference in the code.

      • Thanks for your reply!

        I sure hope it will work out. I’ve been using the AD7705 to get a precise reading of a 10-turn potentiometer, and it worked perfectly fine, until I added a LCD+keypad shield (DFRobot). For some reason, when I connect both the LCD and the ADC, the ADC hangs. I’ve checked to see if I fried the hardware or something like that, checked if the pinout matches, and most everything else that came to my mind. Nothing works so far, which is very frustrating. If you have some insight on how to get this to work, I would sure like to know.

        Thank you very much,

  • For anyone using the TM7705 red boards of ebay.

    I had a lot of issues getting mine going until I attached 5v to the reset pin. I’m not great at reading wiring diagrams but I thought that it was already connected, but it wasn’t.

    I get readings from a pot using the default code above on Arduino uno with the tm7705 above and the Pot connected to 5v, ain+, ain-.

    it reads up until 2.5v.

    if you touch a wire to ain- and the REFIN+ (The fourth pin from the dot(ground) on the ad7705 chip), you get readings from 0-5v.

  • I have a question for Kerry D Wong. (Thanks so much for this library, its so great that you did all the work and than shared it!)

    I am trying to get a reading from an RTD sensor on the board. While I would love your help with that too my actual question is:

    To get a bipolar reading, do I need to read ain+ and ain- (by putting ad7705.readADResult(AD770X::CHN_COMM)). Or is that a question that would not even make sense if I knew more aobut electronics?

    (I ask because when I read Ain+ with the REF as the agitation for the RTD, I only get the agitation value (2.5) as a reading)

    Thanks for all your help in both writing this library and then reviewing it to make it easier :)!

    • Hi, to use bipolar mode with AD7705, you need to call the overloaded initialization function (definition below):

      void AD770X::init(byte channel, byte clkDivider, byte polarity, byte gain, byte updRate)

      and passing in AD770x::BIPOLAR into the polarity variable.

      Also, in bipolar mode, the measurable range between ain+ and ain- is between -2.5V to 2.5V if the reference is 2.5V.

  • Thanks for the great library, but im not able to get correct values on the ouptut, it is always the same even if i change the input voltage, my module is the red from ebay i also tried connecting reset pin to 5v but nothing changes.

  • Hi Kerry,
    i´m quite desperate to bring AD7706 alive. Im using uno board with AT328, all wires are connected correctly and still i cant get nothing but 0.00 in serial monitor. Would you be so kind and give me an advice how to fix it. It looks like AD7006 doesnt comunicate with uC.

    Thanks for reply

  • Ps. I also use the red one from eBay connected on an pi and it work, even without connected the reset pin.it has a vref = 2.5v.

  • Dear Kerry!
    In file AD7705.h we see:
    static const byte UNIPOLAR = 0x0;
    static const byte BIPOLAR = 0x1;

    In datasheet DOC000143693.pdf page 12
    B/U Bipolar/Unipolar Operation. A “0” in this bit selects Bipolar Operation. A “1” in this bit selects Unipolar Operation.

    Where is the mistake?

  • Severals errors:
    1. in AD770x.h
    static const byte UNIPOLAR = 0x0; // MUST BE 0X1
    static const byte BIPOLAR = 0x1; // MUST BE 0X0
    static const byte CLK_DIV_1 = 0x1; // MUST BE 0x00
    static const byte CLK_DIV_2 = 0x2; // MUST BE 0x01

    • Thanks Roman for your reply. However, I still have some issues and my readings are always zero. I think I have figured out a problem: while using the scope for the DRDY pin I noticed that it does not go LOW.

  • Hi kerry,
    thanks for you library. it is realy promising.
    ıf ı change

    AD770X ad7706(2.5);
    double v;
    AD770X ad7706(2.5);
    double v1,v2;

    the outputs fluctuate randomly. Both channel can be read easiliy however two channel give unexpected outcome.
    could you comment on that? And do we need to change (as Roman said)?
    static const byte UNIPOLAR = 0x0; // MUST BE 0X1
    static const byte BIPOLAR = 0x1; // MUST BE 0X0
    thanks a lot.

  • Hi. In the monitor serial see. Why?
    0.00 : 0.00
    0.00 : 0.00
    0.00 : 0.00
    0.00 : 0.00
    0.00 : 0.00
    0.00 : 0.00
    0.00 : 0.00

  • Hello Sir

    Thank you for the library.
    I wanted to know weather this code will run in Arudino Due.
    can you please do tell me what can be the code to interface AD7705 in Arudino Due.


  • Hello everybody
    first of all thanks for the lib.
    I have problem with AC7705 conversion. my sketch is the following.


    AD770X ad7705(65536);
    unsigned int ADCValue1;
    unsigned int ADCValue2;

    void setup() {
    // Open serial communications and wait for port to open:
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

    ad7705.init(AD770X::CHN_AIN1,AD770X::CLK_DIV_1, AD770X::BIPOLAR, AD770X::GAIN_1, AD770X::UPDATE_RATE_25);
    ad7705.init(AD770X::CHN_AIN2,AD770X::CLK_DIV_1, AD770X::BIPOLAR, AD770X::GAIN_1, AD770X::UPDATE_RATE_25);

    void loop() {

    ADCValue1 = ad7705.readADResult(AD770X::CHN_AIN1);
    ADCValue2 = ad7705.readADResult(AD770X::CHN_AIN2);

    Serial.print(“AD7705 analog 16bit input 1: “);

    Serial.print(“AD7705 analog 16bit input 2: “);



    but the serial output still zero forever.
    AD7705 analog 16bit input 1: 0
    AD7705 analog 16bit input 2: 0

    AD7705 analog 16bit input 1: 0
    AD7705 analog 16bit input 2: 0

    even if i put 3 volt at the input.
    somebody can help me?

    • Hey Miki

      I’ve also been there, so in my case what worked was to pull up the rst pin of the ADC using a pullup resistor.
      First, your line does not look good to me “AD770X ad7705(65536);”
      you might want to provide the ref voltage like so:

      AD770X ad7705(2.5);

      Second, you must expect double values from readResult, not unsigned int


  • Dear,
    Please note that I had a reading problem with the AD7705 (DRDY never going to level Zero).

    Board with PIC16F690 XTAL @8 MHz, PortC Driving all ADC pins.
    Programming with MikroBasic v7 Pro and Pickit2.
    Driving AD7705 pins with own software and simple functions (not really SPI protocol).

    I noted that “reading” was subject to setting, when reading datas, the AD7705 Din input … MUST be set to level ONE !

    I Don’t understand why ( possibly inputting command while reading ?) but it WORKED really !
    All is now OK !
    Perhaps some solution to others softwares and users.

    If you are interrested for all users, please give me your e-mail where I can send my software (test).


  • Hello everyone, tried to use the library from Kerry Dwong with the TM7705 chip from Ebay (red breakboard), link: https://www.sunrom.com/p/adc-board-dual-16-bit-spi-ad7705tm7705. It has a reference voltage of 2.5V and a oscillator the matches the requirement stated in the AD7705 datasheet.

    I Have rewritten the library from Kerry Dwong for the AD7705, and now added SPI lib to it, so it can be used for all type of controllers. The library can be found here: https://github.com/DanSTAR-DTU/Flight-Controller-mark-1-Margit/tree/master/Margit/AD770X/Libraries/DanSTAR_AD770X. Enjoy it :)

    However, I am like everyone else getting readings of only zeroes. I want to know if anyone else has solved this problem, and if so how? Furthermore is there a chance that I can get a look into the library you used/made to understand how you made it work with the TM7705 version? Also how did you guys connect the breakboard with arduino controller and to what ever sensor you are using – I am using a load cell.

    My connections to arduino due and load cell:

    For Arduino due and TM7705:
    GND -> GND
    VCC -> 5V
    RST -> 5V or nothing (as you can see in the circuit diagram)
    CS -> pin 10
    SCK -> pin 76
    DIN -> pin 75
    DOUT -> pin 74
    DRDY -> Nothing, since i am using the internal resistor.

    For load cell and TM7705:
    AIN1 + -> Output data
    AIN1 – -> Output data
    The two left wires coming from the load cell goes to GND and 5V for excitation.

    If you look into my library you can see that I am using SPI_MODE = 3. I am not sure if that us correct, but i think so since it states that in the sample code in the datasheet.
    Furthermore I am using Unipolar mode which I think is the correct mode, though not sure?

    Please if you find any mistakes in the library, do tell me so I can correct it :)

    Hope you guys have an answer for my questions :)

    • Hello
      Please … I Don’t know very well C language and how is written SPI library … I am only a Mikroe Basic language writer.

      Verify that before reading datas … the DIN of AD7705 is SET … DIN=1
      In my program, DIN of AD7705 is connected to Spi_SDO output of my board with PIC16F690 minimum system …

      Here are the définitions of my SPI pins for PIC16F690.

      dim Chip_Select as sbit at RC0_bit
      Spi_DRDY as sbit at RC1_bit
      Spi_RST as sbit at RC2_bit
      Spi_CLK as sbit at RC3_bit
      Spi_SDI as sbit at RC4_bit // connected to Dout AD7705
      Spi_SDO as sbit at RC5_bit // connected to Din AD7705

      dim Chip_Select_Direction as sbit at TRISC0_bit
      Spi_DRDY_Direction as sbit at TRISC1_bit
      Spi_RST_Direction as sbit at TRISC2_bit
      Spi_CLK_Direction as sbit at TRISC3_bit
      Spi_SDI_Direction as sbit at TRISC4_bit // =1 so Spi_SDI is an input connected to AD7705 Dout output
      Spi_SDO_Direction as sbit at TRISC5_bit // =0 so Spi_SDO is an output connected to AD7705 Din input.

      So Spi_SDO is an output … and I had to make Spi_SDO = 1 –> Din = 1 before reading datas of AD7705.
      If Spi_SDO = 0 … then I only read 0000 !

      See the changes …
      Spi_SDO = 1 The last column is the mean of the first 8 samples
      (speed = ~ 100 samples /second, turning slowly input voltage with pot 10 turns)

      8BD7 8B90 8B46 8B03 8AC4 8A85 8A46 8A06 00008AE9
      89C4 8982 893C 88FA 88BB 887F 8848 8813 000088E2
      87E3 87B9 8792 876E 874C 872C 870C 86EC 00008761
      86CC 86A9 8684 865F 8638 8615 85F7 85E0 0000864F
      85CC 85BD 85B2 85A6 859E 8599 8598 8597 000085A9
      8596 8597 8596 8595 8595 8593 8591 8592 00008594
      8595 8599 859D 85A6 85B5 85C8 85DE 85F8 000085B8
      8612 862A 8643 865D 8675 868B 86A3 86BF 00008668

      Spi_SDO = 0
      2000 2000 2000 2000 2000 2000 2000 2000 00002000
      2000 2000 2000 2000 2000 2000 2000 2000 00002000
      2000 2000 2000 2000 2000 2000 2000 2000 00002000
      2000 2000 2000 2000 2000 2000 2000 2000 00002000
      2000 2000 2000 2000 2000 2000 2000 2000 00002000
      2000 2000 2000 2000 2000 2000 2000 2000 00002000
      2000 2000 2000 2000 2000 2000 2000 2000 00002000

      I hope this can help you …
      Best Regards to everyone

  • Hello I have connect an AD7705 on an Arduino Mega, I have modified the librarie like this:

    static const int pinMOSI = 51; //MOSI
    static const int pinMISO = 50; //MISO
    static const int pinSPIClock = 52; //SCK
    static const int pinCS = 53; //CS

    And I’m using this sketch:


    AD770X ad7705(2.5);
    double v;

    void setup()


    void loop()
    v = ad7705.readADResult(AD770X::CHN_AIN1);

    v = ad7705.readADResult(AD770X::CHN_AIN2);
    Serial.print(” : “);

    But I read only 0.0 in both channel
    Where am I doing wrong?

    • Please make MOSI (pin output) = 1 before reading.
      So AD7705 Din (input) = 1 !

      Just verify that it remains 1 when calling your reading routine !

      See my above remark …

  • hi everyone,

    I have some difficulties in the library. The first one is about the sample code shared by Kerry. He uses the gain factor as 4 to read the channel without gain. I think there should GAIN:1 to gainless read. Could someone clarify this?

    The second issue about changing Vref value. Could someone post a working code piece shoeing how Vref can be manupulated?
    The third issue is about getting RAWADC Result, that is, Integer form of ADCRESULT? I could not get it?
    Thanks in advance.

    Thank you Kerry for your effort. MAybe there will be updated version of the library Idont know.

  • Hello Mr. Wong and others in this discussion. I also have the red module with the TM7705 chip and I have also had problems with the channel readings using your library. I noticed that on the board there is a 4.9152MHz crystal, but in your library there is no way to select this clock frequency. I see that in the library there is a command for this:
    “writeClockRegister (byte CLKDIS, byte CLKDIV, byte outputUpdateRate)”
    That assembles the byte of the Clock Register like this:
    “// 7 6 5 4 3 2 1 0
    // ZERO (0) ZERO (0) ZERO (0) CLKDIS (0) CLKDIV (0) CLK (1) FS1 (0) FS0 (1) ”
    There is no option to select the value of CLKDIS, and the options for CLKDIV are 0x1 (in binary, 1) and 0x2 (in binary, 10), that is, it seems to me that the values for CLK_DIV_1 and CLK_DIV_2 should be 0x0 and 0x1 . Or am I wrong?
    How could we implement the use of the clock given by the plate’s crystal?
    Thank you, in advance!

  • Hello Mr. Wong,

    I have a doubt in the library when I am declaring a reference voltage of 5 V and giving a reference voltage of 5 V to IN1+. On the serial monitor, I can see ADC conversion from 2.5V to 5 V when I vary the potentiometer.

    whatever reference voltage I am giving it is divided by 2.

    Thank you, in advance!

  • hi Kerry,
    Thanks for your library. it was 9 years old now. Are there any update on it? maybe compatible for esp8266/esp32
    declaring reference and calibration part need revision I think.
    anyway thanks again

  • Hello everybody. Many thanks to the author of this library. it’s nice. however to read both channels i need a reset function in between readings (that’s a minor issue).
    biggest problem (common problem): i also suffer with TM7705 chip (coming from china). that is all returned data is =0.0 in all ways. The reason is the symbol on the PCB:
    DOUT(pcb)=MISO(arduino)=(pin12) and DIN(pcb)=MOSI(arduino)=(pin11).
    yes it sounds wrong, but it’s true. I’m sure someone needs this information.
    I’m not fluent in English, I use google translate. sorry!

  • Hello AD7705 funs,

    I think there is a synchronization problem within the library. If you use spiMODE other than mode2 the library works. However produced raw data in 0-65536 range is very limited. In my experience ı got only one fourth of full ecpected raw data , namely around 8000 instead of 32000 durin 10 mv input and gain 128. both channel are procuing reasonable raw data.

    If ı use spi mode2 then ı get around 16000 count as expected. However in this mode 2nd channel does not work.
    Do you have similar experiences? Have you tested raw data for both channel?

Leave a Reply

Your email address will not be published.