Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

PM25_Test Compile Error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PM25_Test Compile Error

by jhefler on Tue Aug 25, 2020 12:19 pm

I get this error when I try to compile the unmodified PM25_Test.ino example program from the Adafruit_PM25AQI library:

------------------------------------------------------------------------------------------------------------------------------------------------------
Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Users\jhefl\Documents\Arduino\Sketches\Misc\PM25_test\PM25_test.ino:3:0:
C:\Users\jhefl\Documents\Arduino\libraries\Adafruit_PM25_AQI_Sensor/Adafruit_PM25AQI.h:21:32: fatal error: Adafruit_I2CDevice.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
------------------------------------------------------------------------------------------------------------------------------------------------------
It appears the compiler is looking for library "Adafruit_I2CDevice.h"
I installed the PM25_AQI_Sensor library using the Arduino IDE 1.8.7 Library Manager tool.

Can you help me resolve this issue?

jhefler
 
Posts: 9
Joined: Tue Aug 25, 2020 11:29 am

Re: PM25_Test Compile Error

by mikeysklar on Tue Aug 25, 2020 1:08 pm

Hello jhefler,

Are you trying to connect to this air quality sensor via serial or i2c? This is mentioned in the guide for this product although in an obscure way.

https://learn.adafruit.com/pm25-air-qua ... duino-code

If you are using serial you will not need to install any additional libraries, but you will need to comment out the i2c line '//' and uncomment the baudrate line for serial.

Code: Select all | TOGGLE FULL SIZE
 if (! aqi.begin_I2C()) {      // connect to the sensor over I2C



Code: Select all | TOGGLE FULL SIZE
 //#include <SoftwareSerial.h>
//SoftwareSerial pmSerial(2, 3);

  //pmSerial.begin(9600);

  //if (! aqi.begin_UART(&pmSerial)) { // connect to the sensor over software serial


You will want to install the Adafruit BusIO library to use the default examples i2c settings.

mikeysklar
 
Posts: 1958
Joined: Mon Aug 01, 2016 8:10 pm

Re: PM25_Test Compile Error

by jhefler on Tue Aug 25, 2020 3:33 pm

Thanks for the super fast reply!
That fixed the issue. I am using an Arduino Uno with only one hardware serial port so I will use the software serial connect (when I get the PM25). The I2C PM25 was out of stock when I placed my order.
Thanks again for excellent support.

jhefler
 
Posts: 9
Joined: Tue Aug 25, 2020 11:29 am

Re: PM25_Test Compile Error

by mikeysklar on Tue Aug 25, 2020 5:07 pm

Great. Glad this worked.

mikeysklar
 
Posts: 1958
Joined: Mon Aug 01, 2016 8:10 pm

Re: PM25_Test Compile Error

by jhefler on Tue Aug 25, 2020 5:50 pm

I have another problem.
I am trying to use the SoftwareSerialExample from the Software Serial Library without modifying the code.

If I understand the code correctly, I should connect the Tx Serial Port (pin 1) to the Software Serial Rx (pin 2) and the Rx Serial Port (pin 0) to the Software Serial Tx Port (pin 3). I set the Arduino Serial Monitor to 115200 baud per the code.

Upon starting the sketch, "Goodnight moon!" appears once followed by many backwards question marks. The Arduino Tx LED is active while the marks are printing, then all goes quiet.

The Serial Port baud rate is 115200 per the code and the monitor, but the Software Serial Port baud rate is 38400. I have tried making them the same, but just get gibberish variations. I am pretty sure my hardware is OK because I am using Arduino pin 2 for input from an external clock pulse generator to run a clock sketch with an Adafruit LCD display.

Is the example code intended to use just one Arduino Uno board and the Software monitor, or does it need another Uno?

Appreciate your help.

jhefler
 
Posts: 9
Joined: Tue Aug 25, 2020 11:29 am

Re: PM25_Test Compile Error

by mikeysklar on Wed Aug 26, 2020 11:06 am

You are seeing a baud rate miss match with the question marks. Your wiring is correct to connect RX <--> TX each way.

Make sure your code and console are all starting fresh at 115200. If the settings is even briefly at 38400 for the console you will see gibberish.

mikeysklar
 
Posts: 1958
Joined: Mon Aug 01, 2016 8:10 pm

Re: PM25_Test Compile Error

by jhefler on Wed Aug 26, 2020 12:42 pm

I set all baud rates at 115200. The console prints "Goodnight Moon" once, then descends into gibberish before finally halting. The TX LED is flashing while this is happening, but the RX LED is dark.
Interestingly, the behavior does not change if I comment out lines 53 &53:

52| // if (Serial.available())
53| // mySerial.write(Serial.read());

It appears that the Software Serial Port is receiving data that the Serial Port is transmitting, but the Serial port is not available when the code at line 52 executes. This corresponds to the observation that the RX light does not flash.

With all due respect, have you actually run this sketch on an Arduino Uno? (I have a Rev 3 Uno); that is, Can the Arduino Uno share the serial port? I read another post (Re: Topic: serial.available() not work) that says it cannot.

Thanks for your patience.

jhefler
 
Posts: 9
Joined: Tue Aug 25, 2020 11:29 am

Re: PM25_Test Compile Error

by jhefler on Wed Aug 26, 2020 3:43 pm

PS -
I just pulled the USB plug and powered the Arduino from a battery so the Serial Port would not be shared by the console. I thought if sharing the port were the problem the TX/RX LED's would indicate communications. Unfortunately, there was no TX/RX LED activity.

Ideas?

jhefler
 
Posts: 9
Joined: Tue Aug 25, 2020 11:29 am

Please be positive and constructive with your questions and comments.