Notifications
Clear all

Help with I2C programming ESP32 and two sensors

27 Posts
5 Users
1 Likes
474 Views
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2502
 

@zander 

OK, using a different library is probably the cause for the extra errors.

Thanks for the explanation.

Anything seems possible when you don't know what you're talking about.


   
Ron reacted
ReplyQuote
(@jaz939)
Member
Joined: 5 months ago
Posts: 13
Topic starter  

Hi guys,

this is at the moment my progress. 

I have run the scanner and I got 0x12 and 0x76. When I run the sketch I'm adding I get the next message in the serial  monitor

Could not read from AQI

I believe we are near to successfully completing the sketch :).

BR

Roman


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2502
 

@jaz939 

I suggest that you insert some println statements into the .cpp file to determine exactly where the function:

bool Adafruit_PM25AQI::read(PM25_AQI_Data *data)

fails. That will help determine what's required to fix the problem.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@jaz939)
Member
Joined: 5 months ago
Posts: 13
Topic starter  

Hi I will look into it.

Can be the problem, that I didn't use I2C address 0x12. If I look in .cpp file I see this I2C address.

If I'm running only PMSA003I the beginning of transition is

PM25 found!
AQI reading success
 
---------------------------------------
Concentration Units (standard)
---------------------------------------
PM 1.0: 5		PM 2.5: 8		PM 10: 13
Concentration Units (environmental)
---------------------------------------
PM 1.0: 5		PM 2.5: 8		PM 10: 13
---------------------------------------
Particles > 0.3um / 0.1L air:1014
Particles > 0.5um / 0.1L air:300
Particles > 1.0um / 0.1L air:61
Particles > 2.5um / 0.1L air:10
Particles > 5.0um / 0.1L air:4
Particles > 10 um / 0.1L air:4
 
 
 
 
 

   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2502
 

@jaz939 

It appears that you've directly copied the 'test' example for the library. So, the setup and execution should be OK as the example code worked fine when you tested it. Presumably, the problem only started after you merged the two module's sketches together.

The read() module has about 9 different conditions which will cause the module to fail. Rather than just 'shotgunning' potential solutions, it seems more efficient to insert some println statements in that module to determine EXACTLY which of those conditions is causing the failure. Once known, we can focus on eliminating that problem.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@jaz939)
Member
Joined: 5 months ago
Posts: 13
Topic starter  

When I run AirQualityV1 I get:

PM25 found!

Sensor error:Communication failure

Could not read from AQI

 

This indicates that BME688 sensor is not connected. 
 

   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2502
 

@jaz939 

So, you're telling me that you have a sensor whose instantiation you're calling aqi and a second, different sensor whose instantiation you're calling bme, but bme reports messages using the identifier AQI ?

In your previous message you said that ended with "could not read from AQI" which is the error message at the point ...

  if (! aqi.read(&data)) {
    Serial.println("Could not read from AQI");
    delay(500);  // try again in a bit!
    return;
  }

Yet now you're claiming a different failure point. 

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@jaz939)
Member
Joined: 5 months ago
Posts: 13
Topic starter  

So guys, 

I have used different combinations and now is working. I didn't learn much I was only lucky to combine two sketches that worked.

 

Thanks for the discussion and help. I will move to next stage to combine the Nextion display 🙂

Roman


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6530
 

@jaz939 Glad to see you got it working.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6530
 

@ will from now on when one of us asks the person with the problem to do something to aid us in troubleshooting and they ignore us, we should unsubscribe.

I have seen this BS attitude too many times. It was fine when I was billing $200 (2000) an hour, I didn't mind waiting then.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@jaz939)
Member
Joined: 5 months ago
Posts: 13
Topic starter  

Hi guys,

@zander did I do something wrong? 

@will hard to say what was wrong. The only thing that comes to my mind is that both sensor called I2C 

if (! aqi.begin_I2C()) {
 
    Serial.println("Could not find PM 2.5 sensor!");
    while (1) delay(10);
  }
 

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6530
 

@jaz939 I2C is designed to handle many devices. It's fairly automatic.

What you did wrong in the sketch has been covered almost from the beginning.

What I was eluding to was a member asked you to try something or asked a question and you ignored them then just popped up with "It's fixed". Good luck in the future.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Page 2 / 2