Help reading data from Serial with TelemetryViewer

Hello, I´m new in arduino programing, and I`m stuck in my project. I´m working with project with several load cells, so I´m working with HX711-multi library. My code works fine with Ide serial monitor or ploter. The problem is tha I would like to use TelemetryViewer software to view and record the data. The software tells me thay I need to include in my code something like this:

// this code is a crude template // you will need to edit this

void setup() { Serial.begin(115200); }

// use this loop if sending integers void loop() { int loadcell1 = ...; int loadcell2 = ...; int loadcell3 = ...;

char text[22]; snprintf(text, 22, "%d,%d,%d", loadcell1, loadcell2, loadcell3); Serial.println(text);

delay(...); }

// or use this loop if sending floats void loop() { float loadcell1 = ...; float loadcell2 = ...; float loadcell3 = ...;

char loadcell1_text[30]; char loadcell2_text[30]; char loadcell3_text[30];

dtostrf(loadcell1, 10, 10, loadcell1_text); dtostrf(loadcell2, 10, 10, loadcell2_text); dtostrf(loadcell3, 10, 10, loadcell3_text);

char text[94]; snprintf(text, 94, "%s,%s,%s", loadcell1_text, loadcell2_text, loadcell3_text); Serial.println(text);

delay(...); }

But I don´t know how to modify my code to make it works. I´ve been searching for a solution and trying to fix it for weeks. Please, If some one could help me I´ll be very glad. Thank you very much.

My code is the following:

include "HX711-multi.h"

// Pins to the load cell amp

define CLK 13 // clock pin to the load cell HX711

define DOUT1 A1 // data pin to the first HX711

define DOUT2 A2 // data pin to the second HX711

define DOUT3 A3 // data pin to the third HX711

define BOOT_MESSAGE "MIT_ML_SCALE V0.8"

define TARE_TIMEOUT_SECONDS 4

byte DOUTS[3] = {DOUT1, DOUT2, DOUT3};

define CHANNEL_COUNT sizeof(DOUTS)/sizeof(byte)

long int results[CHANNEL_COUNT];

HX711MULTI scales(CHANNEL_COUNT, DOUTS, CLK);

void setup() { Serial.begin(115200); Serial.println(BOOT_MESSAGE); Serial.flush(); pinMode(11,OUTPUT);

tare(); }

void tare() { bool tareSuccessful = false;

unsigned long tareStartTime = millis(); while (!tareSuccessful && millis()<(tareStartTime+TARE_TIMEOUT_SECONDS*1000)) { tareSuccessful = scales.tare(20,10000); //reject 'tare' if still ringing } }

void sendRawData() { scales.read(results); for (int i=0; i} * *delay(10); } void loop() {

sendRawData(); //this is for sending raw data, for where everything else is done in processing //on serial data (any data) re-tare if (Serial.available()>0) { * while (Serial.available()) {* * Serial.read();* * }* * tare();* }

IF you can, just tell us in English what changes need to be made to your program.

Paul

chiquicapoiro: The problem is tha I would like to use TelemetryViewer software to view and record the data.

I have never heard of that.

A link to its user manual would help us to help you.

...R

Apparently, it is some sort of software written in Java that needs JRE to run. There are Java source files.

.

ieee488: There are Java source files.

If the only source of info is Java source files the OP can count me out. :)

In the past I have used JRE with an Arduino with no problem.

...R

Thank you very much for your answers and your time. The software I would like to use is a java based software: TelemetryViewer v0.6, from http://www.farrellf.com/TelemetryViewer/ For my project I need to see in real time the changes of loads in all the load cells, and I was wathcing this video and is exactly what I need, because in the future I will need to add more load cells: https://www.youtube.com/watch?v=lFZ26gD7OIE

The problem is that the software ask me to add some lines in my code, but I can´t make it work. You can see in the picture: https://imgur.com/MhslU0X

Software tell me this:

// this code is a crude template
// you will need to edit this

void setup() {
  Serial.begin(115200);
}

// use this loop if sending integers
void loop() {
  int loadcell1 = ...;
  int loadcell2 = ...;
  int loadcell3 = ...;

  char text[22];
  snprintf(text, 22, "%d,%d,%d", loadcell1, loadcell2, loadcell3);
  Serial.println(text);

  delay(...);
}

// or use this loop if sending floats
void loop() {
  float loadcell1 = ...;
  float loadcell2 = ...;
  float loadcell3 = ...;

  char loadcell1_text[30];
  char loadcell2_text[30];
  char loadcell3_text[30];

  dtostrf(loadcell1, 10, 10, loadcell1_text);
  dtostrf(loadcell2, 10, 10, loadcell2_text);
  dtostrf(loadcell3, 10, 10, loadcell3_text);

  char text[94];
  snprintf(text, 94, "%s,%s,%s", loadcell1_text, loadcell2_text, loadcell3_text);
  Serial.println(text);

  delay(...);
}

thank you very very much for your help and time.

chiquicapoiro: The problem is that the software ask me to add some lines in my code, but I can´t make it work.

You seem to have posted the template code but you also need to show us the code that represents your best attempt at using the template.

And when posting code please use the code button

so your code 
looks like this

and is easy to copy to a text editor See How to use the forum

...R

Thank you very much for your help, and I apologize for my errors posting, I´m new here. I don´t know how to add the lines, so I don´t have one last attempt. My code works like this sending data to serial port of the three load cells, but I´m stuck understanding the lines that software is asking to me and complete them.

I figure out that I have to complete with my variables, but I´ve tryed everything... and nothing... I got plane lines in the TelemetryViewer plot. Thank you very much for your help.

chiquicapoiro: I figure out that I have to complete with my variables, but I´ve tryed everything... and nothing...

But you have not posted the program that you have tried and which is giving you straight lines.

...R

Thank you very much for your answer.
I put the code in my first post.
I´ll put it again and attach the file:

#include "HX711-multi.h" 
// Pins to the load cell amp 
#define CLK 13 // clock pin to the load cell amp 
#define DOUT1 A0 // data pin to the first lca 
#define DOUT2 A1 // data pin to the second lca 
#define DOUT3 A2 // data pin to the third lca 
#define DOUT4 A3 // data pin to the fourth lca 
#define BOOT_MESSAGE "LOAD_CELL" 
#define TARE_TIMEOUT_SECONDS 4 
byte DOUTS[4] = {DOUT1, DOUT2, DOUT3, DOUT4}; 
#define CHANNEL_COUNT sizeof(DOUTS)/sizeof(byte) 
long int results[CHANNEL_COUNT]; 
HX711MULTI scales(CHANNEL_COUNT, DOUTS, CLK);


void setup() 
{ 
Serial.begin(115200); 
Serial.println(BOOT_MESSAGE); 
Serial.flush(); 
pinMode(11,OUTPUT); 
tare(); 
} 

void tare() 
{ 
bool tareSuccessful = false; unsigned long tareStartTime = millis(); 
while (!tareSuccessful && millis()<(tareStartTime+TARE_TIMEOUT_SECONDS*1000)) { tareSuccessful = scales.tare(20,10000); 
//reject 'tare' if still ringing 
} 
}

void sendRawData() 
{ 
  scales.read(results); for (int i=0; i<scales.get_count(); ++i) {; 
  Serial.print( -results[i]); 
  Serial.print( (i!=scales.get_count()-1)?"\t":"\n"); } 
  delay(10); 
} 

void loop() 
{ 
  sendRawData(); 
  //this is for sending raw data, for where everything else is done in processing 
  //on serial data (any data) re-tare if (Serial.available()>0) { while (Serial.available()) { Serial.read(); } tare(); } }
}

This is the serial plot with 4 load cells working at the same time:

Imgur

So i woult like to send this data to TelemetryViewer.
Thank you very much.

Multi_Load_Cell.ino (1.36 KB)

chiquicapoiro: I put the code in my first post.

Never make big changes to old posts. Correcting typos is fine, but nothing more. Put new material in a new Reply where it will be in the correct chronological order. When you make big changes to old posts it makes it impossible for someone else to make sense of the Thread reading from top to bottom. If you can re-instate the Original Post to its original state that would be a good idea.

And when I come back to a Thread I only read onwards from my most recent Reply so I never see changes to earlier stuff.

...R

The code in Reply #9 looks nothing like the template in Reply #5. Have you tried just taking a copy of the template and filling in the blanks?

...R

Sorry for that, I´m very new in the forum. I tryed to fill the blanks, but I don´t know what values I have to put in. I´ve been trying several things, still works with serial plot, but I don´t know what "int", or may be "long int" I have to use. Thank you very much.

I don't know how the HX711 library works.

To be able to send the results to Telemetry Viewer, the key is to create a character buffer.

char text[94]; snprintf(text, 94, "%s,%s,%s", loadcell1_text, loadcell2_text, loadcell3_text);

and Serial.println(text);

.

Thank you for your answer, I have this part clear, more or less... but my problem is to fill the previous part:

void loop() {
  int loadcell1_text = ...;
  int loadcell2_text = ...;
  int loadcell3_text = ...;

I don´t know what I have to put in this place. Thank you very much again for your answer

chiquicapoiro: Thank you for your answer, I have this part clear, more or less... but my problem is to fill the previous part:

void loop() {
  int loadcell1_text = ...;
  int loadcell2_text = ...;
  int loadcell3_text = ...;

I don´t know what I have to put in this place.

If it was my problem I would try

void loop() {
  int loadcell1_text = 123;
  int loadcell2_text = 234;
  int loadcell3_text = 345;

It is looking for an int which is a numeric value whatever the name of the variable might suggest

...R

As just a test, all you need is Serial.println("123,456,789"); Just realized that it is comma separated string that the program expects.

.

Thank you very much. I tryed both sugestions. With both I get straight lines with the values I´ve write in the blanks, in IDE serial monitor and TelemetryViewer too.

https://imgur.com/1yf1v6K

My actual code is this:

#include "HX711-multi.h" 
// Pins to the load cell amp 
#define CLK 13 // clock pin to the load cell amp 
#define DOUT1 A0 // data pin to the first lca 
#define DOUT2 A1 // data pin to the second lca 
#define DOUT3 A2 // data pin to the third lca 
#define DOUT4 A3 // data pin to the fourth lca 
#define BOOT_MESSAGE "LOAD_CELL" 
#define TARE_TIMEOUT_SECONDS 4 
byte DOUTS[4] = {DOUT1, DOUT2, DOUT3, DOUT4}; 
#define CHANNEL_COUNT sizeof(DOUTS)/sizeof(byte) 
long int results[CHANNEL_COUNT]; 
HX711MULTI scales(CHANNEL_COUNT, DOUTS, CLK);


void setup() 
{ 
Serial.begin(115200); 
Serial.println(BOOT_MESSAGE); 
Serial.flush(); 
pinMode(11,OUTPUT); 
tare(); 
} 

void tare() 
{ 
bool tareSuccessful = false; unsigned long tareStartTime = millis(); 
while (!tareSuccessful && millis()<(tareStartTime+TARE_TIMEOUT_SECONDS*1000)) { tareSuccessful = scales.tare(20,10000); 
//reject 'tare' if still ringing 
} 
}

void sendRawData() 
{ 
  scales.read(results); for (int i=0; i

}

What more I could try? Thank you sincerely for your help.

void setup()
{
Serial.begin(115200);
}


// use this loop if sending integers
void loop() {

  Serial.println("123,234,345");

  delay(1000);
}

Thak you for your answer. I tryed that, but still showing in plot 3 straigh lines with this values. :( Thank you very much.