Hi guys,
this is a continuing discussion about getting help for I2C programming in ESP32. I want to get data from two sensors (PMSA003I and BME688).
I'm noby in Arduino programming and I still learning how to do this. I would be very happy if I could learn how to do this.
Thanks
Jaz939
Have you done the two searches on Google "ESP32 BME688" and then "ESP32 PMSA003I"? There seems to be plenty of tutorials and pre-made sketches on either. Combining should be a matter of just wiring the same pins from the ESP32 to both sensors as they have different I2C addresses and they can run on the same two I2C pins. Then combine the sketches to do what you want. If your searches don't provide enough information, then you need to provide more of an explanation here as to what you're having troubles with.
3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide
Hi,
I successfully run each sensor separately. When combining both together I get an error. If you now how to change the program and show me how I would appreciate it.
Hi @jaz939,
The first problem that glares at me, and will you soon, is that you are asking for two variables of different types, in the same function, setup, but expecting them to have the same name 'data'.
This is like having two children in the same room, both called Fred. Every time you refer to Fred, they don't know which one you are talking too!
PM25_AQI_Data data;
---
bme68xData data;
--------------------
I haven't been through the rest of the code, but perhaps it would be educational to you to have a go fixing this bug, and then assess where you are.
Best wishes and good luck, Dave
@jaz939 I hacked together your code with some working BME680 code. I commented out your failing code and substituted working code. Have a look and see if this is close. If so, delete the commented out lines that are no good. I suspect there are still errors but now you can start testing.
After you delete all the extraneous code, use menu Tools/Autoformat and then manually make the code look good so it is easier to read.
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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@davee That is just one of many, I had to delete almost all his 680 code and just dripped in a sample. It compiles but I have no way to test yet.
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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Hi,
@davee I get your point with naming.
@zander thanks for this but I prefer the library bsec. With this library, I can get the air quality index IAQ. In your program I see few thinks I can use.
I must start to understand each line of code. Also, I must teach how to decelerate the sensor so that I can read the data from it.
How does the sketch communicate with the library?
BR
Jaz939
@davee I have renamed one of the variable names. So no error. Still have to work on one of the sensors. Now the sensor is not visible.
@jaz939 Ok, good luck.
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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
I didn't understand your last post, but try changing the ;act part of your sketch as follows ...
//****************************************** //BME688 bme68xData bme68xData; bme.setOpMode(BME68X_FORCED_MODE); delayMicroseconds(bme.getMeasDur()); if (bme.fetchData()) { bme.getData(bme68xData); Serial.print("Time: "+ String(millis()) + ", "); Serial.print("Temp: "+ String(bme68xData.temperature) + "°C, "); Serial.print("Pressure: "+ String(bme68xData.pressure) + "Pa, "); Serial.print("Humidity: "+ String(bme68xData.humidity) + "%, "); Serial.print("Gas: "+ String(bme68xData.gas_resistance) + "ohm, "); Serial.println(bme68xData.status, HEX); } delay(1000);
I'm confused because you're talking about Arduino programming but mentioned a ESP32 in the first post. So, I've assumed that you meant that you were using an ESP32 in the Arduino IDE.
After modifying your sketch to the above, I then selected the DOIT ESP32 DEVKIT V1 and compiled the sketch. It compiled clean and gave the following stats ...
Anything seems possible when you don't know what you're talking about.
@davee I have renamed one of the variable names. So no error. Still have to work on one of the sensors. Now the sensor is not visible.
I modified the code you posted and also changed the name of one sensor but where you got no error, I still have a terminal error.
Can you explain this?
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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Hi @jaz939,
I assume you did the same change as @Will posted.
I have done the same, and selected 'ESP32 Dev Module', to match my processor card.
This compiles without error, (confirming @Will's experience), and runs as far as expected, which sadly is only to say "Could not find PM 2.5 sensor!" in the Serial Monitor, as I don't have either of the required sensors.
It is obviously difficult for us to help with problems we can't see, but we may be able to suggest something if you explain exactly what is happening, showing error messages etc. Sorry but "Now the sensor is not visible. " doesn't even say which sensor you are referring to.
Maybe provide us with full update? Don't forget to include any code changes, or a new listing if there are several changes.
Best wishes, Dave
@davee That's strange, I get a missing include error because the include is spelled wrong. After fixing that there is 2 dozen errors. I used the code the OP posted and default error checking.
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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Which include was spelled incorrectly ? I googled both
Anything seems possible when you don't know what you're talking about.
@will I got the missing include on #include"bme68xLibrary.h" so removed the suspicious looking Library part and used bme68x.h which is in the Adafruit680 library. Sounds like your solution is better so I will delete all my files to do with this as it is a false trail. Thanks.
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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.