In order to use the serial port to talk to sensors, the serial port login/console needs to be disabled. In the Raspbian OS image, this is enabled by default as it enables easy debugging.
The serial port login can be disabled via raspi-config:
- Launch the terminal and run this command:
sudo raspi-config
- Select Advanced Options from the main menu of raspi-config:

Select Advanced Options from the raspi-config menu
- Select the A8 Serial option from the drop-down menu:

Select A8 Serial from the dropdown
- Disable serial login:

Disable serial login
- Finish the configuration and reboot at the end:

Save config and reboot