A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By Mikejstb
#19073 yes, it was most certainly something I did wrong as far as comments to the blog.

Anyway - I finally installed everything into a nice little plastic box and loaded in the new .MONO file, and we finally have some nice weather.

Denver weather can be crazy - earlier in the week we had several inches of snow, today it hit 88 f!

But now I see what I think is corruption in the new .MONO file.

Here's what the new one looks like:
FullSizeRender (1).jpg


and here's the original one:
FullSizeRender.jpg


by the way I discovered that the way to get rid of the garbage on the right of the SH1106 1.3" oled is to shift the column position + 2 pixels. I figured out how to do that in an ESP-Arduino project which uses some code from the u8g library. Unfortunately I can't see how this could be fixed in NodeMCU. I think it could be tweaked in the source code in the u8g section but I don't know how to do that sort of thing.

I also discovered another difference between the SSD1306 and the SH1106. The 1106 is different as far as autoscrolling when sending byte data to it. So the ESP-Arduino project that I've been working on doesn't display graphics correctly.

It's interesting that your Lua code does display your graphics correctly. I'm sure it's the difference in your code vs the E-A u8g code I've been playing with.

This is the thread about that project - http://www.esp8266.com/viewtopic.php?f=29&t=3256

Here are all the little ESP displays I've made. It's hard to see the smallest black one.

IMG_2307.JPG


I had to order some more project boxes from Electrodragon!
I sure would like to try my hand at a 3D printer...one of these days! :)
You do not have the required permissions to view the files attached to this post.
User avatar
By miker
#19294 Not having luck getting my display to light up at all using LUA. I'm using the ESP-01 and have everything working fine with the Arduino IDE but not using LUA & ESPlorer.
- the hardware is good
- the oled does have an address of 0x3C
- I've flashed the -01 with nodemcu_float_0.9.6-dev_20150406.bin
- I'm using ESPlorer v0.2.0-rc1

As a test I formatted the ESP-01, opened simple-oled-example, displayXBM.lua, changed
SDA = 0, SCL = 2, clicked Save to ESP, Save&Compile, Run but the screen is still black.

There is a WifiScan example project on this forum that uses the Arduino IDE. This works fine on my hardware.

Thankx,
Mike
User avatar
By Mikejstb
#19337 OK - here is my Lua "mqtt message center" code.
It subscribes to my top-level topic - home/#.
My Node Red sends out the date/time in a message "home/time" every minute - this message is always displayed on line 4.
Note very good use of the small screen real estate to have the topic and time/date taking up the first 4 lines...oh well.

Then the next two messages will be displayed and subsequent messages scroll the old ones up.
IMG_2310.JPG


the garbage on the right of the screen and the bad positioning is because I'm using a 1.3" SH1106 oled instead of a real SSD1306.

Here is the code, most of it is borrowed from various examples that I found on this board.

Code: Select all--Init 
 DeviceID="ESP-12_Light_Control" 
 Broker="192.168.2.177" 
mTopic = "home/#"
topic = mTopic
myStr0 = "  mqtt Message Center"
myStr1 = "   topic = "..topic
myStr2 = "Current Date/Time-UTC ="
myStr3 = ""
myStr4 = ""
myStr5 = ""
myStr6 = ""
myStr7 = ""
gotEm = 0
function init_i2c_display()
     -- SDA and SCL can be assigned freely to available GPIOs
     sda = 5 -- GPIO14
     scl = 6 -- GPIO12
     sla = 0x3c
     i2c.setup(0, sda, scl, i2c.SLOW)
     disp = u8g.ssd1306_128x64_i2c(sla)
end

-- graphic test components
function prepare()
     disp:setFont(u8g.font_6x10)
     disp:setFontRefHeightExtendedText()
     disp:setDefaultForegroundColor()
     disp:setFontPosTop()
end


function draw(void)
    prepare()
    disp:drawStr(0,0,myStr0)
    disp:drawStr(0,8,myStr1)
    disp:drawStr(0,16,myStr2)
    disp:drawStr(0,24,myStr3)
    disp:drawStr(0,32,myStr4)
    disp:drawStr(0,40,myStr5)
    disp:drawStr(0,48,myStr6)
    disp:drawStr(0,56,myStr7)
end


function loop(void)
  disp:firstPage()
  repeat
    draw()
  until disp:nextPage() == false
 end

 --GPIO2 is connected to LED via resistor, initially off 
  gpio.write(4,gpio.HIGH) 

 function listen()
 m:on("message", function(conn, topic, data)
 
   print(topic .. ":" ..data)
   if (topic == "home/time") then
      myStr3 = data
   elseif gotEm == 0 then   
      myStr4 = topic
      myStr5 = "  "..data
      gotEm = 1
   elseif gotEm == 1 then
      myStr6 = topic
      myStr7 = "  "..data
      gotEm = 2
   elseif gotEm == 2 then
      myStr4 = myStr6 -- move em up a line
      myStr5 = myStr7
      myStr6 = topic
      myStr7 = "  "..data
   end   
end)
 end -- of listen function
 
 function mqtt_sub() 
    m:subscribe("home/#",0, function(conn)   
      print("Mqtt Subscribed home/# ") 
      listen() --run the subscription function 
 
    end) 
 end 

 m = mqtt.Client("ESP8266MC", 180, "mqtt login", "mqtt pw") 
 m:lwt("/lwt", "ESP8266MC gone", 0, 0) 
 m:on("offline", function(con)   
    print ("Mqtt Reconnecting...")   
    tmr.alarm(1, 5000, 0, function()
print ("should connect here...")   
      m:connect(Broker, 1883, 0, function(conn)   
        print("Mqtt Connected to:" .. Broker) 
        mqtt_sub() --run the subscription function 
      end) 
    end) 
 end) 

 
 tmr.alarm(0, 1000, 1, function() 
  if wifi.sta.status() == 5 and wifi.sta.getip() ~= nil then 
    tmr.stop(0) 
    m:connect(Broker, 1883, 0, function(conn)   
      print("Mqtt Connected to:" .. Broker) 
     mqtt_sub()
   end) 
  end 
 end) 
 
 
 init_i2c_display()
tmr.alarm(3,1000,1,function()   
   disp:firstPage()
   repeat
      draw()
   until disp:nextPage() == false
end)




hopefully this can help you get your display working
You do not have the required permissions to view the files attached to this post.