const uint8_t nreg2 = 22;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
read2();
}
void loop() {
// put your main code here, to run repeatedly:
}
void read2() {
uint64_t data[4];
uint64_t counter = 0;
data[0]=0x000;
data[1]=0X11;
data[2]=0X1111;
data[3]=0X1111;
// counter = data[3];
for (int j = 3; j >= 0; j--)
{
counter = counter | (data[j] << (3 - j) * 16);
}
print_uint64_t(counter);Serial.println();
counter=counter /100;
Serial.println(str(counter));
double activityImportValue = (double)counter / 100;
Serial.println();
Serial.println(activityImportValue );
}
void print_uint64_t(uint64_t num) {
char rev[128];
char *p = rev+1;
while (num > 0) {
*p++ = '0' + ( num % 10);
num/= 10;
}
p--;
/*Print the number which is now in reverse*/
while (p > rev) {
Serial.print(*p--);
}
}
char* str( uint64_t num ) {
static char buf[22];
char* p = &buf[sizeof(buf)-1];
*p = '\0';
do {
*--p = '0' + (num%10);
num /= 10;
} while ( num > 0 );
return p;
}