hello guys,
I'm trying to print my data like line by line
for instance,
speed weight rpm max rpm amps
40 0.500 60 90 0.200
in this way.
thank you guys ,and i do really appreciate it.
this is my coding :
#include "HX711.h" //You must have this library in your arduino library folder
#include <Servo.h>
Servo esc_signal;
#define DOUT 3
#define CLK 2
const int hallSensorPin = 2; // connect the hall effect sensor on pin 2
const unsigned long sampleTime = 1000;
const int maxRPM = 1260; // maximum RPM for LCD Bar
int rpmMaximum = 0;
const int analogIn = A0;
int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;
HX711 scale(DOUT, CLK);
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
float calibration_factor = -65000; //-106600 worked for my 40Kg max scale setup
//=============================================================================================
// SETUP
//=============================================================================================
void setup() {
Serial.begin(9600);
esc_signal.attach(9);
esc_signal.write(30);
pinMode(hallSensorPin,INPUT);
delay(3000);
Serial.println("Press T to tare");
scale.set_scale(-65000); //Calibration Factor obtained from first sketch
scale.tare(); //Reset the scale to 0
}
int getRPM()
{
int count = 0;
boolean countFlag = LOW;
unsigned long currentTime = 0;
unsigned long startTime = millis();
while (currentTime <= sampleTime)
{
if (digitalRead(hallSensorPin) == HIGH)
{
countFlag = HIGH;
}
if (digitalRead(hallSensorPin) == LOW && countFlag == HIGH)
{
count++;
countFlag=LOW;
}
currentTime = millis() - startTime;
}
int countRpm = int(60000/float(sampleTime))*count;
return countRpm;
}
void displayRPM(int rpm)
{
Serial.print("RPM = ");
Serial.print(rpm);
Serial.print(" MAX RPM = ");
Serial.println(rpmMaximum);
}
void displayBar(int rpm)
{
int numOfBars=map(rpm,0,maxRPM,0,15);
if (rpm!=0)
{
for (int i=0; i<=numOfBars; i++)
{
}
}
}
void loop() {
int x=40;
delay(100);
//int rpm = getRPM();
// if (rpm > rpmMaximum) rpmMaximum = rpm;
//Change this to kg and re-adjust the calibration factor if you follow lbs
while ((x<60)){
esc_signal.write(x); //Vary this between 40-130 to change the speed of motor. Higher value, higher speed.
x=x+1;
Serial.print("speed: ");
Serial.print(x);
Serial.print(" ");
Serial.print(" weight ");
Serial.print(scale.get_units(), 3); //Up to 3 decimal points
Serial.println(" kg");
getRPM();
int rpm = getRPM();
if (rpm > rpmMaximum) rpmMaximum = rpm;
displayRPM(rpm);
displayBar(rpm);
delay (1000);
RawValue = analogRead(analogIn);
Voltage = (RawValue / 1024.0) * 5000; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);
Serial.print("Raw Value = " ); // shows pre-scaled value
Serial.print(RawValue);
Serial.print("\t mV = "); // shows the voltage measured
Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
Serial.print("\t Amps = "); // shows the voltage measured
Serial.println(Amps,3); // the '3' after voltage allows you to display 3 digits after decimal point
delay(2500);
}
Serial.print("Weight== ");
Serial.print(scale.get_units(), 3); //Up to 3 decimal points
Serial.println(" kg");
esc_signal.write(0);
delay (50);
if(Serial.available())
{
char temp = Serial.read();
if(temp == 't' || temp == 'T')
scale.tare(); //Reset the scale to zero
Serial.print("Weight: ");
Serial.print(scale.get_units(), 3); //Up to 3 decimal points
Serial.println(" kg");
Serial.println(" ");
}
}