Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
atc1441 authored May 29, 2021
1 parent 12ed07f commit a5a661b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ArduinoPollDemo/ArduinoPollDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,18 @@ void loop() {
float ac_current = (rx_buffer[21] << 8 | rx_buffer[22]) / 100;
float ac_power = ac_voltage * ac_current;

union byte_to_float_union {
byte byte_in[4];
float float_out;
} byte_to_float;

byte_to_float.byte_in[0] = rx_buffer[13];
byte_to_float.byte_in[1] = rx_buffer[12];
byte_to_float.byte_in[2] = rx_buffer[11];
byte_to_float.byte_in[3] = rx_buffer[10];

float power_gen_total = byte_to_float.float_out;
/* union byte_to_float_union {
byte byte_in[4];
float float_out;
} byte_to_float;
byte_to_float.byte_in[0] = rx_buffer[13];
byte_to_float.byte_in[1] = rx_buffer[12];
byte_to_float.byte_in[2] = rx_buffer[11];
byte_to_float.byte_in[3] = rx_buffer[10];
*/
const uint32_t tempTotal = rx_buffer[10] << 24 | rx_buffer[11] << 16 | rx_buffer[12] << 8 | (rx_buffer[13] & 0xFF);
float power_gen_total = *((float*)&tempTotal);

int temperature = rx_buffer[26];// not reversed

Expand Down

0 comments on commit a5a661b

Please sign in to comment.