|
本帖最后由 602293544 于 2019-11-24 21:20 编辑
一直想给这个电表模块加一个外壳,终于今天有空完成了,先上图
外壳:先说这个外壳是买的,为啥是买的,因为本萌豚不会建模,正好在某宝上看到有模型卖,看了看尺寸和电表差不多可以放进入就入了一个,本来 是想上下出线的结果有点小,没办法只能都走一边了,正好手里有个以前买东西送的社会人贴纸,就贴在表面了。
屏幕:这个单纯的觉得好玩,可能安上后1年看不了几次,买的开合式CT的,这样你还可以拿着你的电表去给别人测测东西,别人问,你就说是自己做 的来装转B
我改造需要的东西清单:
培正模块、esp12f(坑死我了)、220V转5V(加转3.3的芯片)、oled1306屏幕、杜邦线若干(有点硬,剪了跟数据线用了)
接线:先是这么这么接,然后那么那么焊,最后在这样这样弄,完成了(滑稽,emmmm你们都会的我就是卖个萌),然后就可以上导轨了。忽略电工 胶带吧(主要是买不起热缩管,还是胶带物美价廉)
没用sonoff的原因是不会弄屏幕这样就得2个esp模块了,正巧esphome更新了一波,虽然数据少了那么几个,但是也不影响使用,代码直接在论坛嫖嫖就有了,还有个好处就是你的ha挂掉了这个也一样显示,不受影响。
上代码了
esphome(esp12f、esp12e)
substitutions:
device_name: ws161
wifi_ssid: 'PDCN'
wifi_password: '12345678'
wifi_fast_connect: 'false'
wifi_reboot_timeout: 0s
ota_password: '123456'
api_reboot_timeout: 0s
esphome:
name: $device_name
platform: ESP8266
board: esp01_1m
web_server:
port: 80
css_url: https://esphome.io/_static/webserver-v1.min.css
js_url: https://esphome.io/_static/webserver-v1.min.js
wifi:
ssid: $wifi_ssid
password: $wifi_password
reboot_timeout: $wifi_reboot_timeout
power_save_mode: none
fast_connect: $wifi_fast_connect
logger:
api:
reboot_timeout: $api_reboot_timeout
ota:
safe_mode: true
password: $ota_password
i2c:
sda: 12
scl: 14
# scan: False
uart:
tx_pin: 4
rx_pin: 5
baud_rate: 9600
sensor:
- platform: wifi_signal
name: "oled12f"
update_interval: 60s
id: xinhao
- platform: pzemac
current:
name: "PZEM-004T V3 Current"
id: dianliu
voltage:
name: "PZEM-004T V3 Voltage"
id: dianya
power:
name: "PZEM-004T V3 Power"
id: gonglv
frequency:
name: "PZEM-004T V3 Frequency"
id: pinlv
power_factor:
name: "PZEM-004T V3 Power Factor"
id: yinshu
energy:
name: "PZEM-004T V3 Energy"
id: dianneng
update_interval: 5s
font:
- file: 'ziti.ttf'
id: font1
size: 15
glyphs: 环境时间表信号息电压流功频率因数今日量昨总用¥费!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
- file: 'ziti.ttf'
id: font2
size: 47
time:
- platform: sntp
timezone: Asia/Shanghai
id: time1
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
id: my_display
pages:
- id: page1
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "时间");
it.strftime(64, 15, id(font2), TextAlign::CENTER_HORIZONTAL, "%H:%M", id(time1).now());
- id: page2
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "电表信息");
it.printf(0, 20, id(font1), TextAlign::TOP_LEFT, "电流: %.3f A", id(dianliu).state);
it.printf(0, 60, id(font1), TextAlign::BASELINE_LEFT, "电压: %.0f V", id(dianya).state);
- id: page3
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "电表信息");
it.printf(0, 20, id(font1), TextAlign::TOP_LEFT, "功率: %.0f W", id(gonglv).state);
it.printf(0, 60, id(font1), TextAlign::BASELINE_LEFT, "功率因数: %.2f", id(yinshu).state);
- id: page4
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "电表信息");
it.printf(0, 20, id(font1), TextAlign::TOP_LEFT, "WiFi信号: %.0f db", id(xinhao).state);
it.printf(0, 60, id(font1), TextAlign::BASELINE_LEFT, "频率: %.2f HZ", id(pinlv).state);
- id: page5
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "电表信息");
it.printf(0, 20, id(font1), TextAlign::TOP_LEFT, "用电量: %.2f KWH", id(dianneng).state);
it.printf(0, 60, id(font1), TextAlign::BASELINE_LEFT, "用电费: %.2f ¥", id(dianneng).state*0.5);
interval:
- interval: 5s
then:
- display.page.show_next: my_display
- component.update: my_display
代码就这样了,不解释了
在这里说一下为啥我刚才说的esp12f坑死我了,首先我是直接外接电源上的黄金版的哪个ttl结果不能进入刷写模式,以为坏了,然后试了试esp12e还是这样,后来换了另一个刷esp01s的ttl好了,本以为这次可以开开心心的刷固件了,谁知道这个oled刷完了不能启动,一直在闪灯,哎呀那个难受哟,然后慢慢的找原因,不明觉厉,完全不知道啥原因。然后就猜想难道是代码太多了???不应该呀,试着删几个代码在刷一次看看就是下面的这个
substitutions:
device_name: ws161
wifi_ssid: 'PDCN'
wifi_password: '12345678'
wifi_fast_connect: 'false'
wifi_reboot_timeout: 0s
ota_password: '123456'
api_reboot_timeout: 0s
esphome:
name: $device_name
platform: ESP8266
board: esp01_1m
web_server:
port: 80
css_url: https://esphome.io/_static/webserver-v1.min.css
js_url: https://esphome.io/_static/webserver-v1.min.js
wifi:
ssid: $wifi_ssid
password: $wifi_password
reboot_timeout: $wifi_reboot_timeout
power_save_mode: none
fast_connect: $wifi_fast_connect
logger:
api:
reboot_timeout: $api_reboot_timeout
ota:
safe_mode: true
password: $ota_password
i2c:
sda: 12
scl: 14
# scan: False
uart:
tx_pin: 4
rx_pin: 5
baud_rate: 9600
sensor:
- platform: wifi_signal
name: "oled12f"
update_interval: 60s
font:
- file: 'ziti.ttf'
id: font1
size: 15
glyphs: 环境时间表信息电压流功率因数今日量昨总用¥费!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
- file: 'ziti.ttf'
id: font2
size: 47
time:
- platform: sntp
timezone: Asia/Shanghai
id: time1
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
id: my_display
pages:
- id: page1
lambda: |-
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "时间");
it.strftime(64, 15, id(font2), TextAlign::CENTER_HORIZONTAL, "%H:%M", id(time1).now());
哎哟卧槽启动了,联网了,这是咋回事,然后又刷了最上面的那个,???为啥这回能启动了
有大佬帮我看看咋回事嘛,接线也挺稳的。之后一波三折总算是用上了,断电在通电也都正常工作了。
重点:
|
评分
-
查看全部评分
|