what does?
@Dave1829 I think he might be referring to how it worked that way on the ESP8266 (in another topic)… at least that’s how I interpreted it
@Shadeyman But yes, perhaps add in what Dave mentioned and experiment.
A sketch I used on a NodeMCU runs on this ESP8285, however, I don’t know which pins are the i2c pin on this ESP8285.
The I2C bus needs to know which address to find the sensor. This is in addition to telling the Wire library which pins to use as the I2C bus.
In one of my earlier posts I explained how to edit the Adafruit BME library file to specify which I2C bus address to use for the BME sensor. It appears that you didn’t do it that way, and instead did it with a line in the code (I didn’t realise that you could do that!).
If you’d edited the library file then it would be used in all future code compilations on that PC. If you don’t take that approach then you need both lines of code - one to tell the BME library where to find the sensor on the I2C bus and the other to tell the Wire library which pins to use for I2C.
Not sure if the sequence matters, but I’d guess the Wire command should come first.
Pete.
so a sketch with no bme.begin runs perfectly on the nodeMCU?
//leaves thread.
Also different board, different rules… the full NodeMCU might not require pulldown resistors on the I2C lines, but the ESP8285 might?
@Dave1829 Well of course it had a “bme.begin”, if you’d read the beginning of the thread you’d know that?
As far as I know the ESP8285 is exactly the same as the ESP8266 except it has 1Mb onboard.
sounds like you might need to sleep on it mate
// really leaves thread
Well Dave’s a helpful chap.
So now I’m confused.
I think I’ve found the right sensor pins etc, but what’s happened to the data?
Here’s the code if it will help.
#define BLYNK_PRINT Serial
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
//Setup connection of the sensor
Adafruit_BME280 bme; // I2C
char auth[] = "3efa4091d9fc4ff89e2a43fe454a58ca";
char ssid[] = "BTHub6-P38S";
char pass[] = "wAwhd7rKg3cT";
BlynkTimer timer;
float pressure; //To store the barometric pressure (Pa)
float temperature; //To store the temperature (oC)
int humidity; //To store the humidity (%) (you can also use it as a float variable)
void setup() {
//Wire.begin(int sda, int scl)
bme.begin(0x76); //Begin the sensor
Wire.begin(2, 15);
Serial.begin(9600); //Begin serial communication at 9600bps
Serial.println("Adafruit BME280 test:");
Blynk.begin(auth, ssid, pass);
timer.setInterval(2000L, ReadSensors); // read sensor every 2s
}
void ReadSensors(){
//Read values from the sensor:
pressure = bme.readPressure();
temperature = bme.readTemperature();
humidity = bme.readHumidity ();
Blynk.virtualWrite(V1, pressure/100); // write pressure to V1 value display widget
Blynk.virtualWrite(V2, temperature); // write temperature to V2 value display widget
Blynk.virtualWrite(V3, humidity); // write altimeter to V3 value display widget
//Print values to serial monitor:
Serial.print(F("Pressure: "));
Serial.print(pressure);
Serial.print(" Mb");
Serial.print("\t");
Serial.print(("Temp: "));
Serial.print(temperature);
Serial.print(" °C");
Serial.print("\t");
Serial.print("Humidity: ");
Serial.print(humidity); // this should be adjusted to your local forcase
Serial.println(" %");
//delay(2000); //Update every 2 sec
}
void loop() {
Blynk.run();
timer.run();
}
Where it says “nan” instead of a pressure or temperature value it means “not a number”.
I guess that means that you still have problems communicating with the sensor.
Have you tried running one of the BME sensor code examples that get installed along with the library?
In the Arduino IDE it’s Files/Examples/Adafruit BME280 Library…
You’ll have to edit the article sample to use the correct Wire pins and I2C address.
Pete.
@PeteKnight
Ran i2c Scanner on the specific pins(e.g. Wire.begin(2, 15); ) and found the sensor everytime.
So I think I’ve found out how to chose the pins I want but maybe I’m using a “special” pin like @Costas said in an earlier post, and thats the problem?
The sensor can’t start until i2c is available. Switch these 2 lines around.
Thanks that has stopped it crashing.
I am still puzzled by the pinout issue… if you are using Wire.begin(2, 15);
then that has corresponding numbers for both Arduino and board IO for SDA on Pin 2… but completely wrong for SCL to be on Pin 15??
And yet the address detection worked on those pins… but no data…
So, perhaps the address detection doesn’t require full bus/wire connection…
Try Wire.begin(2, 14);
No joy.
If you guys don’t know, I stand no chance …
The pin settings for the 01M are very confusing and the pinout @Shadeyman provided is only part of schedule.
See http://wiki.ai-thinker.com/_media/esp8266/esp8266_series_modules_user_manual_v1.1.pdf see top of page 6 of the manual (not page 6 of the pdf) for the rest of the pinout.
I2C_SDA is shown as physical pin 7 (with I2C_SCL being physical pin 15).
Do you have SDA and SCL of the sensor connected to physical pins 7 and 15?
So I would say the GPIO’s are 2 and 14 so Wire.begin(2, 14);
should be correct.
AI Thinker don’t appear to classify it as an ESP8285 and just bundle it in with ESP8266.
Are you compiling as ESP8285 or ESP8266?
Try ESP8266.
You probably know that you can compile without uploading and you should try the compile first if you choose ESP8266 (with 1MB).
Don’t connect anything to very, very special pins GPIO 9 and 10 (physical pins 11 and 12) when using ESP8266 compilation.
If compiling works for ESP8266 try an upload. I don’t know how you have the 01M wired up so you might need to try both ck and nodemcu reset settings in the IDE.
@Costas Sorry about the delay replying.
This pin thing was annoying me, so I used i2cScanner and eventually found the sensor using Wire.begin(2, 15); .
I then used BME280 i2c Test and again found it using Wire.begin(2, 15); .
So obviously I tried the sketch with the same setting, Wire.begin(2, 15); .
It was only when I took these snap shots that I realised something. My sketch is using an Adafruit_BME280 bme library, and the test sketches were using BME280I2C bme library. now I’m no expert but is the library causing my problem?