Advertisement
Narayan

eeprom

Oct 20th, 2022 (edited)
1,263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. #define GOT_HERE()  do {Serial.print('['); Serial.print(__LINE__); Serial.println(']'); Serial.flush();} while(0)
  4. #define MAX_BUFFER_ADDR_PK 102
  5. #define SDA_PIN 4
  6. #define SCL_PIN 5
  7.  
  8. const int I2C_SLAVE_ADDR0 = 0x50;
  9. const int I2C_SLAVE_ADDR1 = 0x51;
  10. const int I2C_SLAVE_ADDR2 = 0x52;
  11. const int I2C_SLAVE_ADDR3 = 0x53;
  12. const int I2C_SLAVE_ADDR4 = 0x54;
  13. const int I2C_SLAVE_ADDR5 = 0x55;
  14. const int I2C_SLAVE_ADDR6 = 0x56;
  15. const int I2C_SLAVE_ADDR7 = 0x57;
  16.  
  17. char addrpk[MAX_BUFFER_ADDR_PK] = {};
  18. bool ok = true;
  19.  
  20. void setup(){
  21.     Serial.begin(115200);
  22.     Wire.begin(SDA_PIN, SCL_PIN);
  23.     Wire.setClock(100);
  24. }
  25.  
  26. void loop() {
  27.     strcpy(addrpk, "{\"bc1qjaz2248t09y98vaqguq2560t7kclhesapce5sf\":\"KxdK7M6b148NsEyH6EvR91xSWN27uzCxYfhgdRznZEZfX7Kkr9Rh\"}");
  28.     using periodic = esp8266::polledTimeout::periodicMs;
  29.     static periodic nextPing(1000);
  30.     if(nextPing && ok){
  31.         GOT_HERE();
  32.         Wire.beginTransmission(I2C_SLAVE_ADDR7);
  33.         GOT_HERE();
  34.         Wire.write(addrpk);
  35.         GOT_HERE();
  36.         Wire.endTransmission();
  37.         GOT_HERE();
  38.         Wire.requestFrom(I2C_SLAVE_ADDR7, strlen(addrpk));
  39.         GOT_HERE();
  40.         while( Wire.available() ){
  41.             char c = Wire.read();
  42.             Serial.print(c);
  43.             GOT_HERE();
  44.         }
  45.         ok = false;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement