I2C Communication among devices

NOOB here.

Just to comment about the Platformio.ini file. I love it because I can setup at least two devices at the same time (or switch from one to the other). It would be advantagous if I could locate a comprehensive tutorial about using the file with its possiblilties other than what is listed at the PlatformIO Website. Little disappointed that there were no conditionals other than the src_filter for selecting a compile folder.

With that said, any advice on how to setup the configuration file for communication (Serial, TWI (I2C) SPI, etc.) amoung MCU devices.

Thanks in advance

What is src_filter lacking in your opinion?

This question is far too general to be ansered, you are asking for info on at least 3 different topics here, all of which have an electrical protocol component and programming component (e.g., how to use Arduino Serial, Wire or SPI classes) to them, and for all of these extensive docs exist on the framework side (example, example, …)

Specific - Detailed - but not general!? Got It. I Think… For example, I noted when using the Arduino.h Include Lib. that the data type int is inconsistent…

myVar:6297
0b1100010011001
0x1899
myVar:-1
0b11111111111111111111111111111111
0xFFFFFFFF

When sending information over I2C for example the integer needs to be broken up into bytes. Notice the difference in sizes from a positive (16 bits) to a negative integer (32 bits). Thus using a Arduino.h Lib has caused hiccups. Here I am not asking for a solution specifically but in general whether libraries maybe including math or a better and maybe (I do not know) whether something can be configured (ini). Really all I wanted was to start a general conversation. Sorry I took up your time…

Try this:

void setup() {
  int x = 123;
  Serial.begin(9600);
  Serial.println(sizeof(x));

  x = -x;
  Serial.println(sizeof(x));
}

void loop() {
}

You will get the result “2” for each. See here. for details.

HTH

Cheers,
Norm.