sdp610.ino 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #include <Wire.h>
  2. int16_t okunan;
  3. byte crc;
  4. float get_dp;
  5. void setup() {
  6. Wire.begin(); // wake up I2C bus
  7. Serial.begin(9600);
  8. // this section will run only one time.
  9. // Wire.beginTransmission(0x38);
  10. // Wire.write(0xFA); //adress change command
  11. // Wire.write(0x2C); //register adress msb
  12. // Wire.write(0x20); // register adress lsb
  13. // Wire.write(0x01); //new adress msb (new adress will be 0x21,if you want, you can change this value )
  14. // Wire.write(0x1F); //new adress lsb (first six bit must 000000 and after 7 bit changeable (desired adress) last 3 bit must be 111
  15. // //= result 0b0000000100001111=0x21 and final first byte(msb)=0x01 second byte (lsb) =0x0F
  16. // Wire.endTransmission();// sensor adress still 0x40. but after reset it will be 0x21. press arduino reset button to hard reset :)
  17. }
  18. void loop() {
  19. //After change adress of sensor you can delete setup section of adress change commands
  20. Wire.beginTransmission(0x21); //
  21. Wire.write(0xF1); //
  22. Wire.endTransmission(); // "Thanks, goodbye..."
  23. Wire.requestFrom(0x21, 3); // request to from 0x21 sensor 3 byte data
  24. okunan = (Wire.read() << 8) | Wire.read();
  25. crc = Wire.read(); // crc reading but not control for error correction :)
  26. get_dp = okunan / 240; // look sdp610-125 datasheet
  27. Serial.print("Sensor1: ");
  28. Serial.print(okunan);
  29. Serial.print("----");
  30. Serial.println(get_dp);
  31. delay(100);
  32. //---------------------------------------------------------------------------
  33. Wire.beginTransmission(0x41); //
  34. Wire.write(0xF1); //
  35. Wire.endTransmission(); // "Thanks, goodbye..."
  36. Wire.requestFrom(0x41, 3); // request to from 0x21 sensor 3 byte data
  37. okunan = (Wire.read() << 8) | Wire.read();
  38. crc = Wire.read(); // crc reading but not control for error correction :)
  39. get_dp = okunan / 240; // look sdp610-125 datasheet
  40. Serial.print("Sensor2: ");
  41. Serial.print(okunan);
  42. Serial.print("----");
  43. Serial.println(get_dp);
  44. delay(100);
  45. //---------------------------------------------------------------------------
  46. Wire.beginTransmission(0x61); //
  47. Wire.write(0xF1); //
  48. Wire.endTransmission(); // "Thanks, goodbye..."
  49. Wire.requestFrom(0x61, 3); // request to from 0x21 sensor 3 byte data
  50. okunan = (Wire.read() << 8) | Wire.read();
  51. crc = Wire.read(); // crc reading but not control for error correction :)
  52. get_dp = okunan / 240; // look sdp610-125 datasheet
  53. Serial.print("Sensor3: ");
  54. Serial.print(okunan);
  55. Serial.print("----");
  56. Serial.println(get_dp);
  57. delay(100);
  58. //---------------------------------------------------------------------------
  59. Wire.beginTransmission(0x31); //
  60. Wire.write(0xF1); //
  61. Wire.endTransmission(); // "Thanks, goodbye..."
  62. Wire.requestFrom(0x31, 3); // request to from 0x21 sensor 3 byte data
  63. okunan = (Wire.read() << 8) | Wire.read();
  64. crc = Wire.read(); // crc reading but not control for error correction :)
  65. get_dp = okunan / 240; // look sdp610-125 datasheet
  66. Serial.print("Sensor4: ");
  67. Serial.print(okunan);
  68. Serial.print("----");
  69. Serial.println(get_dp);
  70. delay(100);
  71. //---------------------------------------------------------------------------
  72. Wire.beginTransmission(0x39); //
  73. Wire.write(0xF1); //
  74. Wire.endTransmission(); // "Thanks, goodbye..."
  75. Wire.requestFrom(0x39, 3); // request to from 0x21 sensor 3 byte data
  76. okunan = (Wire.read() << 8) | Wire.read();
  77. crc = Wire.read(); // crc reading but not control for error correction :)
  78. get_dp = okunan / 240; // look sdp610-125 datasheet
  79. Serial.print("Sensor5: ");
  80. Serial.print(okunan);
  81. Serial.print("----");
  82. Serial.println(get_dp);
  83. delay(100);
  84. //---------------------------------------------------------------------------
  85. Wire.beginTransmission(0x29); //
  86. Wire.write(0xF1); //
  87. Wire.endTransmission(); // "Thanks, goodbye..."
  88. Wire.requestFrom(0x29, 3); // request to from 0x21 sensor 3 byte data
  89. okunan = (Wire.read() << 8) | Wire.read();
  90. crc = Wire.read(); // crc reading but not control for error correction :)
  91. get_dp = okunan / 240; // look sdp610-125 datasheet
  92. Serial.print("Sensor6: ");
  93. Serial.print(okunan);
  94. Serial.print("----");
  95. Serial.println(get_dp);
  96. delay(100);
  97. //---------------------------------------------------------------------------
  98. Wire.beginTransmission(0x35); //
  99. Wire.write(0xF1); //
  100. Wire.endTransmission(); // "Thanks, goodbye..."
  101. Wire.requestFrom(0x35, 3); // request to from 0x21 sensor 3 byte data
  102. okunan = (Wire.read() << 8) | Wire.read();
  103. crc = Wire.read(); // crc reading but not control for error correction :)
  104. get_dp = okunan / 240; // look sdp610-125 datasheet
  105. Serial.print("Sensor7: ");
  106. Serial.print(okunan);
  107. Serial.print("----");
  108. Serial.println(get_dp);
  109. delay(100);
  110. //---------------------------------------------------------------------------
  111. Wire.beginTransmission(0x40); //
  112. Wire.write(0xF1); //
  113. Wire.endTransmission(); // "Thanks, goodbye..."
  114. Wire.requestFrom(0x40, 3); // request to from 0x21 sensor 3 byte data
  115. okunan = (Wire.read() << 8) | Wire.read();
  116. crc = Wire.read(); // crc reading but not control for error correction :)
  117. get_dp = okunan / 240; // look sdp610-125 datasheet
  118. Serial.print("Sensor8: ");
  119. Serial.print(okunan);
  120. Serial.print("----");
  121. Serial.println(get_dp);
  122. delay(1000);
  123. }