Hi, although I looked in the forums but I did not came to a solution which in the end would be simple if you know the solution. ;D
Can I get this double converted to a string? Or is this the wrong way?
My VB6 PC application accepts numbers upto 999999 by serial commmunication but no fractionals so fractionals need to be converted before send to serial.
So a value like 0.022 in the serial monitor which is for the Amps value needs to become 22 which is miliAmps.
How can I get this 22 and not 22.00 to send to serial.
/*
Measuring Current Using ACS712 30A Module
*/
const int analogIn = A2;
//int mVperAmp = 185; // for 20A Module
int mVperAmp = 66; // for 30A Module
int RawValue= 0;
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
RawValue = analogRead(analogIn);
Voltage = (RawValue / 1023.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(1000);
}