Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Issue with reading Audio from ADC - Teensy 4.1

  1. #1
    Junior Member
    Join Date
    Jan 2023
    Posts
    3

    Issue with reading Audio from ADC - Teensy 4.1

    I set up the recommended circuit for using the ADC for sampling audio and got it working perfectly with the Teensy 3.6. The code returned the expected peak values.

    Then switching over to a 4.1 (with the 10k resistor changed to a 2k resistor) the peak value failed to return any data and peak.available() returns false. All of the pins are still connected to the same pins as they were for the 3.6.

    I do not have the pins available to use a shield so I would like to get the ADC method working for the 4.1.

    Attached is the source code.
    Audio_Tester.ino

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    
    
    // GUItool: begin automatically generated code
    AudioInputAnalog         adc1;           //xy=227.99999618530273,267.9999885559082
    AudioAnalyzePeak         peak1;          //xy=461.99999237060547,264.99999618530273
    AudioConnection          patchCord1(adc1, peak1);
    // GUItool: end automatically generated code
    
    
    
    // GUItool: end automatically generated code
      long StartMillis;
    
    void setup() {
      // put your setup code here, to run once:
       StartMillis = millis();
    
       Serial.begin(9600);
       delay(1000);
       AudioMemory(12);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      
      
     if (millis()> StartMillis+10){
    
    
       StartMillis =millis();
       
           
      if (peak1.available()){
       
           float peakValue = peak1.read();
           Serial.println(peakValue);
      }else{
        Serial.println("Peak not available");
      }  
     }
    }
    Thanks in advance!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,408
    Try using 1.58-beta3. For Arduino 1.8.x, get the installer here. For Arduino 2.0.x, use Boards Manager to install version "0.58.3".

  3. #3
    Junior Member
    Join Date
    Jan 2023
    Posts
    3
    Hey Paul, Thanks for the quick response.

    I tried a full uninstall of Arduino and Teensyduino and then re-installing the 1.58-beta3 and Arduino 1.8.19.
    Unfortunately, the issue persists. (peak.available() never returns true and calling peak.read() always returns 1.00)

  4. #4
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Since your code ran successfully on the T3.6 and not on the T4.1, and you only changed the resistor you may want to check your external hardware.
    Fastest test is probably using the RMS object to see whether any audio is present at the A2 pin.

    Paul

  5. #5
    Junior Member
    Join Date
    Jan 2023
    Posts
    3
    Thanks for the help. After checking and confirming the presence of audio I reinstalled the V1.58 and horaah suddenly it was working!
    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •