I have prepared a sender/receiver example using two RP2040 boards. The sender reads a touch input and writes one byte to I2C address 0x08; the receiver uses that byte to control an LED. The source is archived below.
Evidence pending: I do not yet have the wired setup, an addressed-message test or a working-result recording in this archive. The earlier text stated that the test succeeded, but I cannot substantiate that statement from the files currently available.
At least one node must be my own designed and fabricated board. I will identify its revision using my board design and fabrication record.
My intended wiring is SDA to SDA, SCL to SCL and a common ground between the two boards. I still need to record the actual header pins, supply arrangement and I2C pull-up arrangement used on the physical setup. I will not assume those are correct merely because the code builds.
The sender uses Wire.beginTransmission(0x08). The receiver uses Wire.begin(0x08) and registers its receive callback. A byte of 1 requests LED on; 0 requests LED off.
#include <Wire.h>
#define TOUCH_PIN D9
#define RECEIVER 0x08
void setup() {
Wire.begin(); // join the bus as the controller
pinMode(TOUCH_PIN, INPUT);
}
void loop() {
byte msg = digitalRead(TOUCH_PIN); // 1 = touched, 0 = not
Wire.beginTransmission(RECEIVER);
Wire.write(msg);
Wire.endTransmission();
delay(100);
}
#include <Wire.h>
#define LED_PIN D1
#define MY_ADDRESS 0x08
void setup() {
pinMode(LED_PIN, OUTPUT);
Wire.begin(MY_ADDRESS); // join the bus with my address
Wire.onReceive(onMessage);
}
void onMessage(int howMany) {
byte msg = Wire.read();
digitalWrite(LED_PIN, msg); // 1 turns the LED on, 0 off
}
void loop() {}
The group assignment page is still a template. I need the actual inter-project message test and results there. A working link does not make that group work complete.