Thanks for a very good tutorial and video. Just a tip, when you order BME280 on Ebay you will most likely get a BMP280 delivered to you. The BMP280 can only measure temperature and air pressure. That means no humidity is shown.
Well you’d think that would be simple like connect a common ground and I2C SCL to SCL to SDA but no as both devices are configured to be bus masters in a master slave (eg sensor) architecture so do wire.begin(99); that should turn one of them into the slave.
Seba Baciu I’m not sure what you mean, on most boards the Vcc input works across a wide range of 3.3 to 5v as there is an on-board regulator with a low voltage drop out. There are a very few specific boards that operate at 3.3v and have no regulator to minimise power consumption.
@@G6EJD according to the datasheet 4.25V is the Absolute maximum rating for VDD for this device. It would be a better idea to use 3.3V. Seba Baciu is right.
Unless you specifically purchase a BME280 without an on board regulator (there are very few, perhaps 1 in the market) then the device can be operated from 5v. I’m not sure what the confusion is here, ALL bme280 boards have a regulator fitted.
Very helpful. I needed a way to not use the "standard" GPIO pins for the display and, for my purposes, decided to edit the LIquidCrystal_I2C.cpp (include file) by changing the wire.begin() statement to wire.begin(9,10). The I2C interface will now always use those pins, which for my purposes, is fine as I like to keep the lower digitals available for other (non-I2C) instruments and such things as relays. If you do this, put copious comments in your source file so in two years, when a display won't work on the standard pins, you'll know where to look. These are really great videos! Thanks for putting the time into creating them.
Hi I am unable fix i2c device issues with any device connecting with esp8266 did multiple trials to fix but found no solution I will be happy if you could help me finding a solution with i2c oled with esp8266
Benny, the first thing is what size display is it? 1.3” or 0.96” or 0.64” each requires a different driver, next is screen resolution ie 128x64. Most addresses are common, link to the exact display you purchased please. Should have 4-pins Vcc Gnd SCK Sda
G6EJD thanks for replying.. I have 0.96 ssd1306 oled board and yes it has 4pins as you have mentioned .. The problem is with i2c I tried bme280 to figure out the problem and the i2c never finds the address even though I tried defining the clock frequency and pins for the esp8266
@@G6EJD thanks a lot for your time.... I have fixed the issue... it was the jumper wire.... I think wire strands inside the wires were broken...... which made me to run around crazy for 2 days... on the way It helped me learn many things... Adafruit library is working fine so far....thanks a lot for your efforts.... stay safe ..have a fine day...
hello there, i am using wemos d1 r2 with gy-85, i tried everything you have mentioned but the values that the wemos is reading are always constant. I couldn't find the problem, could you please help me
This is a particularly difficult sensor to operate what you should do is run an I2C address scanner to ensure your detecting the 3 devices, there is one in my github general repository. When you are sure the connections are correct then move on to a suitable library but to be honest few exist that work.
I ran i2c address scanner and it found the three devices, i also tried several working scripts for the three devices individually and all of them keep giving me constant values. Could it be some problem in the interaction between the wemos and the sensor? Like should i try the sensor on arduino uno to check if it is working normally?
If the devices have been detected then they are working, the problem is with the libraries most of which don’t work. What I would do is try an adxl345 library and try that device out and then the next and so on.
Finally, I found the problem and i think i should share it with eveyone. First of all, i used two pull-up resistors (4.7K) on the SCL and SDA, this caused the accelerometer and gyroscope of the gy-85 sensor to work but the magnetometer was just giving zero values. on the datasheet of this gy-85 sensor, it says that the magnetometer sensor uses HMC5883L IC but after searching the internet and reading the code on the IC, I found out that the IC is QMC5883. This probably happens when buying this low-cost sensor unfortunately. so the third sensor's problem was solved by using the QMC5883 library instead of HMC5883's library. Thank you for your help anyways.
You set up serial (software serial) ports on each device say on pins D8 and D7 with one D1 configured as D8=Tx and D7=Rx and on the other D1 D8=Rx and D7=Tx the serial poets must be cross connected, but in this example I’ve defined the pins differently so achieving the cross connection as ordinarily D8 goes to D7 and D7 to D8. Therefore wire in my example D8 to D8 and D7 to D7. Then you can can send data from one device and vice-versa. I’d start with a baud rate of 9600 for test purposes. It would be very difficult to do this using a network protocol. There are plenty of software serial examples around including in the IDE Examples
Do you mean devices or buses? If the latter there is little to no support for multiple buses. If using the same I2C devices you have to use an I2C multiplexer if using different I2C addresses then they all have different addresses and all sit on the bus in parallel
@@G6EJD I mean busses. I want to use multiple BME280, but the IC just supports two Addresses - my solution idea was to use multiple busses with each two sensors connected. But would you recommend hardware I2c multiplexer in this case?
There is no working multiple I2C bus library that I have seen, I have tried to instantiate two buses recently but it does not work. You need to use a standard I2C bus multiplexer the base address is the address of the multiplexer then each device is +1 so for the bme280 that would be (say multiplexer base address is #50) then each bme280 would be located at #50, #51, #52, and so-on.
Another factor you never mention is that I2C requires pull-up resistors on the SDA and SCL lines. Improper pull-ups (missing or wrong value) will cause communication errors.
Yes I could have also mentioned that the Arduino and ESP32 and ESP8266 all have weak pull-ups that can be enabled which are enough for short distance normal speed I2C bus communications.
Hello, My ESP32 I2C still aren't working. I'm trying to connect that with MPU6050. I'm using Lolin32 Lite and there are no 21 and 21 pins out. I'm doing: Wire.begin(13, 15); Serial.println(SDA); Serial.println(SCL); That still printing out 21 and 22. When it comes to the libraries I'm using only Wire.h, nothing more. What could be the case?
OK, SDA and SCL will always print out 21 and 22 because they are predefined with the board type you have selected. But this does not matter, as Wire.begin(12,14); is my preferred choice will redefine the I2C pins.As your just using the wire library there should be no other redefinition of the SDA and SCL pins.Getting the 6050 to work is not trivial, are you sure your sending the correct sequences and why try running an I2C scanner to see if the device is responding to it's I2C address. Here's one: github.com/G6EJD/I2C-Device-Scanner If you have further problems let me know so we can hopefully solve it for you. I don't have a 6050 yet to try out, but I have ordered one.
I just tried an ESP32 Lolin Lite with the device scanner and an 5883 connected to 12,14 (sda,scl) as set in the example programme and that finds the device OK. Have you checked your connections?
Yeah, I've checked my connections. That's GY-521 module with MPU6050. It is working fine with Arduino NANO. On saturday I'll try Lolin32 Lite with ADS1115. Maybe my IDE is loading wrong Wire library? Is that possible?
Not sure what library your using but the address has to be somewhere, in the Adafruit version on line 37 is this: #define BME280_ADDRESS (0x77) Which needs to be changed for most non Adafruit products to 0x76 or on the pcb bridge or break the jumper depending on the type, that will bump the address up by 1 then 0x77 would work as a default.
For nearly all of the ESP32 pins (mostly ADC not) you can reconfigure any pins to any function. A lot depends on the libraries your using as sometimes they e.g. wire.begin(sda,scl); then in your programme you might do wire.begin(32,33) and your definition gets ignored because library includes happen first. The way to check is to open the library .cpp and .h files and search for any wire.begin statements and comment them out, then use your own that redefine the pins.
A great video. It seems what you described are not really the problem of I2C devices, but the problem of some of those libraries available out there, in this particular case Adafruit's library. Personally I normally try to avoid Adafruit's libraries, their libraries tend to do too many things with one single library, and therefore bloated and sometime not easy to use. I also try not to mess with the library in order to make the code work, because very soon you might forgot what have you done with the library, or when the library get updated the code will no longer work, or if you share your code on github or somewhere, the code might not work unless you pack with the modified library as the dependency. I usually just uses the good old Wire library for all my I2C needs, it is a little bit more work, but it is what most of the libraries built from.
E-Tinkers, agreed, but Adafruit have greatly improved their libraries and no allow e.g. bme.begin(sda,scl,speed); to override the default pin allocations which is a good improvement, but yes when I made this video that was their problem of using pin definitions suited to only their boards and sensors, fair-enough, but a move to a more open source approach by them is particularly welcomed I think.
@@G6EJD yes, a PR (pull request) on their github library with a good reasoning for such case will normally get accepted and changed in future release...
Check your connections and power source to the RTC. Is there a pattern to the rebooting? Is the RTC designed to be supplied by 3.3v or 5v? Make sure the RTC is getting the correct voltage.
Thanks again for a Great video about problems we usually run into and how to FIX the problem. In going over the video the second time, wouldn't it be good to modify the library name( Copy the standard library then paste it under a slightly different name, unique to your project) for this particular project rather than changing the STANDARD library? It could be a long time before I use the I2C again and with my memory it could be a while before I figure it out. This might resolve problems down the line.
A good idea and observation and in theory yes, but have you tried to do that. For example copying the library and renaming to e.g. Davids_Adafruit_BME280 does not work as there are other dependencies that need to be resolved, not impossible to fix, as I'd then need to copy and rename Adafruit_Sensor and maybe others. The compromise for most applications is to get rid of the Wire.begin() statements and gain the flexibility of being able to define/use other pins with Wire.begin(Sda,Scl) and then the only overhead is the I2C address for non-Adafruit boards. It can become very confusing and convoluted to the inexperienced and I wish it were that easy to resolve.
Some libraries allow the address to be a parameter need to look in .h file if call specified. If using user defined pins just re-define the SDA and SCL definitions before calling the i2c devive/library, don't need to edit the library that way. You didn't mention need some sort of pull-up some cheap sensors have none, so nothing works.
Pull-up resistors, indeed I realise that I left that aspect out. The device pull-ups (pinMode(pin, INPUT_PULLUP); are OK but only about 20K on the Arduino and ~60K on the ESP8266 and I'm not sure of the exact value for the ESP32, but they are described as weak-pullup's so no-where near the more ideal value of ~10K.
Very important hint, I solved the problem by copying changed libraries into the local libraries folder, then with platformio they have 1st priority and the global lib will not be changed. But without your hint, I have never had found the problems. THX
Much thanks for your continued upload of these instructional videos! Contrary to the advice given at 7:22 i had to uncomment Wire.begin in Adafruit_BME280.cpp and put in the pin numbers as follows - // init I2C or SPI sensor interface if (_cs == -1) { // I2C _wire -> begin(21,22); My ESP32 is a " 'Wemos' Wifi&Bluetooth Battery" (which is the name given to it within the 'Boards drop down menu' in Arduino). I had also changed the address of the I2C BME280 within Adafruit_BME280.h to (0X76) as that is what your 'I2C scanner' sketch spat out.. I will now return to your "ESP32 and BMP180 or BME280 and OLED SH1106 or SSD1306 display Weather Forecaster" script and get that working :)
Thanks for the info, amazing way to show the solutions to many problems you encountered, saved me a lot of time on research, thanks a lot again, I do try to do the same as you!
Hey so I just researched more and I found the way to do it without making changes to the library, I'll be uploading a video about it and referencing your video (if you let me to), it will be in spanish tho
Yes, since I made the video many libraries have been updated to allow addresses to be defined thereby removing the need for modifications. However most people can’t find out what pins are clock and data and don’t understand how to approach the problem. Please go ahead and reference my video.
Haha! What are the chances of you posting this today? Spent a while trying to get a Chinese BMP280 on I2C talking over ESP-now. HEX address and library mods discovered the hard way! Thanks for an other very handy demo!
Based on this video, I learned how to edit the LiquidCrystal_I2C #include file to assign GPIO pins 9 & 10 to SDA and SCL respectively for an LCD I2C display. This was necessary because the original application that the LCD display is being added to uses the (default) GPIO 4 & 5 (I think) and those were already assigned. Now while the test sketch runs fine on an ESP8266 without any code for enabling WiFi, when I edit the code to include the display for the original app that does use WiFi, the processor hangs after program loading. I'm also seeing a compile diagnostic that says "WARNING: library LiquidCrystal_I2C claims to run on (avr) architectures(s) and may be incompatible with your current board which runs on (esp8266) architecture(s)". While the compiled code runs fine on the non_WiFi implementation, I have to wonder if it's stepping on something in the esp8266 when the WiFi functionality is active. Has anybody seen this problem? I'm not sure where to go next.
Denny Carlyle, is the library the built-in variant or some other? Probably best to restore the library and see if you can get a clean compilation, Generally you don’t need to redefine the SDA and SCL pins as they are usually assigned to appropriate pins to find which use Serial.println(SDA) to find which pins are in use. In most instances you can ignore the incompatibility messages.
@@G6EJD The library is one that I imported from a site (I forget which) that claimed to be specifically for the 8666 architectures. It was named LiquidCrystal_I2C-master. The instructions were to rename it to LiquidCrystal_I2C and to do that, I had to delete the existing library that had that name. My need to redefine the SDA/SCL pins is because this display is an add-on to an existing application and the "standard" pins were already in use for a load cell interface. Even with the compiler diagnostic, the code runs fine. But when I integrate the LCD code into the existing application which includes WiFi functionality, the processor hangs. I'm probably going to have to learn how to use the run-time debugger (I think there is one in the Arduino IDE). I guess I was hoping for a simple solution.
// i want to connect apds9960 and mpu6050 but it doesn't work //people help me . // i have changed some a little things in the code of apds9960. #include #include "mpu6050.h" #include // Pins #define APDS9960_INT 2 // Needs to be an interrupt pin // Constants // Global Variables SparkFun_APDS9960 apds = SparkFun_APDS9960(); int isr_flag = 0; float tmp; int address_sensor1= 0x68; //binary equivalent is 1001000 int address_sensor2= 0x39; //binary equivalent is 1001001 int accelX, UP, DOWN, LEFT, RIGHT; void setup(){ Serial.begin(115200); //this creates the Serial Monitor Wire.begin(); //this creates a Wire object mpu6050(); Serial.println(); Serial.println(F("--------------------------------")); Serial.println(F("SparkFun APDS-9960 - GestureTest")); Serial.println(F("--------------------------------")); // Initialize interrupt service routine attachInterrupt(0, interruptRoutine, FALLING); // Initialize APDS-9960 (configure I2C and initial values) if ( apds.init() ) { Serial.println(F("APDS-9960 initialization complete")); } else { Serial.println(F("Something went wrong during APDS-9960 init!")); } // Start running the APDS-9960 gesture sensor engine if ( apds.enableGestureSensor(true) ) { Serial.println(F("Gesture sensor is now running")); } else { Serial.println(F("Something went wrong during gesture sensor init!")); }
} void loop(){ Wire.beginTransmission(address_sensor1); //Send a request to begin communication with the device at the specified address Wire.write(0xFC); Wire.write(0xFD); Wire.write(0xFE); Wire.write(0XFF); Wire.endTransmission(); //this ends transmission of data from the arduino to the temperature sensor Wire.requestFrom(0x39,6); //Request Accel Registers (3B - 40)// 0x68 while(Wire.available() < 6); UP = Wire.read()
Good to hear, I've tried to develop a methodical way of checking and inspecting I2C devies becuase I've had so many first time failures and now through a process of checks I can finally get them working first time. As ever the problem is a lack of standards.
this will be a very helpful video working with a: WIFI Bluetooth-compatible Arduino I2C Programmer LILYGO® TTGO T-CAN485 ESP32 CAN RS-485 Board with Modbus 🧐 thanks as Mary Poppins "1964" would say this is a Supercalifradgilisticexpialidocious how to video... 😍
It’s a colloquialism! How do I say C4I then? Or C6, I come from a military environment where I’d be laughed at if I said ‘I squared C’ anyway being English that’s the way I say it - sorry.
Good go through debugging of I²C
"An expert is a man who has made all the mistakes which can be made, in a narrow field." -- Niels Bohr
Thanks for a very good tutorial and video. Just a tip, when you order BME280 on Ebay you will most likely get a BMP280 delivered to you. The BMP280 can only measure temperature and air pressure. That means no humidity is shown.
Hi, I need to make an I2C communication between an Esp 32 and Esp8266, where can I find info about?
Well you’d think that would be simple like connect a common ground and I2C SCL to SCL to SDA but no as both devices are configured to be bus masters in a master slave (eg sensor) architecture so do wire.begin(99); that should turn one of them into the slave.
For I2C to BME280 example the voltage pin is 5V going to a 3V pin on BME? is not the opposite side pin on the board, close to the reset?
Seba Baciu I’m not sure what you mean, on most boards the Vcc input works across a wide range of 3.3 to 5v as there is an on-board regulator with a low voltage drop out. There are a very few specific boards that operate at 3.3v and have no regulator to minimise power consumption.
@@G6EJD according to the datasheet 4.25V is the Absolute maximum rating for VDD for this device. It would be a better idea to use 3.3V. Seba Baciu is right.
Unless you specifically purchase a BME280 without an on board regulator (there are very few, perhaps 1 in the market) then the device can be operated from 5v. I’m not sure what the confusion is here, ALL bme280 boards have a regulator fitted.
@@G6EJD Right, if there is an regulator. However there're many bme280 boards without regulator for esp 32/8266.
Can you give me a link to one without a regulator then? I’m still not sure what the confusion is about!
Very helpful. I needed a way to not use the "standard" GPIO pins for the display and, for my purposes, decided to edit the LIquidCrystal_I2C.cpp (include file) by changing the wire.begin() statement to wire.begin(9,10). The I2C interface will now always use those pins, which for my purposes, is fine as I like to keep the lower digitals available for other (non-I2C) instruments and such things as relays. If you do this, put copious comments in your source file so in two years, when a display won't work on the standard pins, you'll know where to look. These are really great videos! Thanks for putting the time into creating them.
This worked great for me. Thank you very much :P
Hi I am unable fix i2c device issues with any device connecting with esp8266 did multiple trials to fix but found no solution I will be happy if you could help me finding a solution with i2c oled with esp8266
Benny, the first thing is what size display is it? 1.3” or 0.96” or 0.64” each requires a different driver, next is screen resolution ie 128x64.
Most addresses are common, link to the exact display you purchased please. Should have 4-pins Vcc Gnd SCK Sda
G6EJD thanks for replying.. I have 0.96 ssd1306 oled board and yes it has 4pins as you have mentioned .. The problem is with i2c I tried bme280 to figure out the problem and the i2c never finds the address even though I tried defining the clock frequency and pins for the esp8266
Benny, what driver are you using? I find the Adafruit versions don’t won’t if not their displays
@@G6EJD thanks a lot for your time.... I have fixed the issue... it was the jumper wire.... I think wire strands inside the wires were broken...... which made me to run around crazy for 2 days... on the way It helped me learn many things...
Adafruit library is working fine so far....thanks a lot for your efforts.... stay safe ..have a fine day...
DuPont cables are notoriously bad for faults, been there, done that too!
hello there,
i am using wemos d1 r2 with gy-85, i tried everything you have mentioned but the values that the wemos is reading are always constant. I couldn't find the problem, could you please help me
This is a particularly difficult sensor to operate what you should do is run an I2C address scanner to ensure your detecting the 3 devices, there is one in my github general repository. When you are sure the connections are correct then move on to a suitable library but to be honest few exist that work.
I ran i2c address scanner and it found the three devices, i also tried several working scripts for the three devices individually and all of them keep giving me constant values. Could it be some problem in the interaction between the wemos and the sensor? Like should i try the sensor on arduino uno to check if it is working normally?
If the devices have been detected then they are working, the problem is with the libraries most of which don’t work. What I would do is try an adxl345 library and try that device out and then the next and so on.
Ok i will try that
Finally, I found the problem and i think i should share it with eveyone.
First of all, i used two pull-up resistors (4.7K) on the SCL and SDA, this caused the accelerometer and gyroscope of the gy-85 sensor to work but the magnetometer was just giving zero values. on the datasheet of this gy-85 sensor, it says that the magnetometer sensor uses HMC5883L IC but after searching the internet and reading the code on the IC, I found out that the IC is QMC5883. This probably happens when buying this low-cost sensor unfortunately. so the third sensor's problem was solved by using the QMC5883 library instead of HMC5883's library.
Thank you for your help anyways.
I want 2 Wemos D1 Minis to talk to each other...how do I wire and configure
it?
You set up serial (software serial) ports on each device say on pins D8 and D7 with one D1 configured as D8=Tx and D7=Rx and on the other D1 D8=Rx and D7=Tx the serial poets must be cross connected, but in this example I’ve defined the pins differently so achieving the cross connection as ordinarily D8 goes to D7 and D7 to D8. Therefore wire in my example D8 to D8 and D7 to D7.
Then you can can send data from one device and vice-versa. I’d start with a baud rate of 9600 for test purposes.
It would be very difficult to do this using a network protocol. There are plenty of software serial examples around including in the IDE Examples
how would you use several i2c busses with this method?
Do you mean devices or buses? If the latter there is little to no support for multiple buses. If using the same I2C devices you have to use an I2C multiplexer if using different I2C addresses then they all have different addresses and all sit on the bus in parallel
@@G6EJD I mean busses. I want to use multiple BME280, but the IC just supports two Addresses - my solution idea was to use multiple busses with each two sensors connected. But would you recommend hardware I2c multiplexer in this case?
There is no working multiple I2C bus library that I have seen, I have tried to instantiate two buses recently but it does not work. You need to use a standard I2C bus multiplexer the base address is the address of the multiplexer then each device is +1 so for the bme280 that would be (say multiplexer base address is #50) then each bme280 would be located at #50, #51, #52, and so-on.
Another factor you never mention is that I2C requires pull-up resistors on the SDA and SCL lines. Improper pull-ups (missing or wrong value) will cause communication errors.
Yes I could have also mentioned that the Arduino and ESP32 and ESP8266 all have weak pull-ups that can be enabled which are enough for short distance normal speed I2C bus communications.
Hello,
My ESP32 I2C still aren't working. I'm trying to connect that with MPU6050. I'm using Lolin32 Lite and there are no 21 and 21 pins out. I'm doing:
Wire.begin(13, 15);
Serial.println(SDA);
Serial.println(SCL);
That still printing out 21 and 22.
When it comes to the libraries I'm using only Wire.h, nothing more.
What could be the case?
OK, SDA and SCL will always print out 21 and 22 because they are predefined with the board type you have selected. But this does not matter, as Wire.begin(12,14); is my preferred choice will redefine the I2C pins.As your just using the wire library there should be no other redefinition of the SDA and SCL pins.Getting the 6050 to work is not trivial, are you sure your sending the correct sequences and why try running an I2C scanner to see if the device is responding to it's I2C address. Here's one: github.com/G6EJD/I2C-Device-Scanner If you have further problems let me know so we can hopefully solve it for you. I don't have a 6050 yet to try out, but I have ordered one.
Still nothing. I've tried Device Scanner and it doesn't find any device. My code is good for sure, becase it rns fine with arduino.
I just tried an ESP32 Lolin Lite with the device scanner and an 5883 connected to 12,14 (sda,scl) as set in the example programme and that finds the device OK. Have you checked your connections?
Do you have the 6050 working OK on an Arduino UNO?
Sparkfun have a mature library for the 6050 with testing examples.
Yeah, I've checked my connections.
That's GY-521 module with MPU6050. It is working fine with Arduino NANO.
On saturday I'll try Lolin32 Lite with ADS1115.
Maybe my IDE is loading wrong Wire library? Is that possible?
Opened bme280.h file in notepad++ and can find no address to change
Not sure what library your using but the address has to be somewhere, in the Adafruit version on line 37 is this:
#define BME280_ADDRESS (0x77)
Which needs to be changed for most non Adafruit products to 0x76 or on the pcb bridge or break the jumper depending on the type, that will bump the address up by 1 then 0x77 would work as a default.
I'm trying to get I2C to work on ESP32 pins 32 and 33. Will I have issues changing to these pins if their not hardware SDA and SCL
For nearly all of the ESP32 pins (mostly ADC not) you can reconfigure any pins to any function. A lot depends on the libraries your using as sometimes they e.g. wire.begin(sda,scl); then in your programme you might do wire.begin(32,33) and your definition gets ignored because library includes happen first. The way to check is to open the library .cpp and .h files and search for any wire.begin statements and comment them out, then use your own that redefine the pins.
G6EJD sounds good. I'll give it a go
A great video. It seems what you described are not really the problem of I2C devices, but the problem of some of those libraries available out there, in this particular case Adafruit's library. Personally I normally try to avoid Adafruit's libraries, their libraries tend to do too many things with one single library, and therefore bloated and sometime not easy to use. I also try not to mess with the library in order to make the code work, because very soon you might forgot what have you done with the library, or when the library get updated the code will no longer work, or if you share your code on github or somewhere, the code might not work unless you pack with the modified library as the dependency. I usually just uses the good old Wire library for all my I2C needs, it is a little bit more work, but it is what most of the libraries built from.
E-Tinkers, agreed, but Adafruit have greatly improved their libraries and no allow e.g. bme.begin(sda,scl,speed); to override the default pin allocations which is a good improvement, but yes when I made this video that was their problem of using pin definitions suited to only their boards and sensors, fair-enough, but a move to a more open source approach by them is particularly welcomed I think.
@@G6EJD yes, a PR (pull request) on their github library with a good reasoning for such case will normally get accepted and changed in future release...
Thanks for your tutorial. But my ESP32 reboots some times when I use RTC DS3231 chip, I can fix it
Check your connections and power source to the RTC. Is there a pattern to the rebooting? Is the RTC designed to be supplied by 3.3v or 5v? Make sure the RTC is getting the correct voltage.
Thanks again for a Great video about problems we usually run into and how to FIX the problem. In going over the video the second time, wouldn't it be good to modify the library name( Copy the standard library then paste it under a slightly different name, unique to your project) for this particular project rather than changing the STANDARD library? It could be a long time before I use the I2C again and with my memory it could be a while before I figure it out. This might resolve problems down the line.
A good idea and observation and in theory yes, but have you tried to do that.
For example copying the library and renaming to e.g. Davids_Adafruit_BME280 does not work as there are other dependencies that need to be resolved, not impossible to fix, as I'd then need to copy and rename Adafruit_Sensor and maybe others. The compromise for most applications is to get rid of the Wire.begin() statements and gain the flexibility of being able to define/use other pins with Wire.begin(Sda,Scl) and then the only overhead is the I2C address for non-Adafruit boards. It can become very confusing and convoluted to the inexperienced and I wish it were that easy to resolve.
The scanner appeared to be extremely useful. Thank you so much !!!
Some libraries allow the address to be a parameter need to look in .h file if call specified. If using user defined pins just re-define the SDA and SCL definitions before calling the i2c devive/library, don't need to edit the library that way. You didn't mention need some sort of pull-up some cheap sensors have none, so nothing works.
Pull-up resistors, indeed I realise that I left that aspect out. The device pull-ups (pinMode(pin, INPUT_PULLUP); are OK but only about 20K on the Arduino and ~60K on the ESP8266 and I'm not sure of the exact value for the ESP32, but they are described as weak-pullup's so no-where near the more ideal value of ~10K.
Very important hint, I solved the problem by copying changed libraries into the local libraries folder, then with platformio they have 1st priority and the global lib will not be changed. But without your hint, I have never had found the problems. THX
thank you without this video i probably would not have though to change the bus adress from the library
Thank you. This was very helpful.
Much thanks for your continued upload of these instructional videos! Contrary to the advice given at 7:22 i had to uncomment Wire.begin in Adafruit_BME280.cpp and put in the pin numbers as follows -
// init I2C or SPI sensor interface
if (_cs == -1) {
// I2C
_wire -> begin(21,22);
My ESP32 is a " 'Wemos' Wifi&Bluetooth Battery" (which is the name given to it within the 'Boards drop down menu' in Arduino).
I had also changed the address of the I2C BME280 within Adafruit_BME280.h to (0X76) as that is what your 'I2C scanner' sketch spat out..
I will now return to your "ESP32 and BMP180 or BME280 and OLED SH1106 or SSD1306 display Weather Forecaster" script and get that working :)
Thank you for this video! Had to make a deeper cut on my BME/BMP280 to change the I2C adress..
yes some PCB's have quite thick copper.
It helps a lot, many thanks for spending time for such valuable lesson.. I hope you doing good as in good in many good things, truly
Thanks for the info, amazing way to show the solutions to many problems you encountered, saved me a lot of time on research, thanks a lot again, I do try to do the same as you!
Hey so I just researched more and I found the way to do it without making changes to the library, I'll be uploading a video about it and referencing your video (if you let me to), it will be in spanish tho
Yes, since I made the video many libraries have been updated to allow addresses to be defined thereby removing the need for modifications. However most people can’t find out what pins are clock and data and don’t understand how to approach the problem. Please go ahead and reference my video.
@@G6EJD If it wasn't for your video I wouldnt Have found the solution! Ill go ahead and make it
Haha! What are the chances of you posting this today? Spent a while trying to get a Chinese BMP280 on I2C talking over ESP-now. HEX address and library mods discovered the hard way!
Thanks for an other very handy demo!
Been there - done that :)
Based on this video, I learned how to edit the LiquidCrystal_I2C #include file to assign GPIO pins 9 & 10 to SDA and SCL respectively for an LCD I2C display. This was necessary because the original application that the LCD display is being added to uses the (default) GPIO 4 & 5 (I think) and those were already assigned. Now while the test sketch runs fine on an ESP8266 without any code for enabling WiFi, when I edit the code to include the display for the original app that does use WiFi, the processor hangs after program loading. I'm also seeing a compile diagnostic that says "WARNING: library LiquidCrystal_I2C claims to run on (avr) architectures(s) and may be incompatible with your current board which runs on (esp8266) architecture(s)". While the compiled code runs fine on the non_WiFi implementation, I have to wonder if it's stepping on something in the esp8266 when the WiFi functionality is active. Has anybody seen this problem? I'm not sure where to go next.
Denny Carlyle, is the library the built-in variant or some other? Probably best to restore the library and see if you can get a clean compilation, Generally you don’t need to redefine the SDA and SCL pins as they are usually assigned to appropriate pins to find which use Serial.println(SDA) to find which pins are in use. In most instances you can ignore the incompatibility messages.
Try including esp8266 WiFi first if not already.
@@G6EJD The library is one that I imported from a site (I forget which) that claimed to be specifically for the 8666 architectures. It was named LiquidCrystal_I2C-master. The instructions were to rename it to LiquidCrystal_I2C and to do that, I had to delete the existing library that had that name. My need to redefine the SDA/SCL pins is because this display is an add-on to an existing application and the "standard" pins were already in use for a load cell interface. Even with the compiler diagnostic, the code runs fine. But when I integrate the LCD code into the existing application which includes WiFi functionality, the processor hangs. I'm probably going to have to learn how to use the run-time debugger (I think there is one in the Arduino IDE). I guess I was hoping for a simple solution.
@@G6EJD Good idea. I just looked at the original source and that library is not there. Surprising that it works at all. I'll visit github.
Denny Carlyle it’s now inbuilt in the IDE
Thank you soo much for this video, u are an angel !!
// i want to connect apds9960 and mpu6050 but it doesn't work
//people help me .
// i have changed some a little things in the code of apds9960.
#include
#include "mpu6050.h"
#include
// Pins
#define APDS9960_INT 2 // Needs to be an interrupt pin
// Constants
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
float tmp;
int address_sensor1= 0x68; //binary equivalent is 1001000
int address_sensor2= 0x39; //binary equivalent is 1001001
int accelX, UP, DOWN, LEFT, RIGHT;
void setup(){
Serial.begin(115200); //this creates the Serial Monitor
Wire.begin(); //this creates a Wire object
mpu6050();
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - GestureTest"));
Serial.println(F("--------------------------------"));
// Initialize interrupt service routine
attachInterrupt(0, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Start running the APDS-9960 gesture sensor engine
if ( apds.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running"));
} else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
}
void loop(){
Wire.beginTransmission(address_sensor1); //Send a request to begin communication with the device at the specified address
Wire.write(0xFC);
Wire.write(0xFD);
Wire.write(0xFE);
Wire.write(0XFF);
Wire.endTransmission(); //this ends transmission of data from the arduino to the temperature sensor
Wire.requestFrom(0x39,6); //Request Accel Registers (3B - 40)// 0x68
while(Wire.available() < 6);
UP = Wire.read()
Thanks, great clear video once again.
Thanks David that's going to save me heaps of time
Good to hear, I've tried to develop a methodical way of checking and inspecting I2C devies becuase I've had so many first time failures and now through a process of checks I can finally get them working first time. As ever the problem is a lack of standards.
Great tutorial. Thanks
Thanks a lot. You solved my problem.
this will be a very helpful video working with a: WIFI Bluetooth-compatible Arduino I2C Programmer LILYGO® TTGO T-CAN485 ESP32 CAN RS-485 Board with Modbus 🧐 thanks
as Mary Poppins "1964" would say this is a Supercalifradgilisticexpialidocious how to video... 😍
It's I squared C, not I two C.
It’s a colloquialism! How do I say C4I then? Or C6, I come from a military environment where I’d be laughed at if I said ‘I squared C’ anyway being English that’s the way I say it - sorry.
Thank you.its great...
ESP32 I2C PIN NUMBERS
Thanks a lot sir
good, thanks a lot
thanks you
WOW thankssss ALOT
Glad you liked the video, I hope it helped
Thank you that was very informative.