| credentials.example.h | Upload files to "/" | |
| README.md | Add README.md | |
| RoomSensor.ino | Upload files to "/" | |
Environment Sensor
I've created this because the ESPHome Docker Version had problems (with my browser) and I wasn't able to fix them.
This code just connects to WiFi and sends the data from a DHT11, BMP180 and Light sensor (By DFRobot) to a specific MQTT topic. The Data can then be handled as wished with Home Assistant or any other software.
Setup
You will find an example credentials file in this repo. You will have to adjust it to fit your needs. Then rename it to credentials.h.
You can flash this to any ESP32 using the Arduino IDE. Just load the code, select the Serial Port and flash!
HomeAssistant integration
Since the MQTT integration can only be configured through the config yaml, you will either need an Add-On for terminal access (on OS only) or edit the files yourself through SSH (on Docker install).
You will probably want to use this only when using the Dockerised installation, as ESPHome seems to work as an Add-On just fine.
Now to the config:
mqtt:
sensor:
- name: "Room Sensor Temperature"
state_topic: "room/mine/roomsensor"
value_template: "{{ value_json.tempe }}"
unit_of_measurement: "°C"
suggested_display_precision: 1
unique_id: "room_sensor_temperature"
device:
name: "Room Sensor"
identifiers:
- "room_sensor"
- name: "Room Sensor Humidity"
state_topic: "room/mine/roomsensor"
value_template: "{{ value_json.humid }}"
unit_of_measurement: "%"
unique_id: "room_sensor_humidity"
device:
name: "Room Sensor"
identifiers:
- "room_sensor"
- name: "Room Sensor Pressure"
state_topic: "room/mine/roomsensor"
value_template: "{{ value_json.press }}"
unit_of_measurement: "Pa"
unique_id: "room_sensor_pressure"
device:
name: "Room Sensor"
identifiers:
- "room_sensor"
- name: "Room Sensor Light Intensity"
state_topic: "room/mine/roomsensor"
value_template: "{{ value_json.light }}"
unit_of_measurement: "lx"
unique_id: "room_sensor_light"
device:
name: "Room Sensor"
identifiers:
- "room_sensor"
You can add multiple of these, but will have to change the device name and identifiers. Also you will need to change the sensor names and ids.