### begin() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Initializes the I2C bus and the radio module. This function must be called in the setup() function before any other library functions. ```APIDOC ## begin() ### Description Initializes the I2C bus by calling `Wire.begin()`. Must be called in `setup()` before any other library function is used. No parameters are required and nothing is returned. ### Method `void begin()` ### Parameters None ### Request Example ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); // Starts the Wire (I2C) interface at default pins } void loop() {} ``` ``` -------------------------------- ### Full Signal Monitor Example Source: https://context7.com/kerogs/ks_tea5767/llms.txt This example demonstrates how to combine various functions to monitor all available signal parameters, including PLL lock status, raw RSSI, RSSI in dBm, stereo mode, and raw status bytes in both hex and ASCII representations, updating every 3 seconds. ```APIDOC ## Full Signal Monitor ### Description Reads and prints all available signal parameters every 3 seconds: PLL lock, raw RSSI, RSSI in dBm, stereo mode, and raw status bytes in both hex and ASCII representations. ### Functions Used - `getPLL()`: Checks if the PLL is locked. - `getRSSI()`: Gets the raw RSSI value. - `getRSSIdBm(int rssi)`: Converts raw RSSI to dBm. - `getStereo()`: Checks if stereo mode is active. - `getHex()`: Retrieves raw status bytes as a hex string. - `getASCII()`: Retrieves raw status bytes as an ASCII string. ### Example Usage ```cpp #include #include KS_TEA5767 radio; float frequency = 104.5; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(frequency); } void loop() { bool pllLocked = radio.getPLL(); int rssi = radio.getRSSI(); int rssiDbm = radio.getRSSIdBm(rssi); bool isStereo = radio.getStereo(); String hexSt = radio.getHex(); String asciiSt = radio.getASCII(); Serial.println(F("==== TEA5767 Information ====")); Serial.print(F("Frequency : ")); Serial.println(frequency); Serial.print(F("PLL locked : ")); Serial.println(pllLocked ? "Yes" : "No"); Serial.print(F("RSSI (raw) : ")); Serial.println(rssi); Serial.print(F("RSSI (dBm) : ")); Serial.println(rssiDbm); Serial.print(F("Stereo mode : ")); Serial.println(isStereo ? "Yes" : "No"); Serial.print(F("Status (Hex) : ")); Serial.println(hexSt); Serial.print(F("Status (ASCII) : ")); Serial.println(asciiSt); Serial.println(F("=============================")); Serial.println(); delay(3000); } ``` ``` -------------------------------- ### Initialize I2C Bus and Radio Module with begin() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Initializes the I2C bus using Wire.begin(). Must be called in setup() before other library functions. No parameters are required. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); // Starts the Wire (I2C) interface at default pins } void loop() {} ``` -------------------------------- ### Initialize and Set Frequency with KS_TEA5767 Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Basic setup for the KS_TEA5767 library. Includes initialization and setting the FM frequency. Ensure Wire.h is included for I2C communication. ```c++ #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); // KS_TEA5767 library initialization radio.setFrequency(104.5); // Set frequency to 104.5 MHz } void loop() { } ``` -------------------------------- ### Full Signal Monitor Example Source: https://context7.com/kerogs/ks_tea5767/llms.txt Combines multiple functions to read and print all available signal parameters every 3 seconds, including PLL lock, RSSI, stereo mode, and raw status in hex and ASCII. ```cpp #include #include KS_TEA5767 radio; float frequency = 104.5; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(frequency); } void loop() { bool pllLocked = radio.getPLL(); int rssi = radio.getRSSI(); int rssiDbm = radio.getRSSIdBm(rssi); bool isStereo = radio.getStereo(); String hexSt = radio.getHex(); String asciiSt = radio.getASCII(); Serial.println(F("==== TEA5767 Information ====")); Serial.print(F("Frequency : ")); Serial.println(frequency); Serial.print(F("PLL locked : ")); Serial.println(pllLocked ? "Yes" : "No"); Serial.print(F("RSSI (raw) : ")); Serial.println(rssi); Serial.print(F("RSSI (dBm) : ")); Serial.println(rssiDbm); Serial.print(F("Stereo mode : ")); Serial.println(isStereo ? "Yes" : "No"); Serial.print(F("Status (Hex) : ")); Serial.println(hexSt); Serial.print(F("Status (ASCII) : ")); Serial.println(asciiSt); Serial.println(F("=============================")); Serial.println(); // Expected output: // ==== TEA5767 Information ==== // Frequency : 104.50 // PLL locked : Yes // RSSI (raw) : 72 // RSSI (dBm) : -78 // Stereo mode : Yes // Status (Hex) : 2b 40 6e 90 00 // Status (ASCII) : +@n.. // ============================= delay(3000); } ``` -------------------------------- ### Get Raw Status Bytes as ASCII String Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads 5 status bytes and returns them as a 5-character ASCII string. Printable bytes are shown as characters, others as '.'. Useful for quick visual inspection. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { String asciiStatus = radio.getASCII(); Serial.print("Status (ASCII): "); Serial.println(asciiStatus); // Example output: Status (ASCII): +@n.. delay(1000); } ``` -------------------------------- ### Get Raw Status Bytes as Hex String Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads 5 status bytes and returns them as a space-separated hexadecimal string. Each byte is zero-padded. Useful for low-level debugging. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { String hexStatus = radio.getHex(); Serial.print("Status (Hex): "); Serial.println(hexStatus); // Example output: Status (Hex): 2b 40 6e 90 00 delay(1000); } ``` -------------------------------- ### Tune to FM Frequency with setFrequency() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Tunes the TEA5767 module to a specified frequency in MHz. Valid range is 76.0 to 108.0 MHz. Requires the Wire library and prior initialization with begin(). ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); // Tune to 104.5 MHz // Also valid: radio.setFrequency(87.5), radio.setFrequency(107.9) } void loop() {} ``` -------------------------------- ### getASCII() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads 5 status bytes from the TEA5767 and returns them as a 5-character ASCII string. Bytes in the printable range (32–126) are shown as their ASCII character; all others are replaced with ".". Useful for quick visual inspection of the status frame. ```APIDOC ## getASCII() ### Description Reads 5 status bytes from the TEA5767 and returns them as a 5-character ASCII string. Bytes in the printable range (32–126) are shown as their ASCII character; all others are replaced with ".". Useful for quick visual inspection of the status frame. ### Method `getASCII()` ### Returns - `String`: A 5-character ASCII string representing the status bytes. ``` -------------------------------- ### Convert Raw RSSI to dBm with getRSSIdBm() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Converts a raw RSSI value to a dBm-scale signal strength using the formula -114 + (rssi * 0.5). Returns an integer, typically ranging from -114 dBm to -50 dBm. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { int rssi = radio.getRSSI(); int rssiDbm = radio.getRSSIdBm(rssi); Serial.print("RSSI raw: "); Serial.print(rssi); Serial.print(" | RSSI dBm: "); Serial.println(rssiDbm); // Example output: RSSI raw: 72 | RSSI dBm: -78 delay(1000); } ``` -------------------------------- ### Multi-Frequency RSSI Plotter with KS_TEA5767 Source: https://context7.com/kerogs/ks_tea5767/llms.txt Monitors RSSI in dBm for a predefined list of FM frequencies, formatting output for the Arduino Serial Plotter. Requires Wire.h and KS_TEA5767.h. A 100ms delay after setFrequency() is recommended. ```cpp #include #include KS_TEA5767 radio; float frequencies[] = { 94.9, 102.4, 104.5 }; const int numFrequencies = sizeof(frequencies) / sizeof(frequencies[0]); void setup() { Serial.begin(9600); radio.begin(); } void loop() { for (int i = 0; i < numFrequencies; i++) { radio.setFrequency(frequencies[i]); delay(100); // Settle time int rssi = radio.getRSSI(); int rssiDbm = radio.getRSSIdBm(rssi); Serial.print(frequencies[i], 1); Serial.print(":"); Serial.println(rssiDbm); // Output per iteration: // 94.9:-82 // 102.4:-90 // 104.5:-78 delay(100); } delay(1000); } ``` -------------------------------- ### Check PLL Lock Status with getPLL() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads status bytes to determine if the PLL is locked, indicating tuner stability. Returns true if locked, false otherwise. Call after setFrequency() and allow time for stabilization with a delay. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); delay(100); // Allow tuner to stabilize } void loop() { bool locked = radio.getPLL(); if (locked) { Serial.println("PLL: Locked — tuner is stable"); } else { Serial.println("PLL: Unlocked — no signal or still settling"); } delay(1000); } // Expected output: // PLL: Locked — tuner is stable ``` -------------------------------- ### getHex() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads 5 status bytes from the TEA5767 and returns them as a space-separated hexadecimal string (e.g., "2b 40 6e 90 00 "). Each byte is zero-padded to two hex digits. Useful for low-level debugging of the module's internal state registers. ```APIDOC ## getHex() ### Description Reads 5 status bytes from the TEA5767 and returns them as a space-separated hexadecimal string. Each byte is zero-padded to two hex digits. Useful for low-level debugging of the module's internal state registers. ### Method `getHex()` ### Returns - `String`: A space-separated hexadecimal string representing the 5 status bytes. ``` -------------------------------- ### Detect Stereo Transmission with getStereo() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads status bytes to detect if the received station is broadcasting in stereo. Returns true for stereo, false for mono. Useful for adjusting audio output. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { bool stereo = radio.getStereo(); Serial.print("Audio mode: "); Serial.println(stereo ? "Stereo" : "Mono"); // Expected output: Audio mode: Stereo delay(1000); } ``` -------------------------------- ### getPLL() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Checks the PLL lock status of the TEA5767 module. Returns true if the PLL is locked, indicating a stable tuner, and false otherwise. ```APIDOC ## getPLL() ### Description Reads 5 status bytes from the TEA5767 over I2C and returns `true` if bit 6 of byte 3 is set, indicating the PLL is locked onto the current frequency. A locked PLL means the tuner is stable at the requested frequency. Returns `false` if the PLL is unlocked (e.g., no signal, or module still settling). ### Method `bool getPLL()` ### Parameters None ### Response * **true**: The PLL is locked and the tuner is stable. * **false**: The PLL is unlocked (no signal or module still settling). ### Request Example ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); delay(100); // Allow tuner to stabilize } void loop() { bool locked = radio.getPLL(); if (locked) { Serial.println("PLL: Locked — tuner is stable"); } else { Serial.println("PLL: Unlocked — no signal or still settling"); } delay(1000); } // Expected output: // PLL: Locked — tuner is stable ``` ``` -------------------------------- ### getRSSIdBm Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Converts the RSSI value to dBm scale and returns it. ```APIDOC ## getRSSIdBm ### Description Converts the RSSI value to dBm scale and returns it. ### Method `getRSSIdBm(int rssi)` ### Parameters #### Path Parameters - **rssi** (int) - Required - The RSSI value to convert. ``` -------------------------------- ### FM Band Scanner with KS_TEA5767 Source: https://context7.com/kerogs/ks_tea5767/llms.txt Sweeps the FM band, logs detected stations exceeding an RSSI threshold, and stores their information. Requires Wire.h and KS_TEA5767.h. Adjust rssiThreshold based on your environment. ```cpp #include #include KS_TEA5767 radio; const float startFrequency = 87.5; const float endFrequency = 108.0; const float step = 0.1; const int rssiThreshold = 50; // Adjust based on environment const unsigned long listenTime = 3000; // ms to listen per detected station struct StationInfo { float freq; bool stereo; int rssi; int rssiDbm; }; const int maxStations = 50; StationInfo stationList[maxStations]; int stationCount = 0; void setup() { Serial.begin(9600); radio.begin(); Serial.println(F("==== Starting FM Scan ====")); for (float freq = startFrequency; freq <= endFrequency; freq += step) { radio.setFrequency(freq); delay(100); // Let tuner settle int rssi = radio.getRSSI(); bool pllLocked = radio.getPLL(); if (rssi > rssiThreshold && pllLocked && stationCount < maxStations) { stationList[stationCount] = { freq, radio.getStereo(), rssi, radio.getRSSIdBm(rssi) }; stationCount++; Serial.println(F("=== Station Detected ===")); Serial.print(F("Frequency : ")); Serial.print(freq, 1); Serial.println(F(" MHz")); Serial.print(F("RSSI : ")); Serial.println(rssi); Serial.print(F("Mode : ")); Serial.println(radio.getStereo() ? "Stereo" : "Mono"); Serial.println(F("========================")); delay(listenTime); } } Serial.println(F("==== Summary ====")); for (int i = 0; i < stationCount; i++) { Serial.print(F("- ")); Serial.print(stationList[i].freq, 1); Serial.print(F(" MHz | ")); Serial.print(stationList[i].stereo ? "Stereo" : "Mono"); Serial.print(F(" | RSSI: ")); Serial.print(stationList[i].rssi); Serial.print(F(" (")); Serial.print(stationList[i].rssiDbm); Serial.println(F(" dBm)")); } // Example output: // - 94.9 MHz | Stereo | RSSI: 68 (-80 dBm) // - 102.4 MHz | Mono | RSSI: 53 (-88 dBm) // - 104.5 MHz | Stereo | RSSI: 72 (-78 dBm) } void loop() {} ``` -------------------------------- ### getRSSIdBm(int rssi) Source: https://context7.com/kerogs/ks_tea5767/llms.txt Converts a raw RSSI value to a dBm-scale signal strength. Typical values range from approximately -114 dBm to -50 dBm. ```APIDOC ## getRSSIdBm(int rssi) ### Description Converts a raw RSSI value (as returned by `getRSSI()`) to a dBm-scale signal strength using the formula `-114 + (rssi * 0.5)`. Returns an `int`. Typical values range from approximately -114 dBm (no signal) to around -50 dBm (strong signal). ### Method `int getRSSIdBm(int rssi)` ### Parameters * **rssi** (int) - The raw RSSI value obtained from `getRSSI()`. ### Response * **int**: The signal strength in dBm. ### Request Example ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { int rssi = radio.getRSSI(); int rssiDbm = radio.getRSSIdBm(rssi); Serial.print("RSSI raw: "); Serial.print(rssi); Serial.print(" | RSSI dBm: "); Serial.println(rssiDbm); // Example output: RSSI raw: 72 | RSSI dBm: -78 delay(1000); } ``` ``` -------------------------------- ### Read Raw Signal Strength with getRSSI() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads status bytes to retrieve the raw RSSI value, typically ranging from 0 to 127. Higher values indicate a stronger signal. Use getRSSIdBm() for conversion to dBm. ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { int rssi = radio.getRSSI(); Serial.print("Raw RSSI: "); Serial.println(rssi); // Expected output: Raw RSSI: 72 delay(1000); } ``` -------------------------------- ### setFrequency Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Sets the frequency of the TEA5767 module to the specified value in MHz. ```APIDOC ## setFrequency ### Description Sets the frequency of the TEA5767 module to the specified value in MHz. ### Method `setFrequency(float frequencyMHz)` ### Parameters #### Path Parameters - **frequencyMHz** (float) - Required - The desired frequency in MHz. ``` -------------------------------- ### setFrequency(float frequencyMHz) Source: https://context7.com/kerogs/ks_tea5767/llms.txt Tunes the TEA5767 module to the specified FM frequency in MHz. The valid range is 76.0 to 108.0 MHz. ```APIDOC ## setFrequency(float frequencyMHz) ### Description Tunes the TEA5767 module to the specified frequency in MHz by computing the 14-bit PLL word using the formula `(4 * (frequencyMHz * 1000000 + 225000)) / 32768` and sending it as part of a 5-byte I2C control frame. Valid range is 76.0 to 108.0 MHz. ### Method `void setFrequency(float frequencyMHz)` ### Parameters * **frequencyMHz** (float) - The desired FM frequency in Megahertz (e.g., 104.5). ### Request Example ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); // Tune to 104.5 MHz // Also valid: radio.setFrequency(87.5), radio.setFrequency(107.9) } void loop() {} ``` ``` -------------------------------- ### getASCII Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Converts the status bytes received from TEA5767 to ASCII characters. Non-printable characters are replaced with '.', ```APIDOC ## getASCII ### Description Converts the status bytes received from TEA5767 to ASCII characters. Non-printable characters are replaced with ".". ### Method `getASCII()` ### Parameters None ### Returned Parameter - **String**: The status bytes converted to ASCII characters. ``` -------------------------------- ### getPLL Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Checks if the PLL is locked. Returns true if locked, false otherwise. ```APIDOC ## getPLL ### Description Checks if the PLL is locked. ### Method `getPLL()` ### Parameters None ### Returned Parameter - **bool**: `true` if PLL is locked, `false` otherwise. ``` -------------------------------- ### getHex Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Returns the status bytes received from TEA5767 in hexadecimal format. ```APIDOC ## getHex ### Description Returns the status bytes received from TEA5767 in hexadecimal format. ### Method `getHex()` ### Parameters None ### Returned Parameter - **String**: The status bytes in hexadecimal format. ``` -------------------------------- ### getStereo() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Detects if the received FM station is broadcasting in stereo. Returns true for stereo and false for mono. ```APIDOC ## getStereo() ### Description Reads 5 status bytes from the TEA5767 and returns `true` if bit 7 of byte 3 is set, indicating the received station is broadcasting in stereo. Returns `false` for mono reception. Useful for displaying audio mode or switching audio output routing. ### Method `bool getStereo()` ### Parameters None ### Response * **true**: The station is broadcasting in stereo. * **false**: The station is broadcasting in mono. ### Request Example ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { bool stereo = radio.getStereo(); Serial.print("Audio mode: "); Serial.println(stereo ? "Stereo" : "Mono"); // Expected output: Audio mode: Stereo delay(1000); } ``` ``` -------------------------------- ### getStereo Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Checks if the radio is in stereo mode. Returns true for stereo, false for mono. ```APIDOC ## getStereo ### Description Checks if the radio is in stereo mode. ### Method `getStereo()` ### Parameters None ### Returned Parameter - **bool**: `true` if in stereo mode, `false` if in mono mode. ``` -------------------------------- ### getRSSI() Source: https://context7.com/kerogs/ks_tea5767/llms.txt Reads the raw signal strength (RSSI) value from the TEA5767 module. The value is an integer typically ranging from 0 to 127. ```APIDOC ## getRSSI() ### Description Reads 5 status bytes from the TEA5767 and returns the raw RSSI value extracted from bits 7–1 of byte 4 (i.e., `status[3] >> 1`). The raw value is an integer typically ranging from 0 to 127. Higher values indicate stronger received signal. Use `getRSSIdBm()` to convert this to a dBm value. ### Method `int getRSSI()` ### Parameters None ### Response * **int**: The raw RSSI value (0-127). ### Request Example ```cpp #include #include KS_TEA5767 radio; void setup() { Serial.begin(9600); radio.begin(); radio.setFrequency(104.5); } void loop() { int rssi = radio.getRSSI(); Serial.print("Raw RSSI: "); Serial.println(rssi); // Expected output: Raw RSSI: 72 delay(1000); } ``` ``` -------------------------------- ### getRSSI Source: https://github.com/kerogs/ks_tea5767/blob/main/README.md Returns the Received Signal Strength Indication (RSSI) value. ```APIDOC ## getRSSI ### Description Returns the Received Signal Strength Indication (RSSI) value. ### Method `getRSSI()` ### Parameters None ### Returned Parameter - **int**: The RSSI value. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.