Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MASTER
- #include <Wire.h>
- char msg[13];
- void setup()
- {
- // Start I²C bus as master
- Wire.begin();
- Serial.begin(9600);
- }
- void loop()
- {
- Wire.requestFrom(8, 11); // request 11 bytes from slave device #8. 11 bytes because 5 digits for temp, 5 digits for hum, and 1 digit for a comma
- //gathers data comming from slave
- int i=0; //counter for each bite as it arrives
- while (Wire.available()) {
- msg[i] = Wire.read(); // every character that arrives it put in order in the empty array "t"
- i=i+1;
- }
- Serial.println(msg); //shows the data in the array hum
- delay(500); //give some time to relax
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement