Go Down

Topic: Wemos I2C stopped working (Read 209 times) previous topic - next topic


I hope this is the right place to ask this.

My hardware:
An ssd1306 OLED on a Wemos D1 Mini, and a ds18b20 temperature sensor on D4.  All powered from a 10-AMP USB supply.

My project is to simply display the temperature from the ds18b20 on the oled display.  It's been working for weeks.  Until I tried to upload the code to a new Wemos.  Now the program compiles and uploads without error, but I never even get to setup().  (The first thing that setup does is Serial.begin followed by a Serial.print with a welcome message.)

The same sketch on a NodeMCU works fine.
The same sketch on the original Wemos D1 Mini also fails like the new Wemos.

Through lots of head-scratching and experimenting, I've determined that I2C stopped working on the Wemos. (Both of them?)

The I2Cscanner sketch runs just fine on the NodeMCU.  I added more I2C devices and the I2Cscanner on the NodeMCU found all of them.  But the I2Cscanner on the Wemos can't find any I2C devices.

No wiring changed. No code changed - I have double-checked the wiring multiple times: SDA is on D2, SCL is on D1.  I even went to an older IDE with older libraries and the result is the same- no I2C devices found.

Any ideas?


did you select Wemos D1 R2/mini in Tools menu?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.


did you select Wemos D1 R2/mini in Tools menu?


Thank you for your reply.  The sketch had been working for weeks on a Wemos Mini on my bench, and when I went to clone it to another project, I would have bet a week's salary that the correct board setting was "Wemos D1 R1".  

Now since my error is out, can you tell me what is the difference from R1 and R2?
(And what tipped you off to my error?)


OK, with a bit of research, here's the answer (if anyone is interested).

The D1 R1 and D1 R2 are two different boards and have different pin assignments.
My mistake was assuming D1 Mini was based on the D1.

In the D1 R1, pins D1 and D2 are TX (GPIO1) and GPIO16 respectively.
So when I was using the "Wemos D1 R1" as my board in the IDE Tools tab, SCL and SDA were connected to the wrong pins.

The D1 Mini uses the D1 R2 pin mapping, so I needed to use  "Lolin(Wemos) D1 R2 & mini" for my board selection.

Now, I grok.

Go Up