ESP8285 i2c Pins

I recently compiled my first sketch, yes I had a lot of help from you guys but I’m taking most of the credit because I brought the chips. :sweat_smile:

My sketch has run on a NodeMCU perfectly all day and i wondered if I could compile it to run on the tiny ESP-01M(ESP8285). It did, all I need to do now is figure out which pins are the i2c(SDA, SCL) pins.

esp-01m-04-350x325

I have the ESP-01(ESP8285) User Manual but being a complete noob I only see 1 i2c pin(15) and I’ve no idea where to start looking for the other as I tried the “stick it in a hope” trick and that didn’t work. So some pointers please guys, hints and a push in the right direction.

You can decide which pins to use but don’t use “special” pins http://arduino-esp8266.readthedocs.io/en/latest/libraries.html#i2c-wire-library

1 Like

WOW! So I can actually tell it what pins I want to use by adding something like this to the sketch:

Wire.begin(int sda, int scl)
Wire.begin(12, 14)

Yes but I said don’t use special pins.

1 Like

And 15 is SCL per you pinout table for the 01M.

1 Like

So I could use 12(sda) and 15(scl) as 15 is already scl and as I’ve no idea where sda is and 12 isn’t a special pin as far as I can tell I could that as sda?

Yes but remember 12 and 15 are the pin labels and not GPIO numbers. Don’t know if the IDE for the 8285 will expect GPIO numbers or if the IDE does a translation of the pins etc. Normally it’s best to use GPIO numbers and then your code is portable to other ESP’s.

1 Like

Yes, pin 15 is actually GPIO14?

Why do they do that, its very confusing.

Yes so use wire.begin(10, 15) all GPIO references.

Not sure what I’m doing wrong but

Wire.begin(int sda, int scl)
Wire.begin(10, 15)

isn’t working for me.
Get this error(user name supplied by daughter, please dont laugh. :wink: )

C:\Users\DooFuss\Desktop\ESP8285_Test\ESP8285_Test.ino: In function 'void setup()':

ESP8285_Test:22: error: expected primary-expression before 'int'

       Wire.begin(int sda, int scl)

                  ^

ESP8285_Test:22: error: expected primary-expression before 'int'

       Wire.begin(int sda, int scl)

                           ^

ESP8285_Test:23: error: expected ';' before 'Wire'

       Wire.begin(12, 14);    //Begin the sensor

       ^

exit status 1
expected primary-expression before 'int'

This is just the syntax, comment the line out.

1 Like

2 hours I pondered over it, and it was just that simple. Thanks Costas.
So here’s the noob question, what does the “syntax” do. Remove the line from the code and turn it into some sort of instruction?

@doofuss… err I meen @Shadeyman :stuck_out_tongue_winking_eye: (I know, I laughed… sue me :wink: )

Syntax means “arrangement of words, commands, etc.”

But by using // in your sketch before any following text (on that same line), then the compiler ignores it when compiling… it is called ‘commenting’ or ‘commenting out’ and is used for both informative description of commands or functions, for others to understand, or as a quick way of ‘removing’ suspect code while developing, without actually deleting the code from the sketch.

1 Like

@Gunner I was dreading having to copy and paste anything because of that user name she gave me. :joy::sweat_smile:

However, it compiled OK but the program froze at “Adafruit BME280 test:” ? :confounded:

To avoid further identification crisis, I can change your forum username to DooFus :stuck_out_tongue_winking_eye:

Probably need to post your code again. Also, apparently the 8285 chipset is a bit different than the 8266… I wonder if there might be library issues??

1 Like

DooFuss was the nickname of a young lad worked for me as a labourer for about 15 years, my daughter married him so I’ll stick with Shadeyman. :sweat_smile:

I’m sure they’re basically an ESP8266 but with 1Mb of memory built in. And they’re really small, especially for my, I have large hands, probably a consequence of being in construction all my life. Although I am 6 feet 2 and 18 stone so I guess I was never going to have small hands. :grimacing:
I have the User Manual for them, am I allowed/able to up a PDF?

Uploaded the sketch a few times, keep getting this error:

Adafruit BME280 test:

Exception (28):
epc1=0x40204d90 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff05f0 end: 3fff0870 offset: 01a0

>>>stack>>>
3fff0790:  ffffffff 3fffc6fc 00000001 3ffef850  
3fff07a0:  00000000 3fffdad0 3ffef850 3ffef490  
3fff07b0:  00004cf7 3ffef1e4 3ffef428 40204e78  
3fff07c0:  3fffdad0 3ffef83c 3ffef428 40204f18  
3fff07d0:  3ffe8920 3ffef490 3ffef46c 402036ec  
3fff07e0:  00000000 3ffef490 3ffef46c 402028ed  
3fff07f0:  3fffdad0 3ffef490 3ffef46c 40202faa  
3fff0800:  00000000 00000000 00000000 3ffef83c  
3fff0810:  00000000 3ffef1e4 3ffef428 4020345d  
3fff0820:  00000000 00003cd0 3ffef834 3ffef83c  
3fff0830:  00000000 3ffef1e4 3ffef1e4 402038d8  
3fff0840:  3fffdad0 00000000 3ffef834 40203651  
3fff0850:  3fffdad0 00000000 3ffef834 40205e54  
3fff0860:  feefeffe feefeffe 3ffef850 40100710  
<<<stack<<<

And here’s the code.

    #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[] = "3efa4091dxxxxxe454a58ca";
    char ssid[] = "xxxxx";
    char pass[] = "xxxxx";
    
    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)
      Wire.begin(10, 15);    //Begin the sensor
      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 5s 
      
    }

    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 5 sec  
    }

    void loop() {
      Blynk.run();
      timer.run();
    }

Here’s an ESP8285 in my hand so you can see how small they are. …

When you upload the sketch, are you choosing the correct board type (ESP8285) in the Arduino IDE?

Pete.

Yes, “Generic ESP8285 Module”. I’ve uploaded other sketches to it.

My BME280 sketch for the NodeMCU runs great on it except I’ve no idea which pins are the i2c pins.
I ran i2c Scanner and tried lots of pins but couldn’t find the right ones. So when Costas said I could choose the pins I wanted I was pleased to say the least …

Try disconnecting your BMP sensor and running the code again. Does it still crash at the same point?

Pete.

No, with the BME280 disconnected it freezes at “Adafruit BME280 test:” .

I’ve just uploaded the original NodeMCU(BME280) sketch and its running fine, except there’s no data as i’ve no idea which pins are the i2c pins …