Mic ultra+ bluetooth speakers / forbidden pins [resolved]

Hi everyone. For my project with a raspberry 3 and mic ultra+, I also use two rotary encoders, an lcd 16x2, 4 leds, a pi camera and two push buttons. Everything works fine but I want let you know that nothing may be connected on pins 17 and 18 (BCM) or the mic ultra + will be disconnect from the pi. Each time I run a script python with something connected on those pins, I have to reboot the pi because the mic and the speakers don’t work anymore. If that can help someone…

Is there a way to transform the pi in bluetooth speaker with the mic ultra+ ?
I tried lukasjapan BT-speaker (github) but it doesn’t work.

Hi Cide,

-Those pins should not interfer with the ULTRA+, please share your code we can have a quick test here.

-Thanks for sharing this simple BT speaker project GitHub - lukasjapan/bt-speaker: A simple Bluetooth Speaker Daemon for the Raspberry Pi 3 The ULTRA uses some I2C commands to setup the codec, you can use this trick to set it up :
Volumio MicUltra + right settings [work around found] - #20 by josdegreef
Try it if you do not manage to make it work please open a different topic

thanks

Hello, here is the code i’m using:

encoder comes from

recorder comes from

lcd driver comes from https://gist.github.com/DenisFromHR/cc863375a6e19dce359d

when i replace 23 and 24 in e1 = Encoder(24, 23, intensity) by 17 and 18. The Ultra+ stops working

import picamera
import datetime
import time
import RPi.GPIO as GPIO
from encoder import Encoder
from recorder import Recorder
import I2C_LCD_driver
import ffmpeg
import os

LED_1 = 12
LED_2 = 13
LED_3 = 5
LED_4 = 6
PHOTO = 15
CAMERA = 16

brightness = 0
cold = 0
warm = 100
record = 0
mylcd = I2C_LCD_driver.lcd()

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(CAMERA,GPIO.IN,pull_up_down = GPIO.PUD_UP)
GPIO.setup(PHOTO,GPIO.IN,pull_up_down = GPIO.PUD_UP)
GPIO.setup(LED_1,GPIO.OUT)
GPIO.setup(LED_2,GPIO.OUT)
GPIO.setup(LED_3,GPIO.OUT)
GPIO.setup(LED_4,GPIO.OUT)
pwm1 = GPIO.PWM(LED_1,1000)
pwm2 = GPIO.PWM(LED_2,1000)
pwm1.start(0)
pwm2.start(0)
mylcd.lcd_display_string(" Justine “,1)
mylcd.lcd_display_string(” Heyde ",2)
time.sleep(2)
mylcd.lcd_clear()
time.sleep(0.3)
GPIO.output(LED_3, GPIO.HIGH)

def intensity(brightness):

brightness = e1.getValue()
cold = e2.getValue()
warm = 100 - cold
pwm1.ChangeDutyCycle(warm*brightness/100)
pwm2.ChangeDutyCycle(cold*brightness/100)
#print("Intensity : {}".format(brightness))
print("Intensity : " , brightness)
mylcd.lcd_display_string("Intensity : " + str(brightness) + " %  ",1)

def balance(cold):

cold = e2.getValue()
brightness = e1.getValue()
warm = 100 - cold
pwm1.ChangeDutyCycle(warm*brightness/100)
pwm2.ChangeDutyCycle(cold*brightness/100)
print("Balance : ",(cold-0) * (6500 - 2700) // (100 - 0) + 2700)
mylcd.lcd_display_string("Kelvin : " + str(((cold-0) * (6500 - 2700) // (100 - 0) + 2700)) + " K  ",2)

e1 = Encoder(24, 23, intensity)
e2 = Encoder(27, 22, balance)

def camera():

global record

with picamera.PiCamera() as camera:
    camera.resolution = (1280, 720)
    camera.framerate = 25
    now = datetime.datetime.now()
    timestamp = now.strftime("%d_%m_%y\r%Hh%Mm%Ss")
    if GPIO.input(CAMERA) == 0 :    
        record = 1
        rec = Recorder(channels=2)
        recfile = rec.open("/home/pi/Videos/" + str(timestamp) + ".wav", "wb") 
        recfile.start_recording()
        print ("Recording")
        GPIO.output(LED_4, GPIO.HIGH)
        GPIO.output(LED_3, GPIO.LOW)
        camera.start_preview()
        camera.start_recording('/home/pi/Videos/' + str(timestamp) + '.h264')
        time.sleep(.5)
    while record == 1:
        camera.wait_recording(.01)
        if GPIO.input(CAMERA) == 0:
           print ("Stopped")
           recfile.stop_recording()
           recfile.close()
           camera.stop_recording()
           camera.stop_preview()
           in1 = ffmpeg.input('/home/pi/Videos/' + str(timestamp) + '.h264')
           in2 = ffmpeg.input('/home/pi/Videos/' + str(timestamp) + '.wav')
           v1 = in1.video
           a2 = in2.audio
           out = ffmpeg.output(v1, a2, '/home/pi/Videos/' + str(timestamp) + '.mp4')
           out.run()
           os.remove('/home/pi/Videos/' + str(timestamp) + '.h264')
           os.remove('/home/pi/Videos/' + str(timestamp) + '.wav')
           GPIO.output(LED_4, GPIO.LOW)
           GPIO.output(LED_3, GPIO.HIGH)
           record = 0
           while GPIO.input(CAMERA) == 0:
               time.sleep(0.1)
           time.sleep(.5)
    if GPIO.input(PHOTO) == 0 :
        mylcd.lcd_clear()
        mylcd.lcd_display_string("   mode photo   ",1)
        mylcd.lcd_display_string("     3 . .      ",2)
        time.sleep(1)
        mylcd.lcd_display_string("     3 2 .      ",2)
        time.sleep(1)
        mylcd.lcd_display_string("     3 2 1      ",2)
        time.sleep(0.5)
        image_path = '/home/pi/Pictures/' + str(timestamp) + '.jpeg'
        GPIO.output(LED_4, GPIO.HIGH)
        GPIO.output(LED_3, GPIO.LOW)
        mylcd.lcd_clear()
        mylcd.lcd_display_string("     photo      ",1)
        mylcd.lcd_display_string("     prise      ",2)
        camera.capture(image_path)
        print("Took photo")
        time.sleep(.5)
        GPIO.output(LED_4, GPIO.LOW)
        GPIO.output(LED_3, GPIO.HIGH)
        cold = e2.getValue()
        brightness = e1.getValue()
        mylcd.lcd_clear()
        mylcd.lcd_display_string("Intensity : " + str(brightness) + " %  ",1)
        mylcd.lcd_display_string("Kelvin : " + str(((cold-0) * (6500 - 2700) // (100 - 0) + 2700)) + " K  ",2)

try:

mylcd.lcd_display_string("Intensity : " + str(brightness) + " %  ",1)
mylcd.lcd_display_string("Kelvin : " + str(((cold-0) * (6500 - 2700) // (100 - 0) + 2700)) + " K  ",2)
while True:
    time.sleep(0.1)
    camera()

except KeyboardInterrupt:
print (‘Interrupted’)
GPIO.cleanup()
mylcd.lcd_clear()

finally :
GPIO.cleanup()
mylcd.lcd_clear()

Hello after a double check I confirm that the I2S audio clock is used by GPIO18 (PIN12), to my knowledge this can’t be move to another pin. I also believe that all other I2S sound cards manufacturers use this pin for the clock.

My documentation was incorrect and is now right, thanks you for nociting the issue.