Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. /**
  2. * Computes the checksum of a SDS011 message.
  3. *
  4. * This checksum is the low 8 bits of the sum of the data bytes.
  5. * The sensor will not react to commands with invalid checksum.
  6. */
  7. byte sds011_checksum(byte* msg, size_t msg_size) {
  8. int sum = 0;
  9. for (int i = 2; i < msg_size - 2; i++) {
  10. sum += msg[i];
  11. }
  12. return (byte) 0xff & sum;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement