senseopk.blogg.se

Wire library i2c
Wire library i2c










To do this, we will be using a few things you might not have come across before. On the other end, you read the array in as individual bytes and rebuild it into the appropriately sized number.

wire library i2c

What you have to do is split the number into individual bytes, put them into an array, and send it over. Data TypeĪs you can see, most of these are more than one byte so sending them over I2C will be a bit of a problem.

wire library i2c

If you are ever confused about the size of a particular data type, you can use sizeOf( data type) function to get the size. There are several other data types that you may find useful as they are more specific about their size and sign. This post will show you how I break large numbers apart to send them over I2C and reassemble them on the other side.īefore beginning, it’s important to know that on most Arduinos and ATmega chips, have a 16 bit integer, meaning that the integer data type takes up 2 bytes. I2C normally only sends a single byte at a time so you are limited to 255 as the largest number.

wire library i2c

I’ve been using I2C a lot lately and something that keeps popping up is the need to send large numbers.












Wire library i2c