SHARE
TWEET

Untitled

a guest Jun 16th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top