输入自己的邮箱地址,我用的是163邮箱
选择用到的模块,红色是显示模块用到的,蓝色是温湿度传感器用到的
选择U8G
然后开始构建自己的固件,等待邮件
过一会会收到两封邮件,其中一封才是下载链接
总共有两类固件,float和integer,我一般都是下载float的,下载完成后就可以得到自己想要的固件啦
写入固件我用了ESPFlashDownloadTool,可以自行查找下载
选择ESP8266
选择自己下载好的固件,然后点击START即可写入
写入成功
scl – D3
sda – D4
scl – D2
sda – D1
每10s刷新一次
sda = 1
scl = 2
scl2 = 3
sda2=4
width = 16
height = 16
wen = string.char(
0x00,0x00,0xC4,0x1F,0x48,0x10,0x48,0x10,
0xC1,0x1F,0x42,0x10,0x42,0x10,0xC8,0x1F,
0x08,0x00,0xE4,0x3F,0x27,0x25,0x24,0x25,
0x24,0x25,0x24,0x25,0xF4,0x7F,0x00,0x00
)
du = string.char(
0x80,0x00,0x00,0x01,0xFC,0x7F,0x44,0x04,
0x44,0x04,0xFC,0x3F,0x44,0x04,0x44,0x04,
0xC4,0x07,0x04,0x00,0xF4,0x0F,0x24,0x08,
0x42,0x04,0x82,0x03,0x61,0x0C,0x1C,0x70
)
shi = string.char(
0x00,0x00,0xE4,0x1F,0x28,0x10,0x28,0x10,
0xE1,0x1F,0x22,0x10,0x22,0x10,0xE8,0x1F,
0x88,0x04,0x84,0x04,0x97,0x24,0xA4,0x14,
0xC4,0x0C,0x84,0x04,0xF4,0x7F,0x00,0x00
)
function init_OLED(sda,scl)
sla = 0x3c
i2c.setup(0, sda, scl, i2c.SLOW)
disp=u8g2.ssd1306_i2c_128x64_noname(0,sla)
disp:setFont(u8g2.font_6x10_tf)
disp:setFontPosTop()
end
function init_wendu(sda,scl)
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
si7021.setup()
hum, temp, hum_dec, temp_dec = si7021.read()
end
function print_OLED()
disp:setFont(u8g2.font_6x10_tf)
disp:setDrawColor(1)
disp:setBitmapMode(0)
disp:drawStr(4, 4, "Advertising position")
disp:drawXBM(16,25,width,height, shi)
disp:drawXBM(33,25,width,height, du)
disp:drawStr(49, 29, Humidity)
disp:drawXBM(16,42,width,height, wen)
disp:drawXBM(33,42,width,height, du)
disp:drawStr(49, 46,Temperature)
disp:drawFrame(0, 0,128,16)
disp:drawFrame(0, 16,128,48)
--disp:drawFrame(0, 16,128,45)
disp:sendBuffer()
end
init_wendu(sda2,scl2)
print(string.format("Humidity:\t\t%d.%03d\n", hum, hum_dec, temp, temp_dec))
print(string.format("Temperature:\t%d.%03d\n",temp, temp_dec))
Humidity = string.format(" : \t\t%d.%03d\n", hum, hum_dec, temp, temp_dec)
Temperature = string.format(" : \t%d.%03d\n",temp, temp_dec)
init_OLED(sda,scl)
print_OLED()
local mytimer1 = tmr.create()
function TimeFunction1()
init_wendu(sda2,scl2)
Humidity = string.format(" : \t\t%d.%03d\n", hum, hum_dec, temp, temp_dec)
Temperature = string.format(" : \t%d.%03d\n",temp, temp_dec)
init_OLED(sda,scl)
print_OLED()
end
mytimer1:register(10000, 1, TimeFunction1)
mytimer1:start()