Esphomelib - library to greatly simplify Home Assistant integration with ESP32

@OttoWinter Also the switches or sensors i add in the garage.yaml are not showing in home assistant even though MQTT is enabled in discovery mode.

I am going to try this in rpi 3 instead of windows.

It works perfectly in rpi3. Let me know if you want me test any fixes for windows. I think the serial com port is the issue.

This looks very interesting. Thanks for your efforts.

If a Sonoff Basic uses a ESP8266 chip shouldn’t it be possible to use esphomelib on it?

I think the issue might have been that esphomeyaml would not ask the user which serial port to use when multiple are available. With your setup for example, there also seems to be printer connected via another usb to serial chip, so esphomeyaml just failed. I now updated esphomeyaml and uploaded the new version that asks the user what serial device to use if several are detected. To update, use pip install -U esphomeyaml; If you’re still using esphomeyaml via Windows, I hope it will fix the issue :grinning:

I haven’t tried yet with any Sonoff devices (they seem quite dangerous with so little isolation between mains and logic IMHO), but if they’re using an ESP8266 they should probably work. There might be a problem with available flash size (but I doubt it) - if there’s an issue with esphomelib on Sonoff, please notify me. Thanks

i use use the docker container, what to do here for updating? just (re)pull the image?

Will try it out today and let you know the results.

Yes, docker pull ottowinter/esphomeyaml should do the trick

@OttoWinter the new v1.2.2 is now working in windows. Thanks a lot for the quick response.

I have one more question, is it possible to integrate a RF receiver component?

RF Receivers would in principle be possible since with esphomelib you can just write normal Arduino code and create custom sensors. There’s however no built-in support for them since they’re highly dependent on the protocol that’s being used. May I ask what exact receiver and devices you want to integrate? If it sounds useful an lots of users would benefit from it, it might be added to the core.

I will try but not great at coding. I use one of these for motion detection and door detection. I believe they are used widely in DIYs.

  1. PIR Sensor: (see link: http://www.instructables.com/id/Interface-PIR-Sensor-With-NodeMCU/)
  2. Rf 433 door sensor (https://www.gearbest.com/access-control/pp_593451.html?wid=21)

I think the PIR sensor might be simple since its as simple as high on a GPIO when motion is detected.

THe door sensor provides a code on close and open. Something like this below.

2017-03-16 23:04:14 - [INFO] rfrx: Listening for codes on GPIO 27
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 340, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 340, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 343, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 340, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 340, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 340, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 340, protocol 1]
2017-03-16 23:04:27 - [INFO] rfrx: 9848953 [pulselength 341, protocol 1]

So the PIR sensor should already be possible with the GPIO Binary Sensor. The RF433 sensor is probably a bit more difficult, but this library could make integrating it a lot easier, I will take a look at it.

Hi guys, esphomelib version 1.3.0 has just been released here.

Features include a new internal web server with a simple REST API, Deep Sleep support, MQTT SSL support, WiFi hotspot mode and a big MQTT client+core refactor.

Hope you like it! :slight_smile:

2 Likes

Hooray for DeepSleep!

I made a test config for my esp32 based “weather station”. Could someone more experienced tell me if I am doing it the right way?

I will connect a 18650 Battery to the M2 port of the Lolin32 and another wire from the positive pole to pin 34.

esphomeyaml:
  name: testsensor
  platform: ESP32
  board: lolin32

wifi:
  ssid: 'ssid'
  password: 'password'

mqtt:
  broker: '192.168.0.27'
  username: 'user'
  password: 'pass'

# Enable logging
logger:
deep_sleep:
  run_duration: 15s
  sleep_duration: 10min

sensor:
  - platform: adc
    pin: 34
    name: "Spannung Akku"
    update_interval: 5s
  - platform: dht
    pin: 17
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"
    update_interval: 5s
switch:
  - platform: restart
    name: "Testsensor Restart"

The deep sleep component looks good to me :+1:

However, I would maybe be a bit careful with the 18650 cell, as it’s max voltage of 4V+ might cause some troubles with the internal ADC. The attenuation of the ADC Sensor defaults to 0db on the ESP32, which only gives a voltage range from 0 to 1.1V.

To get up to 3.9V set the attenuation: key to 11db (see http://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/adc.html#_CPPv225adc1_config_channel_atten14adc1_channel_t11adc_atten_t). Probably a volatge of 4.2V from the cell won’t be an issue for the internal wiring, but I’d advise to at least put a resistor in series to limit the current if something goes wrong.

Also, you don’t really need to set an update_interval of 5 seconds, as the first “raw” value will be directly published in the first loop() run anyway.

1 Like

My Mac just gives me a bluetooth port on the device list command. Am I missing a driver?

Lars

Probably, yes. Most ESP8266 boards use one of two chipsets for the UART to USB bridge: CP2102 and FT232RL.

On a mac, installation is quite easy if you have homebrew:

# enable drivers tap
brew tap caskroom/drivers
# for CP2102
brew cask install silicon-labs-vcp-driver
# for FT232RL
brew cask install ftdi-vcp-driver

Otherwise, you’ll need to manually install the drivers from these links:

Great, worked and above command now returns

/dev/cu.Bluetooth-Incoming-Port
-------------------------------
Hardware ID: n/a
Description: n/a

/dev/cu.usbmodem26300
---------------------
Hardware ID: USB VID:PID=0E8D:0003 LOCATION=20-4
Description: Product

/dev/cu.SLAB_USBtoUART
----------------------
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=20-3
Description: CP2102 USB to UART Bridge Controller

which looks good to me. And it works now, even connected to my MQTT broker out of the box!

This is really a great contribution to make development of small IOT-like devices more efficient. Many thanks !

Lars

Did someone by chance get an MPU6050 accelerometer working?

Lars