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
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();* }