Permission denied on ttyS0, which user?

Changed my original post to clarify further)

Hi there, I have just started using HA on my raspberry pi3. From a previous project I still had a MH-Z19 CO2 sensor connected to my pi3 and made that my first HA project. After a few attempts I believe I now understand how to use HA and how to configure the sensor in configuration.yaml.
sensor 2:
platform: mhz19
serial_device: /dev/ttyS0
name: MHZ19

I keep getting an error message however:
2017-05-09 20:07:33 ERROR (Thread-11) [homeassistant.components.sensor.mhz19] Could not open serial connection to /dev/ttyS0 ([Errno 13] could not open port /dev/ttyS0: [Errno 13] Permission denied: ‘/dev/ttyS0’)

I have tried to add user ‘Homeassistant’ and ‘pi’ to the dialout group (sudo usermod -G dialout -a ), but no success. Which user should be added? Or do I need to do something else?

I have used the all in one installer and therefore HA runs in the virtual environment.
I hope somebody has the answer to my problem.
Thanks, Ronald

Hi,

I had the same proble and got a solution a few minutes ago.
Run ‘sudo raspi-config’
And go to the Interface Option -> Serial
Disable the login shell accessible over serail and enable serial port hardware.
Reboot the Rpi and you can use the serail.
In my case, serial_device is /dev/serail0 with Rpi1 B+