Terrible static noise when using the headphone output on a RPi3

Hello,

I am using the 3.5mm headphone jack with a pair of Logitech speakers (Z150) for audio feedback when doors open or family members enter the house. Everything is running Hass.io on a RPi3.

Although everything works as expected, I hear a constant and terrible static noise. On multiple forums, I read that users are addressing the issue by adding the following to /boot/config.txt

disable_audio_dither=1
audio_pwm_mode=2

@pvizeli, @balloob, is this something that could be tested on the next update of Hass.io? Perhas, do you have other suggestions to address this problem ?

Thanks!

Any chance you could share your config setup on this? I can’t get anything to play local.

Please and thanks!

Corey

Can’t you test it and tell us?

You’re right Nick :slight_smile:

The problem I had was that I wasn’t sure how to access the config.txt file. After further research, I dug into the Resin.io documentation and ended up on this : https://docs.resin.io/reference/resinOS/advanced/#raspberry-pi. I added the audio_pwm_mode=2 , restarted and the problem seems solved.

Thanks for pointing me in the right direction!

1 Like

Sure thing Corey. I do have the following setup.

  1. I started by installing the Mopidy add-on for Hass.io provided by BestLibre and available here : https://github.com/bestlibre/hassio-addons

  2. Added an MPD to my configuration.yaml

configuration.yaml
media_player:
  - platform: mpd
    host: 192.168.10.217
  1. Added my sound files to config/www directory. Note that I had to create the www directory. At that point you files should be available at : http://192.168.10.217:8123/local/yourFileName

  2. Finally, I adjusted my automations (automation.yaml) to play a sound based on what I wanted to achieve

automation.yaml
- action:
 ....
    - data:
        entity_id: media_player.mpd
        media_content_id: http://192.168.10.217:8123/local/chime-connect.mp3
        media_content_type: music
      service: media_player.play_media
...

I hope this helps.

so in my config would i add

media_player
platform: mpd
host:192.168.86.85:8123/local/goodnight.mp3

i have my sound files in /share/mopidy/media
I’m running hassio and it plays if i go through the addon but my script wont work

In configuration.yaml, you need to add

media_player:
  - platform: mpd
    host: 192.168.86.85

Once you have uploaded your audio files to config/www/, you will be able to use 192.168.86.85:8123/local/goodnight.mp3 in your automation as per the example above.

Thanks!

Could you please share one of your automations so I know I format it properly.

I would appreciate it!

Thanks for your time and help!!

You’re welcome Corey. I shared an example of the configuration.yaml and automation.yaml in my first answer above (Terrible static noise when using the headphone output on a RPi3).

Copying again here :

- action:
 ....
    - data:
        entity_id: media_player.mpd
        media_content_id: http://192.168.10.217:8123/local/chime-connect.mp3
        media_content_type: music
      service: media_player.play_media
...

i know this is probably a stupid question, but are the … and the … dots supposed to be there? i keep getting errors is i try adding those.

lol i didn’t know you could click the arrow to see the code sorry.

No problems Corey. Here the full code snippet I took from my automation.yaml.

In my case, if the trigger (sensor.bob) is above 50, it publishes “home” to the MQTT broker (location/bob topic) and plays a MP3 file using the MPD.

- action:
  - data:
      payload: home
      topic: location/bob
    service: mqtt.publish
  - data:
      entity_id: media_player.mpd
      media_content_id: http://192.168.10.217:8123/local/chime-connect.mp3
      media_content_type: music
    service: media_player.play_media
  alias: Bob is home
  condition: []
  id: '1524844979650'
  trigger:
  - above: '50'
    entity_id: sensor.bob
    platform: numeric_state

You can read more about automations here : https://www.home-assistant.io/docs/automation/ and https://www.home-assistant.io/docs/automation/examples/

thanks bro, I finally got it working! I appreciate the help!

Good to hear. Well done @Corey_Maxim!

1 Like

Hello,

Sorry to use an old thread but I am ussing hassio and the headphone output on a RPI3, but adding both lines of code to config.txt did not solve the issue.
The audio trough HDMI works perfectly.

EDIT: My fault, it was the audio cable which was adding a huge static noise. Solved adding a audio splitter (two outputs) between the raspberry and the audio cable.

Hi Christophe,
Can you please explain with a little more detail how exactly you managed to get access to config.txt? Did you use the media on another host and mount the boot partition?
Thx!

HomeAssistantOS no longer uses ResinOS (not for a year or more) so I’m not sure that config is applicable anymore.

still editing the contents of /mnt/boot/config.txt seems to be a popular way of setting boot options on the RPi no matter what the Linux flavor.
Any idea if these can be set at runtime or should I shutdown, mount media on a different host…etc?