|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/TinyKT0803/actions/workflows/arduino-lint.yml) |
| 4 | +[](https://github.com/RobTillaart/TinyKT0803/actions/workflows/jsoncheck.yml) |
| 5 | +[](https://github.com/RobTillaart/TinyKT0803/issues) |
| 6 | + |
| 7 | +[](https://github.com/RobTillaart/TinyKT0803/blob/master/LICENSE) |
| 8 | +[](https://github.com/RobTillaart/TinyKT0803/releases) |
| 9 | +[](https://registry.platformio.org/libraries/robtillaart/TinyKT0803) |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +# TinyKT0803 |
| 14 | + |
| 15 | +Arduino Library for KT0803 and KT0803K FM transmitter. Tiny85 edition. |
| 16 | + |
| 17 | + |
| 18 | +### Legal point of attention |
| 19 | + |
| 20 | +In different countries there are different laws with respect to using transmitting devices |
| 21 | +and their range. |
| 22 | +Please inform yourself of the local rules and laws if and how you may or may not use a |
| 23 | +device like the KT0803 in your projects, either hobby, commercial or otherwise. |
| 24 | + |
| 25 | + |
| 26 | +## Description |
| 27 | + |
| 28 | +This is an **EXPERIMENTAL** port to the Tiny85/45/25 processor of - https://github.com/RobTillaart/KT0803 |
| 29 | + |
| 30 | +The library is verified to work - See issue #2 |
| 31 | +There are two points of attention: |
| 32 | + |
| 33 | +- ATTiny85 needs a 500 ms delay to initialize I2C to communicate properly (assuming 1 MHz clock) |
| 34 | +- ATTiny85 needs a decoupling capacitor 100-300 nF between RESET and GND and a 10K resistor between VDC and RESET |
| 35 | + |
| 36 | +Note: The KT0803 library will be leading in development and this one will follow. |
| 37 | +The interface section below is identical except for the constructor. |
| 38 | + |
| 39 | + |
| 40 | +## Interface |
| 41 | + |
| 42 | +```cpp |
| 43 | +#include "TinyKT0803.h" |
| 44 | +``` |
| 45 | + |
| 46 | +#### Constructor |
| 47 | + |
| 48 | +- **TinyKT0803()** constructor. |
| 49 | +- **TinyKT0803K()** constructor. |
| 50 | +- **bool begin(float freq = 90.0, bool mute = true)** initializes the library. |
| 51 | +Furthermore it checks if the deviceAddress is available on the I2C bus. |
| 52 | +Default it sets the frequency to 90 MHz and **mutes the signal**. |
| 53 | +Returns true if deviceAddress is found on the bus, false otherwise. |
| 54 | +- **bool isConnected()** test to see if deviceAddress is found on the I2C-bus. |
| 55 | + |
| 56 | + |
| 57 | +#### Frequency |
| 58 | + |
| 59 | +- **bool setFrequency(float MHz)** converts the frequency in MHz to |
| 60 | +call **setChannel(channel)**. The value of channel is rounded off depending |
| 61 | +on the resolution of the device. |
| 62 | +Returns false if MHz is out of range or **setChannel()** fails. |
| 63 | +- **float getFrequency()** returns the current frequency in MHz, can be slightly different |
| 64 | +from the set value due to rounding math mentioned above. |
| 65 | +The return value is derived from a call to **getChannel()** |
| 66 | +- **bool setChannel(uint16_t channel)** writes the channel to broadcast on to the device. |
| 67 | +This involves two or three writes to different device registers. |
| 68 | +- **uint16_t getChannel()** reads the selected channel from the device and |
| 69 | +returns it. |
| 70 | + |
| 71 | + |
| 72 | +#### PGA |
| 73 | + |
| 74 | +Read Datasheet. |
| 75 | + |
| 76 | +The KT0803K has a **PGA_LSB** (2 bits) setting, which allows setting the gain |
| 77 | +with single (1) dB steps. This is not yet implemented in the library. |
| 78 | + |
| 79 | +- **bool setPGA(uint8_t pga)** sets gain according to table below. |
| 80 | +Returns false if pga is out of range (0..7). |
| 81 | +- **uint8_t getPGA()** returns 0..7, default 0. |
| 82 | + |
| 83 | + |
| 84 | +| PGA | gain | notes | |
| 85 | +|:-----:|:-------:|:-------:| |
| 86 | +| 111 | 12dB | |
| 87 | +| 110 | 8dB | |
| 88 | +| 101 | 4dB | |
| 89 | +| 100 | 0dB | |
| 90 | +| 000 | 0dB | default |
| 91 | +| 001 | -4dB | |
| 92 | +| 010 | -8dB | |
| 93 | +| 011 | -12dB | |
| 94 | + |
| 95 | + |
| 96 | +#### RFGain |
| 97 | + |
| 98 | +Read Datasheet. |
| 99 | + |
| 100 | +Note: the RFGain value (4 bits) is distributed over three registers. |
| 101 | +PA_BIAS (register 0x05) is only supported in the KT0803K device. |
| 102 | +It is not yet supported in the library. |
| 103 | + |
| 104 | +- **bool setRFGain(uint8_t rfgain)** sets rfgain according to table below. |
| 105 | +Returns false if rfgain is out of range (0..15). |
| 106 | +- **uint8_t getRFgain()** returns 0..15, default 15. |
| 107 | + |
| 108 | + |
| 109 | +| RFGAIN | RFout | PA_BIAS = 1 | notes | |
| 110 | +|:--------:|:------------:|:------------:|:-------:| |
| 111 | +| 0000 | 95.5 dBuV | - | |
| 112 | +| 0001 | 96.5 dBuV | - | |
| 113 | +| 0010 | 97.5 dBuV | - | |
| 114 | +| 0011 | 98.2 dBuV | - | |
| 115 | +| 0100 | 98.9 dBuV | - | |
| 116 | +| 0101 | 100.0 dBuV | - | |
| 117 | +| 0110 | 101.5 dBuV | - | |
| 118 | +| 0111 | 102.8 dBuV | - | |
| 119 | +| 1000 | 105.1 dBuV | 107.2 dBuV | |
| 120 | +| 1001 | 105.6 dBuV | 108.0 dBuV | |
| 121 | +| 1010 | 106.2 dBuV | 108.7 dBuV | |
| 122 | +| 1011 | 106.5 dBuV | 109.5 dBuV | |
| 123 | +| 1100 | 107.0 dBuV | 110.3 dBuV | |
| 124 | +| 1101 | 107.4 dBuV | 111.0 dBuV | |
| 125 | +| 1110 | 107.7 dBuV | 111.7 dBuV | |
| 126 | +| 1111 | 108.0 dBuV | 112.5 dBuV | default |
| 127 | + |
| 128 | + |
| 129 | +#### Region selection |
| 130 | + |
| 131 | +Read datasheet for details. |
| 132 | + |
| 133 | +Note that not all frequencies are allowed in all regions / countries! |
| 134 | + |
| 135 | +The first four are convenience wrappers for **setPHTCNST()** |
| 136 | +If some region is missing please let me know the details and I can add |
| 137 | +a wrapper for it. |
| 138 | + |
| 139 | +- **void setEurope()** |
| 140 | +- **void setAustralia()** |
| 141 | +- **void setUSA()** |
| 142 | +- **void setJapan()** |
| 143 | +- **bool setPHTCNST(bool on)** See table below. |
| 144 | +- **bool getPHTCNST()** returns set value. |
| 145 | + |
| 146 | +| PHTCNST | time | Region | |
| 147 | +|:---------:|:-------:|:--------:| |
| 148 | +| 0 | 75 μs | USA, Japan, (default) |
| 149 | +| 1 | 50 μs | Europe, Australia |
| 150 | + |
| 151 | + |
| 152 | +#### PilotToneAdjust |
| 153 | + |
| 154 | +Read datasheet. |
| 155 | + |
| 156 | +- **bool setPilotToneAdjust(uint8_t mode)** HIGH = 1 LOW = 0 |
| 157 | +- **uint8_t getPilotToneAdjust()** |
| 158 | + |
| 159 | + |
| 160 | +#### Mute |
| 161 | + |
| 162 | +Default the device is not muted, but **begin()** will default mute it. |
| 163 | +See interface section above. |
| 164 | + |
| 165 | +- **bool setMute(bool mute)** enables or disables the transmitting |
| 166 | +by muting the signal. |
| 167 | +- **bool getMute()** returns the current state of muting. |
| 168 | + |
| 169 | + |
| 170 | +## Preference channels |
| 171 | + |
| 172 | +The device and library do not implement the persistant store of user |
| 173 | +selectable preferences (frequencies or channels). |
| 174 | +This can be implemented by the user in EEPROM or another persistent medium. |
| 175 | + |
| 176 | +Think of a class that holds an array of channels and optional descriptions. |
| 177 | +A minimal hardcoded preset sketch is in the examples. |
| 178 | + |
| 179 | + |
| 180 | +## Derived classes |
| 181 | + |
| 182 | +A derived class TinyKT0803K class is created, with some extended |
| 183 | +functions. |
| 184 | + |
| 185 | +The KT0803L will work as it is backwards compatible with KT0803K. |
| 186 | +It has far more registers in use than the KT0803/K. |
| 187 | + |
| 188 | +The KT0803M is identical to the KT0803K (no new registers), so |
| 189 | +a derived class is straightforward. |
| 190 | + |
| 191 | + |
| 192 | +## Interface KT0803K |
| 193 | + |
| 194 | +(not tested), check datasheet. |
| 195 | + |
| 196 | +#### Mono Stereo |
| 197 | + |
| 198 | +- **bool setMono()** idem |
| 199 | +- **bool setStereo()** idem |
| 200 | +- **bool isStereo()** idem |
| 201 | + |
| 202 | +#### Bass |
| 203 | + |
| 204 | +- **bool setBass(uint8_t bass); // 0..3 = 0, 5, 11, 17 dB |
| 205 | +- **uint8_t getBass()** idem |
| 206 | + |
| 207 | +#### Misc |
| 208 | + |
| 209 | +- **bool powerOK()** idem |
| 210 | +- **bool silenceDetected()** idem |
| 211 | + |
| 212 | + |
| 213 | +## Future |
| 214 | + |
| 215 | +See - https://github.com/RobTillaart/KT0803 |
| 216 | + |
| 217 | + |
| 218 | +## Support |
| 219 | + |
| 220 | +If you appreciate my libraries, you can support the development and maintenance. |
| 221 | +Improve the quality of the libraries by providing issues and Pull Requests, or |
| 222 | +donate through PayPal or GitHub sponsors. |
| 223 | + |
| 224 | +Thank you, |
| 225 | + |
0 commit comments