TroubleshootingArduino

SEN0500 environmental sensor with 3.3V Pro Mini.

userHead anonymous 2022-02-10 04:55:52 879 Views4 Replies

Can you provide me with Arduino code for using the SEN0500 with a 3.3V Pro Mini and I2C communications? I understand that a switch om the SEN0500 must be set to I2C.

2022-06-24 16:20:53

Hi! Each product has an associated wiki. It is recommended that you can refer to the study.

userHeadPic Tonny12138
nluogameno wrote:

The code is missing from the wiki for this sensor. I was able to find the library file which I downloaded from here: https://github.com/DFRobot/DFRobot_EnvironmentalSensor

 

When I try to upload the code to my Arduino Nano Every from the example included with the library, readData, I get the following error message:

 

Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano Every, ATMEGA328"

In file included from C:\Users\Ad Astra\Desktop\readData\readData.ino:23:0: C:\Users\Ad Astra\Documents\Arduino\libraries\DFRobot_EnvironmentalSensor-master\src/DFRobot_EnvironmentalSensor.h:36:16: warning: ISO C++11 requires whitespace after the macro name #define SEN0500/SEN0501_DEFAULT_DEVICE_ADDRESS             0x22 ///< Default device address of SEN0500/SEN0501 sensor is 0x22                ^ C:\Users\Ad Astra\Documents\Arduino\libraries\DFRobot_EnvironmentalSensor-master\src/DFRobot_EnvironmentalSensor.h:36:16: error: expected primary-expression before '/' token #define SEN0500/SEN0501_DEFAULT_DEVICE_ADDRESS             0x22 ///< Default device address of SEN0500/SEN0501 sensor is 0x22                ^ C:\Users\Ad Astra\Desktop\readData\readData.ino:38:52: note: in expansion of macro 'SEN0500' DFRobot_EnvironmentalSensor environment(/*addr = */SEN0500/SEN0501_DEFAULT_DEVICE_ADDRESS, /*pWire = */&Wire);                                                    ^~~~~~~ C:\Users\Ad Astra\Documents\Arduino\libraries\DFRobot_EnvironmentalSensor-master\src/DFRobot_EnvironmentalSensor.h:36:17: error: 'SEN0501_DEFAULT_DEVICE_ADDRESS' was not declared in this scope #define SEN0500/SEN0501_DEFAULT_DEVICE_ADDRESS             0x22 ///< Default device address of SEN0500/SEN0501 sensor is 0x22                 ^ C:\Users\Ad Astra\Desktop\readData\readData.ino:38:52: note: in expansion of macro 'SEN0500' DFRobot_EnvironmentalSensor environment(/*addr = */SEN0500/SEN0501_DEFAULT_DEVICE_ADDRESS, /*pWire = */&Wire);                                                    ^~~~~~~ exit status 1 Error compiling for board Arduino Nano Every.

This report would have more information with"Show verbose output during compilation"option enabled in File -> Preferences. 

2022-08-03 01:44:37
nluogameno wrote:

I solved this issue myself, with more research. I had downloaded the library from github and installed it manually. I was using the 1.00 version of the library. When I updated it using the Arduino IDE Library Manager to 1.01, it worked.

2022-08-03 02:35:09
2 Replies