New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot connect a I2C sensor to ESP32 #62
Comments
I've been having the same issue with a different i2c sensor. Any luck? |
Hello.
Noop. No luck. I have tried different I2C devices.
I gave it up – may be it is not possible to have OLED and I2C sensors togehter on this device.
Regards, jasmin
…________________________________
Von: Douglas Navarro <notifications@github.com>
Gesendet: Monday, October 15, 2018 1:14:50 AM
An: Heltec-Aaron-Lee/WiFi_Kit_series
Cc: Jazzman; Author
Betreff: Re: [Heltec-Aaron-Lee/WiFi_Kit_series] Cannot connect a I2C sensor to ESP32 (#62)
I've been having the same issue with a different i2c sensor. Any luck?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#62 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AU9dGC-ZGMxbxoZopqGJqwV9RfrhMhtCks5uk8VqgaJpZM4W1Rdd>.
|
Ok! ): |
Congratulation!
This is by far more then I have achieved.
Let us know if any progress comes up.
I wonder why the manufacturer is not commenting on this obviously common problem. Also, that you needed external pull-up resistors is not mentioned anywhere.
Could you show us so far your setup?
Warm regards
Jasmin
…________________________________
From: Douglas Navarro <notifications@github.com>
Sent: Tuesday, October 16, 2018 6:24 PM
To: Heltec-Aaron-Lee/WiFi_Kit_series
Cc: Jazzman; Author
Subject: Re: [Heltec-Aaron-Lee/WiFi_Kit_series] Cannot connect a I2C sensor to ESP32 (#62)
Ok! ):
I have made a little bit of progress being able to at least detect the i2c sensor, as well as the oled display, on the i2c bus using this scanner program<espressif/arduino-esp32#977>. I also used external pull-up resistors.
But I'm leaving this aside for now. If I by any chance get back on this issue I'll make sure to update you here.
Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#62 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AU9dGPjbxbptBV-opORtWaIoMWQaGVHzks5ulghYgaJpZM4W1Rdd>.
|
Hello, |
I have no idea, what's going on. |
I have a Heltec 32 Wifi and a BME280. And I see a 76 on channel 1... But also can't read it using the Adafruit libs (No devices found). Scanning I2C Addresses Channel 1 I haven't done the pull-ups yet though... |
I found 2 errors in the Adafruit example program that was stopping my BME280 from working
After those 2 changes. Bingo... 19:23:27.892 -> Temperature = 20.29 *C |
I think I have solved this issue: I tried a sensor on the default I2C pins, 22 (SCL) & 21 (SDA), and it worked. However, after initializing the OLED display, communication with the sensor on pins 22 & 21 stopped working. I discovered here that when the OLED is initialized, it tells the Arduino Wire library to start using pins 15 (SCL) and 4 (SDA) for I2C communications. If I use pins 15, 4 for both the OLED I2C and the sensor I2C, everything works--as long as I initialize the sensor after the OLED display (or, alternatively, initialize the Wire library to use 15, 4 right from the get-go). So basically, using the OLED library has the side-effect of re-assigning the global I2C pins for the esp32 for any Arduino libraries. The simplest solution is to just go with the flow and use the same pins as the OLED for all I2C communications (assuming your I2C sensor device addresses don't collide with the OLED's). |
I can confirm that the above solution of @canadaduane works. At least on Heltec WiFi LoRa 32 v2. This is in a combination of the OLED and the BME280. By random do I here use SoftWire.h, but I guess it can run with the standard Wire.h.
|
Running sample code on itofficeeu's solution with data showed on the display and in serial monitor. |
Thanks, for the information here. However I've found you can use pins 21/22. Iniside
(I don't particularly like that it creates these 'hidden' global object instances even though you may never use them.) The OLED will use So for the sensor bus use Then pass this to the
then it should initialise fine and work on pins 21/22. My modification to the test code from @itofficeeu above is below, (note the use of Hope this helps
|
Taking inspiration from @r1k above, I was able to connect the Adafruit BNO055 to the Heltect OLED ESP 32 wifi kit using the 21/22 pins as well. This was a very helpful post! `#include <Wire.h> int incoming; // the OLED used //Wire sw(PIN_SDA, PIN_SCL); SSD1306 display(0x3C, 4, 15, 16); //Set OLED to default address 0x3C, and pins 4 and 15, with reset at pin 16 double xPos = 0, yPos = 0, headingVel = 0; //velocity = acceldt (dt in seconds) Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28, &Wire1); //Connect to BNO055, with I2C address 0x28, setting Wire1 from Wire.h String strMessageBack; void setup(void) Serial.begin(115200); pinMode(16,OUTPUT); Wire1.begin(21, 22);
while (1); display.drawString(0, 30, "BNO055 found!"); pinMode (LED_BUILTIN, OUTPUT);//Specify that LED pin is output void loop(void) unsigned long tStart = micros(); xPos = xPos + ACCEL_POS_TRANSITION * linearAccelData.acceleration.x; // velocity of sensor in the direction it's facing if (printCount * BNO055_SAMPLERATE_DELAY_MS >= PRINT_DELAY_MS) { while ((micros() - tStart) < (BNO055_SAMPLERATE_DELAY_MS * 1000)) |
|
Dear @r1k is it possible to send a print of Wire.cpp with the modifictaion to work with Wire1? |
I made no changes to wire.cpp, Wire1 is already declared in that file. You just need to initalise it with the correct pin allocation by calling:
and then pass that to the bme object when you create it along with the address to use:
If that doesn't work then check you have the correct physical pins, the clone board I am using is different to the actual Heltec board and I didn't realise to begin with |
@r1k ok thanks |
Hey all, Thanks for all the information here. I'm working with an older I2C motor driver (https://wiki.wemos.cc/products:retired:motor_shield_v1.0.0 ) and I don't have the option of setting the SDA/SCL pins. I've tried using pins 15 & 4 as above, however that doesn't appear to have worked either. Any ideas what I might be doing wrong?
The above code works fine if I comment out the graphics stuff, but as soon as I add it back in, the screen works and the motors don't. |
Try to modifie the arduino.h of the Heltec board, all the boards has a declaration pins in this file you can see where is the file inside of your computer in the arduino IDE option, there try to change the I2c pins for others, compile and see if it’s work
Enviado do Yahoo Mail para iPhone
Em terça-feira, novembro 19, 2019, 7:10 PM, Matthew Macdonald-Wallace <notifications@github.com> escreveu:
Hey all,
Thanks for all the information here.
I'm working with an older I2C motor driver (https://wiki.wemos.cc/products:retired:motor_shield_v1.0.0 ) and I don't have the option of setting the SDA/SCL pins.
I've tried using pins 15 & 4 as above, however that doesn't appear to have worked either.
Any ideas what I might be doing wrong?
#include "Arduino.h"
#include "SPI.h"
#include "U8g2lib.h"
#include "WEMOS_Motor.h"
#ifndef LED_BUILTIN
#define LED_BUILTIN 25
#endif
// setting PWM properties
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;
int buzzer = 13;
U8G2_SSD1306_75X64_NONAME_F_HW_I2C u8g2(U8G2_R0, 16, 15, 4);
Motor M1(0x30,_MOTOR_A, 1000);//Motor A
Motor M2(0x30,_MOTOR_B, 1000);//Motor B
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
// configure LED PWM functionalitites
// attach the channel to the GPIO to be controlled
u8g2.begin();
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.setFontRefHeightExtendedText();
u8g2.setDrawColor(1);
u8g2.setFontPosTop();
u8g2.setFontDirection(0);
}
void loop()
{
int cycleDuration = random(100,3000);
int cyclePauseDuration = random(100,3000);
int cycleRampUpStep = random(100,1500);
int cycleRampDownStep = random(100,1500);
u8g2.clearBuffer();
u8g2.setCursor(0,8);
u8g2.print(cycleDuration);
u8g2.setCursor(0,18);
u8g2.print(cyclePauseDuration);
u8g2.setCursor(0,28);
u8g2.print(cycleRampUpStep);
u8g2.setCursor(0,38);
u8g2.print(cycleRampDownStep);
// increase the LED brightness
for(int dutyCycle = 0; dutyCycle <= 75; dutyCycle++){
// changing the LED brightness with PWM
M1.setmotor( _CW, dutyCycle);
M2.setmotor(_CW, dutyCycle);
u8g2.setCursor(0,0);
u8g2.print(dutyCycle);
u8g2.sendBuffer();
delay(cycleRampUpStep);
}
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(cyclePauseDuration);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// decrease the LED brightness
for(int dutyCycle = 75; dutyCycle >= 0; dutyCycle--){
// changing the LED brightness with PWM
M1.setmotor( _CW, dutyCycle);
M2.setmotor(_CW, dutyCycle);
u8g2.setCursor(0,0);
u8g2.print(dutyCycle);
u8g2.sendBuffer();
delay(cycleRampDownStep);
}
// wait for a second
delay(cycleDuration);
}
The above code works fine if I comment out the graphics stuff, but as soon as I add it back in, the screen works and the motors don't.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Hello.
https://bitbucket.org/christandlg/bmx280mi/src/master/ You can find it in the Arduino IDE libraries. Best regards at all |
Use the BMP180 pressure sensor with a Heltec WiFi Kit 32 at the same time as the built-in OLED display. On the same I2C bus! It is possible! I got it to work. Short video here: https://youtu.be/e1U47JysdzI |
Hi! I have a ESP32 38 pins (https://produto.mercadolivre.com.br/MLB-1717757954-esp-32-38-pinos-_JM) and I want to connect a display OLED 128x32 and a BME280. So, I have connected the display on pins 21 e 22 and the BME280 on pins 4 e 15, but that does'nt work. When I run the code to identify the I2C address from them, I got a message "No I2C devices found". Any tip or help? Anybody who had work with the board ESP32 38 pins? |
Do you know of this tutorial?: |
Yes, I was trying to do that with this site; and I also try only with the bme280 and only with the display, but both does'nt work. When I run the code from Random Tutorials to find de I2C adress, I get the message "No I2C devices found". Also when I run the code bellow, the same message of faill comes. #include <Wire.h> #define I2C_SDA 21 #define SEALEVELPRESSURE_HPA (1013.25) TwoWire I2CBME = TwoWire(0); unsigned long delayTime; void setup() { bool status; // default settings Serial.println("-- Default Test --"); Serial.println(); void loop() { void printValues() { // Convert temperature to Fahrenheit Serial.print("Pressure = "); Serial.print("Approx. Altitude = "); Serial.print("Humidity = "); Serial.println(); I didn't understand which changes I should make in the src file. Following this way: Computer -> Documents -> Arduino -> Libraries -> Softwire -> src -> SoftWire.h, the file that I get is annexed. Is this one who I should change? And if yes, how? Thanks!! |
Brilliant solution: This worked for me on Heltec Wifi Lora v1 .. I used SCL on pin 12 and SDA on pin13 |
Hi, I tried to do the solution here -- using wire1 to make another bus on 21 and 22, in the setup as shown below. I'm using a Heltec-Lora 32 V2. It gets through everything -- wire1 and bme280 initialization and prints "got here" as I wanted, but then when displaying values everything is filled with 0. So it's connecting to the board but not getting anything. Is the board bad? Or is it something with my code or i2c? Thanks!
full code:
It displays |
I have a Heltec Lora 32 v2 with a sensor BMP280 and after searching for hours for finding the issue, it finaly works. Thanks for Canadaduane for his message who was really helpfull. So I connected the two wires of the sensor on the same pin as the Oled screen (15 &4) and it worked with this code: #include <Wire.h> Adafruit_BMP280 bmp; // I2C void setup() { while ( !Serial ) delay(100); // wait for native usb } void show(int t, int a, int p){ void loop() { |
Hello.
I am not able to connect an I2C sensor (BME280) to the Heltec Wifi 32 Kit. I have connected the BME280 to Pin 22 => SDA and Pin 21 => SCL. But I get always the response "No I2C Device found". I tried to run a ESP_I2C_Scanner but I get the response:
Could it be the that the pin layout is wrong?
I am pretty sure the sensor is ok - I have run it on a different Arduino Uno project. I tried a second one with same result. On the other hand the WiFi 32 Kit seems to be ok since I a code running with NTP server time - and it displays the time fine.
Attached you see my project setup and the code of the ESP_I2C_Scanner - do I something wrong?
Warm regards, Jasmin
![setup](https://user-images.gith
ESP_I2C_Scanner.zip
ubusercontent.com/21978392/45917738-4ead4300-be7c-11e8-87fd-184976b5f11a.jpg)
The text was updated successfully, but these errors were encountered: