Advertisement
Narayan

eeprom

Oct 23rd, 2022 (edited)
1,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.59 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[] = {"\{\"bc1qjaz2248t09y98vaqguq2560t7kclhesapce5sf\":\"KxdK7M6b148NsEyH6EvR91xSWN27uzCxYfhgdRznZEZfX7Kkr9Rh\"\}"};
  18. bool ok = true;
  19. int writt = 0;
  20. int status = 0;
  21.  
  22. void setup(){
  23.     Serial.begin(115200);
  24.     Wire.begin(SDA_PIN, SCL_PIN);
  25.     // Wire.setClock(100);
  26. }
  27.  
  28. void loop() {
  29.     using periodic = esp8266::polledTimeout::periodicMs;
  30.     static periodic nextPing(1000);
  31.  
  32.     if(nextPing && ok){
  33.         // GOT_HERE();
  34.         Wire.beginTransmission(I2C_SLAVE_ADDR7);
  35.         // GOT_HERE();
  36.         writt = Wire.write(addrpk);
  37.         Serial.print("Written ");
  38.         Serial.print(writt);
  39.         Serial.println(" bytes!");
  40.         // GOT_HERE();
  41.         Serial.print("Wire endTrans: ");
  42.         Serial.println(Wire.endTransmission());
  43.         // GOT_HERE();
  44.         status = Wire.requestFrom(I2C_SLAVE_ADDR7, strlen(addrpk));
  45.         Serial.print("Wire reqFrom: ");
  46.         Serial.println(status);
  47.         // GOT_HERE();
  48.         while( Wire.available() ){
  49.             char c = Wire.read();
  50.             Serial.print(c);
  51.             // GOT_HERE();
  52.         }
  53.         ok = false;
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement