0

I'm using an OLED 128*64 display screen with NodeMCU ESP8266. when I tried to detect the screen address, the serial monitor shows: enter image description here

It would be kind if someone can tell me what is the problem ? and how t solve it ?

Mari
  • 3
  • 6
  • Exactly how is your I2C device wired to your ESP8266? – romkey Aug 25 '21 at 18:34
  • It is connected like this: SCL of the oled with D1 of the nodemcu , SDA of oled with S2 of nodemcu , GND of oled with GND of nodemcu , VCC of oled with 3V3 of nodemcu – Mari Aug 26 '21 at 07:22
  • Do you have Pull Up resistors? – 0andriy Aug 27 '21 at 14:11
  • No I don't. Shall I have. – Mari Aug 28 '21 at 20:07
  • Yes. It's a must. Read the I²C electrical specifications to understand how it works. Note, you need to have an oscilloscope at hand to debug I²C issues (most of them come from electrical perspective rather than software). – 0andriy Aug 29 '21 at 14:52
  • How many pull up resistors I need and where shall I put it. I don't know a lot about this and I need to fix it cause it's my graduation project. please help me. – Mari Aug 30 '21 at 16:01

3 Answers3

1

Hi Mari please try this I2c tester: it will give you the number of devices and their addresses

#include <Wire.h>

byte errorResult;           // error code returned by I2C 
byte i2c_addr;              // I2C address being pinged
byte lowerAddress = 0x08;   // I2C lowest valid address in range
byte upperAddress = 0x77;   // I2C highest valid address in range
byte numDevices;            // how many devices were located on I2C bus

void setup() {
  Wire.begin();             // I2C init
  Serial.begin(115200);       // search results show up in serial monitor
}

void loop() {
    if (lowerAddress < 0x10)                                // pad single digit addresses with a leading "0"
  Serial.print("0");
  Serial.print(lowerAddress, HEX);
  Serial.print(" to 0x");
  Serial.print(upperAddress, HEX);
  Serial.println(".");

  numDevices = 0;

  for (i2c_addr = lowerAddress; i2c_addr <= upperAddress; i2c_addr++ ) 
    // loop through all valid I2C addresses
  {
    Wire.beginTransmission(i2c_addr);                     // initiate communication at current address
    errorResult = Wire.endTransmission();                 // if a device is present, it will send an ack and "0" will be returned from function

    if (errorResult == 0)                                 // "0" means a device at current address has acknowledged the serial communication
    {
      Serial.print("I2C device found at address 0x");

      if (i2c_addr < 0x10)                                // pad single digit addresses with a leading "0"
        Serial.print("0");

      Serial.println(i2c_addr, HEX);                      // display the address on the serial monitor when a device is found
      numDevices++;
    }
  }

  Serial.print("Scan complete.  Devices found: ");
  Serial.println(numDevices);
  Serial.println();

  delay(10000);                                           // wait 10 seconds and scan again to detect on-the-fly bus changes
}
Luca Spuntoni
  • 252
  • 1
  • 10
  • I tried the code you post but this error appeared: try:4:1: error: 'Wire' does not name a type 4 | Wire.endTransmission() | ^~~~ C:\Users\TOSHIBA\Desktop\try\try.ino: In function 'void loop()': try:26:8: error: 'i2c_addr' was not declared in this scope 26 | for (i2c_addr = lowerAddress; i2c_addr <= upperAddress; i2c_addr++ ) | ^~~~~~~~ exit status 1 'Wire' does not name a type – Mari Sep 11 '21 at 13:05
  • Hi Mary, ' Wire.endTransmission()' was not on my orginal code, sorry about that, I don't know how got there. I re checked and corrected the code removing that line, please try it again, it works. please let me know. All the best – Luca Spuntoni Sep 11 '21 at 19:53
  • You are welcome, if you wish please let me know how it goes, I am interested about that. Thank you. – Luca Spuntoni Sep 12 '21 at 14:15
  • Ok I well, insha'Allah. – Mari Sep 14 '21 at 05:24
  • It should be connected with Pulse Oximeter MAX30100, but we didn't found it in the market, we found MAX30102. It does the same thing but the code should be altered cause Max30102 works with another library which doesn't support a direct function or parameters to get heart rate and oxygen saturation as the Max30100 library do☹️. – Mari Sep 14 '21 at 05:34
  • And that is what I got stuck in. – Mari Sep 14 '21 at 05:36
  • I appreciate the importance of the interfacing of a Pulse Oximeter in these times, please see this reference: https://makersportal.com/blog/2019/6/24/arduino-heart-rate-monitor-using-max30102-and-pulse-oximetry . If you have solved the I2c interfacing issue, I would suggest to accept the answer and open a new more specific question on Pulse Oximeter interfacing. All the best – Luca Spuntoni Sep 14 '21 at 07:42
  • Thanks.. yeah I have solved the the I2C interfacing issue.. again thanks – Mari Sep 14 '21 at 11:27
0

the wiring should be for I2C connection: D2 -> SDA, D1 -> SCL, GND -> GND, (*) -> Vcc

(*) check what oled model you have, some work at +5V other at +3.3V that might be the issue Moreover usually the pullup resistor is not needed (check your model specs) Check also the specification of your oled, sometimes some jumper setup is needed

Luca Spuntoni
  • 252
  • 1
  • 10
  • it is connected the same way. I checked the specification of the oled and it needs 3.3V -6V supply voltage. – Mari Sep 04 '21 at 13:55
0

I found the problem: I didn't insert the nodemcu properly inside the board.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Mari
  • 3
  • 6