Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Computes the checksum of a SDS011 message.
- *
- * This checksum is the low 8 bits of the sum of the data bytes.
- * The sensor will not react to commands with invalid checksum.
- */
- byte sds011_checksum(byte* msg, size_t msg_size) {
- int sum = 0;
- for (int i = 2; i < msg_size - 2; i++) {
- sum += msg[i];
- }
- return (byte) 0xff & sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement