user31083: I have a NodeMCU, which I program with the Arduino IDE. I have connected a VOC sensor to pins D1, D2, which are the SLC/SDA pins for NodeMCU. They have pull-up resistor at 4,3kohm to 3.3V.
First I used I2C scanner code, provided by Arduino, and got a response that I have the sensor connected at address 0x70, which is the correct address, indicated on the datasheet for the sensor.
After I tried to read values from the sensor with command 0b00001001 (provided in the datasheet also), I only get 0s as output! Probably something weird in the coding, perhaps someone could assist me in what I am doing wrong here?
In the code, I request 100 bytes just to make sure to get everything, but I receive only 32 back. The datasheet says it should be 6 bytes on address 0x9. And I have tried hex and dec form but that doesn't work. Binary is the proper way I assume.
My Output:
Start 
Bytes Available: 32 
Data read: 00000000000000000000000000000000

Code:
#include <Wire.h>

int miscadr = 0b1110000;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  delay(100);
}

void loop() {
  Serial.println();
  Serial.print("Start");
  Serial.println();
  Wire.beginTransmission(miscadr); //Start bit
  Wire.write(0b00001001); //Asking for registry 9
  Wire.endTransmission();
  Wire.requestFrom(miscadr, 100);
  Serial.print("Bytes Available: ");
  while(Wire.available()==0);
  Serial.print(Wire.available());
  Serial.println();
  Serial.print("Data read: ");
  while(Wire.available()!=0) {
    Serial.print(Wire.read());
  }
  Serial.println();
  delay(2000);
}


user31043: If your ESP8266 device NodeMCU is not using the Arduino ESP8266 Library standard pins for I2C ( SDA=2, SCL=14) then you must change the Wire.begin() statement to Wire.begin(SDA, SCL) inserting your values for the SDA and SCL pins. See this note for another ESP breakout (Sparkfun) Arduino ESP8266 Wire

31083: <p>I have a NodeMCU, which I program with the Arduino IDE. I have connected a VOC sensor to pins D1, D2, which are the SLC/SDA pins for NodeMCU. They have pull-up resistor at 4,3kohm to 3.3V.</p>

<p>First I used I2C scanner code, provided by Arduino, and got a response that I have the sensor connected at address 0x70, which is the correct address, indicated on the datasheet for the sensor.</p>

<p>After I tried to read values from the sensor with command 0b00001001 (provided in the datasheet also), I only get 0s as output! Probably something weird in the coding, perhaps someone could assist me in what I am doing wrong here?</p>

<p>In the code, I request 100 bytes just to make sure to get everything, but I receive only 32 back. The datasheet says it should be 6 bytes on address 0x9. And I have tried hex and dec form but that doesn't work. Binary is the proper way I assume.</p>

<p>My Output:</p>

<pre><code>Start 
Bytes Available: 32 
Data read: 00000000000000000000000000000000
</code></pre>

<p>Code:</p>

<pre><code>#include &lt;Wire.h&gt;

int miscadr = 0b1110000;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  delay(100);
}

void loop() {
  Serial.println();
  Serial.print("Start");
  Serial.println();
  Wire.beginTransmission(miscadr); //Start bit
  Wire.write(0b00001001); //Asking for registry 9
  Wire.endTransmission();
  Wire.requestFrom(miscadr, 100);
  Serial.print("Bytes Available: ");
  while(Wire.available()==0);
  Serial.print(Wire.available());
  Serial.println();
  Serial.print("Data read: ");
  while(Wire.available()!=0) {
    Serial.print(Wire.read());
  }
  Serial.println();
  delay(2000);
}
</code></pre>
 31043: <p>If your ESP8266 device NodeMCU is not using the Arduino ESP8266 Library standard pins for I2C ( SDA=2, SCL=14) then you must change the Wire.begin() statement to Wire.begin(SDA, SCL) inserting your values for the SDA and SCL pins. See this note for another ESP breakout (Sparkfun) <a href="https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/using-the-arduino-addon" rel="nofollow noreferrer">Arduino ESP8266 Wire</a></p>
