-->
Page 2 of 4

Re: A4 and A5 of arduino is ??? on ESP8266

PostPosted: Sat Nov 26, 2016 1:32 pm
by martinayotte
You seems that have declared your lcd as "u8g" not "ldc", so, you should call it "ug8.begin(0,2);"

Re: A4 and A5 of arduino is ??? on ESP8266

PostPosted: Sat Nov 26, 2016 2:27 pm
by Lxx33
When I put u8g.begin(0,2); I get an error


Code: Select allvoid draw(void) {
  u8g.begin(0,2); // Here I put it, but don't know if this is the right place.
  // graphic commands to redraw the complete screen should be placed here 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( 0, 22, "Hello World!");
}

void setup(void) {


The error show
Code: Select allno matching function for call to 'U8GLIB_SSD1306_128X64::begin(int, int)'
     u8g.begin(0,2);


I really appreciate you all helping me :) :mrgreen: :mrgreen:

Re: A4 and A5 of arduino is ??? on ESP8266

PostPosted: Sat Nov 26, 2016 3:28 pm
by edwin
Some of these replies confuse me a bit as I thought that the GPIO numbers did not directly translate to D numbers. Thus if one uses D0 and D2 as SDA and SCL the declaration Wire.begin(0,2) is wrong as that initializes pins D3 and D4.
If one uses D0 and D2, the initialization shld be Wire.begin(D0,D2) or Wire.begin(16,4)

Or have Icompletely misunderstood things??

Re: A4 and A5 of arduino is ??? on ESP8266

PostPosted: Sat Nov 26, 2016 7:59 pm
by ex-egll
Hi, also new to this, I got the following code to work on an OLED with Pins

VCC
GND
SCL
SDA

Code: Select all-- OLED Display demo
-- March, 2016
-- @kayakpete | pete@hoffswell.com
-- Hardware:
--   ESP-12E Devkit
--   4 pin I2C OLED 128x64 Display Module
-- Connections:
--   ESP  --  OLED
--   3v3  --  VCC
--   GND  --  GND
--   D1   --  SDA
--   D2   --  SCL

-- Variables
sda = 1 -- SDA Pin
scl = 2 -- SCL Pin

function init_OLED(sda,scl) --Set up the u8glib lib
     sla = 0x3C
     i2c.setup(0, sda, scl, i2c.SLOW)
     disp = u8g.ssd1306_128x64_i2c(sla)
     disp:setFont(u8g.font_6x10)
     disp:setFontRefHeightExtendedText()
     disp:setDefaultForegroundColor()
     disp:setFontPosTop()
     --disp:setRot180()           -- Rotate Display if needed
end

function print_OLED()
   disp:firstPage()
   repeat
     disp:drawFrame(2,2,126,62)
     disp:drawStr(5, 10, str1)
     disp:drawStr(5, 20, str2)
     disp:drawCircle(18, 47, 14)
   until disp:nextPage() == false
   
end

-- Main Program
str1="    Hello World!!"
str2="     @kayakpete"
init_OLED(sda,scl)
print_OLED()