I know everyone, I have one problem. I wrote an arduino program to measure the temperature and activate the pump. I would like to remake it and return it to Home Asistannt. The program is on esp wemos D1 mini
This is the program in Arduino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 5
#define SENSORS_NUM 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const byte address[SENSORS_NUM][8] PROGMEM = {
0x28, 0xDE, 0x9E, 0X79, 0xA2, 0x1, 0x3, 0x78,
0x28, 0xE, 0xDF, 0x17, 0x1, 0x0, 0x0, 0x29
};
//LiquidCrystal_I2C lcd(0x27, 20, 2); // W zależności od użytej biblioteki...
LiquidCrystal_I2C lcd(0x4E / 2, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
byte skull_1[8] = { B00000, B00001, B00011, B00011, B00011, B00010, B01011, B11001 };
byte skull_2[8] = { B11111, B11111, B11111, B11111, B01110, B00100, B01110, B11011 };
byte skull_3[8] = { B00000, B10000, B11000, B11000, B11000, B01000, B11010, B10011 };
byte skull_4[8] = { B00100, B00000, B00000, B00001, B00001, B00100, B11000, B01000 };
byte skull_5[8] = { B11111, B10101, B00000, B01010, B11111, B11111, B00000, B00000 };
byte skull_6[8] = { B00100, B00000, B00000, B10000, B10000, B00100, B00011, B00010 };// set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
// Prepare LCD
lcd.begin(20, 2);
lcd.createChar(1, skull_1);
lcd.createChar(2, skull_2);
lcd.createChar(3, skull_3);
lcd.createChar(4, skull_4);
lcd.createChar(5, skull_5);
lcd.createChar(6, skull_6);
lcd.clear();
// Start up screen
{
lcd.setCursor(1, 0);
lcd.write(1);
lcd.write(2);
lcd.write(3);
lcd.setCursor(1, 1);
lcd.write(4);
lcd.write(5);
lcd.write(6);
lcd.setCursor(20 - 4, 0);
lcd.write(1);
lcd.write(2);
lcd.write(3);
lcd.setCursor(20 - 4, 1);
lcd.write(4);
lcd.write(5);
lcd.write(6);
lcd.backlight(); //Turns backlight on
sensors.begin();
lcd.setCursor(0,0);
lcd.setCursor(5, 0);
lcd.print("Basenmierz");
delay(3000);
lcd.setCursor(6, 1);
lcd.print(" :) ");
delay(3000);
}
}
void loop()
{
sensors.requestTemperatures();
//Read first sensor
float temp = sensors.getTempCByIndex(0);
//Print first sensor results
lcd.setCursor (0, 0 );
lcd.print("Temp solara ");
lcd.print(temp);
lcd.print(" ");
//Read second sensor
temp = sensors.getTempCByIndex(1);
//Print second sensor result
lcd.setCursor (0, 1 );
lcd.print("Temp wody ");
lcd.print(temp);
lcd.print(" ");
//Wait 0.1 sec
delay(100);
}
And this is what Home Asistan esp. In addition, information is to be displayed on the oled display (this is a link to this display EOL - WEH002002ABPP5N00002 - Wyświetlacz Longlife OLED znakowy Winstar (niebieski, 20 znaków x 2 wiersze, COB - kontroler na PCB))
esphome:
name: esp_mini_dallas
platform: ESP8266
board: d1_mini
wifi:
ssid: "Bojjkbi"
password: "pufocek18kkjij2"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp Mini Dallas Fallback Hotspot"
password: "1234567890"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "1234567890"
ota:
password: "1234567890"
i2c:
sda: D2
scl: D1
dallas:
- pin: D7
sensor:
- platform: dallas
address: 0xFA02189245736F28
id: tempdallas
name: "Temperatura Dallas"
on_value_range:
- above: 68 # Włączenie alarmu gdy osiągnie zadaną temeraturę
then:
- switch.turn_off: buzer
- switch.turn_on: czerwona
- below: 67 # Wyączenie alarmu gdy osiągnie zadaną temeraturę
then:
- switch.turn_on: buzer
- switch.turn_on: czerwona
# internal: true
display:
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
lambda: |-
it.printf(0, 0, "Temperatura:%.1f", id(tempdallas).state);
it.printf(0, 1, "Alarm = >60.0:%.2f", id(tempdallas).state);
# DIOAD LED CZEROWNA OD ALARMU
##output:
# - platform: esp8266_pwm
# id: led_alarm
# pin: D4
switch:
- platform: gpio
pin: D3
name: "Alarm"
id: buzer
- platform: gpio
pin: D0
name: "czerwona"
id: czerwona
binary_sensor:
- platform: gpio
pin: 16
name: "Przycisk LED Alarm"
on_press:
then:
- switch.toggle: buzer
# Example configuration entry
status_led:
pin: GPIO2