Go Down

Topic: tm7709 (Read 3239 times) previous topic - next topic


I am having trouble getting this adc to work..
Is there any library or code that someone tested that work with this adc..
Here is the link.. http://www.ledsandchips.com/232
The code from the link is not working..
Thanks for your time,


sensor unknown and I cannot open the code.
can you post the (not working )code?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Jun 28, 2013, 10:56 am Last Edit: Jun 28, 2013, 11:00 am by backbone Reason: 1
I have received the modul too and hooked it up to an UNO with a load cell.
I used the code supplied with the link and it works.
In serial monitor it shows nicely a 0.000123 value at no load.
With load it goes to a max of 0.034578
What does not work in the code?

Does it not compile?

I need to parse not only the value from  ADC to Processing and VB6 but also some other values from the UNO.
Dang that is a challenge.

Never to old to learn and I learn every day


Try this code.

Code: [Select]

//TM7709 24bit ADC module arduino sketch
//coldtears electronics
//code reworked to read in grams

//default connection arduino UNO
//DRDY = pin 11 >MOSI
//ADIO = pin 12 >MISO
//SCLK = pin 13 >SCK

//default connection arduino MEGA
//DRDY = pin 21 >MOSI
//ADIO = pin 22 >MISO
//SCLK = pin 28 >SCK

#define TM7710_DRDY        3         
#define TM7710_ADIO        4         
#define TM7710_ADIO_OUT()  DDRB|=1<<4     
#define TM7710_ADIO_IN()   DDRB&=~(1<<4) 
#define Set_TM7710_SCLK()  PORTB|=1<<5
#define Set_TM7710_ADIO()  PORTB|=1<<4
#define Clr_TM7710_SCLK()  PORTB&=~(1<<5)
#define Clr_TM7710_ADIO()  PORTB&=~(1<<4)

unsigned char x[3];
long Result;
float vref=4.89;
double microvolt = 0;
long microvoltA = 456;
long microvoltB = 180;
int extradata1 = 777;
int extradata2 = 888;
float loadA = 0; //this is the first weight (we use no load at the sensor) our sensor already has as a small plate on it we use a preload.
float loadB = 1590; //this is the second calibrated weight in grams
float valueA = 173; //value of the the serialmonitor reading with the first known weigth at the sensor (we use no load at the sensor).
float valueB = 9360; //value of the the serialmonitor reading with the second known load at the sensor (we 1590 grams at the sensor).
float load;
long finalValue;

void setup()
DDRB|=1<<5 ;
Serial.begin(57600);// set baudrate for PC or serialmonitor the same!
void loop()

   for(unsigned char j=0;j<3;j++)
   Result = Result * 256;
   Result = Result + x[1];
   Result = Result * 256;
   Result = Result + x[2];
   Result = Result - 6912000;
   double volt = Result * vref /16/6912000; //data coming from this line is .....      "0.123456" for example
   long microvolt = (volt*1000000); // microvolts are easier to break down in blocks of 3 then floats so we multiply with 1000000.
   //split the microvolt value in blocks of three digits so it can be parsed to the serial output by Serial.print as integer value as it is lower as 1024.
   //sample value of volt  =  "123456" so we brake it down in 123 and 456 <> volt.
   //In our case it will never go below 0 or above 999999
   //float (load.substring (0,2)); // we need the three most right side digits
   //float (load.substring (3,5)); //we need the three most left side digits
   //at the PC side VB6 should detect the "letter - comma - value" and parse it in a textbox
   // how things work with Processing I have no idea yet :-(.
   float load = ((loadB - loadA)/(valueB - valueA)) * ( microvolt - valueA) + loadA; //the final value of the real load on the sensor

   Serial.print ("A,");
   Serial.println (microvoltA);
   Serial.print ("B,");
   Serial.println (microvoltB);
   Serial.print ("C,");
   Serial.println (extradata1);
   Serial.print ("D,");
   Serial.println (extradata2);
   Serial.print ("E,");
   Serial.println (microvolt); //raw sensor value in microvolts
   Serial.print ("F,");
   Serial.println (load,0); // value in grams

void TM7710_Init()
   TM7710_write(0x20);   //Gain=128
   //TM7710_write(0x00); //Gain=16

void TM7710_start(void)   

void TM7710_stop(void)   

void TM7710_write(unsigned char dd)
    unsigned char i;


unsigned char TM7710_read(void)
    unsigned char data=0,i;

    return data;

void printFloat(float value, int places) {
// this is used to cast digits
int digit;
float tens = 0.1;
int tenscount = 0;
int i;
float tempfloat = value;

// if value is negative, set tempfloat to the abs value
// calculate rounding term d:   0.5/pow(10,places)
float d = 0.5;
if (value < 0)
   d *= -1.0;
// divide by ten for each decimal place
for (i = 0; i < places; i++)
   d/= 10.0;
// this small addition, combined with truncation will round out

tempfloat +=  d;

if (value < 0)
   tempfloat *= -1.0;
while ((tens * 10.0) <= tempfloat)
   tens *= 10.0;
   tenscount += 1;

// write out the negative if needed
if (value < 0)

if (tenscount == 0)
   //Serial.print(0, DEC);

for (i=0; i< tenscount; i++)
   digit = (int) (tempfloat/tens);
   //Serial.print(digit, DEC);
   tempfloat = tempfloat - ((float)digit * tens);
   tens /= 10.0;

// if no places after decimal, stop now and return
if (places <= 0)

// otherwise, write the point and continue on

for (i = 0; i < places; i++)
   tempfloat *= 10.0;
   digit = (int) tempfloat;
   // once written, subtract off that digit
   tempfloat = tempfloat - (float) digit;


Never to old to learn and I learn every day


When you buy an ebay version of the TM7709 with pcb then this is the layout for connection.

At the side with the 4 connection pins you connect the load cell.
Where +input and -input are the wires that carry the differential value from the loadcell.
VCC and GND are power source (exatation value) for the loadcell.

Never to old to learn and I learn every day


thanks Paco,

Can you elaborate a bit on the strain gauge circuit please?

I want to use a two wire strain gauge like this one.....

Because I only want to use a single strain gauge, I think I need a circuit like shown here ....
(page 2, bottom right hand corner, 'figure 5, quarter bridge (3wire)')

I think the points labeled '+ bridge supply' and '- bridge supply' need to go to VCC and ground on your diagram, and the points labeled '+ input' and '- input' need to go to the same-named pins on your diagram?

Is this correct?




Understand your question.
Regardless the type of loadcell you always measure in a bridge configuration.
See all other drawings where there are Always 4 resistors.
In your case the idle resistor value = 120 Ohm.
So if you like to measure it in a bridge all other three resistors need to be 120 Ohm too.
Now if your load cell is pressed on, this 120 ohm value will change and cause a differential output which need to go to the +input and -input of of the TM7709. The TM7709 will amplify the signal.

Do you have one of these with the board or just a single TM7709 IC?

Does this help?

What application you are using this strain foil?

Never to old to learn and I learn every day


Do you have one of these

I'm about to order one of these....
I think it's the same item as in your link.

What application you are using this strain foil?

I want to measure the torque in a drive shaft and then use this (along with the rpm) to measure the power being delivered.

thanks for your help.


Ok so your building a engine dyno.  What kind of engine you need to measure?
The TM7709 board is the same.

Never to old to learn and I learn every day

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131