Hello.
I'm new to Arduino and wanted to make a simple project to measure voltage, wattage and current and display it on a GLCD. I've managed that with the help of this site (thanks!) but I'm having problems with the amount of decimal places in my results.
I've had a look at the example sketches and emonlib.h library but I can't see how to format the results without a decimal point.
Any help/advice would be hugely appreciated!
Scott.
Re: Formatting results from EmonLib
I'm not sure I understand your question.
When you say you are having problems with the amount of decimal places, is it that there are too many? And you want the result with just whole numbers?
If so try looking up the arduino variable type (integer - int)
http://www.arduino.cc/en/Reference/VariableDeclaration
Re: Formatting results from EmonLib
Hi.
Thanks for the reply.
Yes, when I call the result onto a LCD (particularly apparentWatts) i get something like 6 numbers to the right of the decimal point. I'd just like to display whole numbers. I know about integer and float point maths and declarations, but in the sample sketch the declarations are done within the emonlib.cpp file itself (I think?).
I'm totally lost.
Re: Formatting results from EmonLib
GLCD receives the data in the form of an integer via the RF module - the unit for the two powers is Watts. So if you are seeing 6 places of decimal, somewhere in your GLCD code it would appear that you've converted to a float (or double).
Serial.print can take an optional second parameter. This is part of the list of examples from the Arduino IDE Reference:
Re: Formatting results from EmonLib
Thanks for your time in replying.
Added the extra formatting to my text and sorted the problem out. Thanks for your help!