My experiment should actually primarily include the sensor BME280 with its abundance of options such as temperature, humidity, air pressure and altitude derived therefrom, but the display of the measured values on a small OLE display 128x64 px occupied me longer than expected. In order to make you a quick start without my made fall cords, I describe my cornerstones.
Preparations and know-how:
- Both the display and the BME sensor are available in different connection variants: SPI software, SPI hardware and I2C. I am describing my first steps using I2C.
- On I2C, more than 120 components can be connected at the same time.
- You can find the pin assignment for your device in the Datasheet under the label "SCL" and "SDA". With respect to a Particle Photon, it is D1 and D0.
- The wiring is simple: VCC and GND an plus (3.3V DC is sufficient) and minus from the device and both components with SCL and SDA applied to D1 and D0. 10 jumper I have installed.
I started by using the Sparkfun Libary because my compatible sensor from the Far-East was at least similar to the Sparkfun product and I tried the sample sketch from the Libary: it worked right away - the values were a bit off the reality, but on the serial monitor has already done something. Fine.
I also tried the Adafruit Libary, which was maintained in the further course. Since I'm not using the adafruit sensor, I've read the Particle Community (hats off, guys!) and got to these PINs:
// I2C wiring
#define BME_MOSI D0 // = SDA
#define BME_SCK D1 // = SCL
// #define BME_SCK D4
// #define BME_MISO D3
// #define BME_MOSI D2
// #define BME_CS D5
Additional PIN definitions are not required with the I2C protocol.
The object is still defined and comments on the remaining options for SPI hardware / software:
Adafruit_BME280 bme; // I2C
// Adafruit_BME280 bme (BME_CS); // hardware SPI
// Adafruit_BME280 bme (BME_CS, BME_MOSI, BME_MISO, BME_SCK);
No additional resistors are necessary: as I know, the original sensors are always delivered with resistors; it has still tried times with my compatible sensor and get a 4700 Ohm resistor lower values as expected. For long-term use it is recommended to solder the supplied headers.
Compared to the DHT22, a higher accuracy is obtained, a further measured variable and a faster update speed <2 sec. For further information see the BME280 data sheet.
2.) OLE displayAn Adafruit Libary is also available for this and some error messages have occurred during the flashing of the example "ssd1306-128x64" from Libary.
Therefore, I would like to consider these 3 points:
1/3: change the path in order not to have duplicate entries of further Libars of the same name in the sketch (the SSD1306 brings its own GFX-Lib additionally):
#include "Adafruit_SSD1306/Adafruit_GFX.h"
#include "Adafruit_SSD1306/Adafruit_SSD1306.h"
// # include "Adafruit_GFX.h"
// #include "Adafruit_SSD1306.h"
2/3 - comment this function as part of the Libary example:
//int random(int maxRand) {
// return rand() % maxRand;
//}
3/3 - use this HEX code with 0x3C / ignore 0x3D or the HEX data on the back of the OLED // by default, we'll generate the high voltage from the 3.3v line internally! (Neat!)
Display.begin (SSD1306_SWITCHCAPVCC,
I have noticed that the display is very sensitive to a vibration and is not working: with restarting the photon it has then folded again.
3.) Remark to the sketchA nice gimmick is the time display: With setting the TimeZone within setup Time.zone (+2.00);
// setup a timezone
, which is part of the ISO6801 format and the function provided by the photon, no further RTC component is required: Display.println (Time.format(Time.now(), "%H:%M h"));
I have decided not to display the barometric air pressure. The altitude is determined by the sea water level (normal zero) at your location and must be adjusted accordingly.
Update 22.06.2017: check this project for a practical example.
Like my description? You will find more under my account.
Follow me to be notified when I publish new projects!
Here is my Paypal link. You can also send me sensors, which I then like to look at times.
Comments