Lior Elazary KK6BWA

...because this life is yours. Some of it was given to you, the rest you make yourself.

  • Increase font size
  • Default font size
  • Decrease font size
Home Ham Baofeng Radios Hacking the Baofeng UV5R - Transmiting

Hacking the Baofeng UV5R - Transmiting

E-mail Print PDF
Article Index
Hacking the Baofeng UV5R
Opening The Radio
Hacking the Radio
Interfacing with the voice chip
interfacing with the RDA5802
Interfacing with the RDA1846
Removing the MCU
Transmiting
All Pages

Transmitting


I finally got my license a few weeks ago (KK6BWA) and after messing around a bit with just talking to people, I finally got back to the radio and tried to transmit. I also, tried to read some of the read only registers on the radio, which indicate RX level strength, DTMF decoded tones, etc.


The first thing I noticed was that I was able to tell the RDA1846 to send a sin wave of a given frequency. In fact, you can choose whether you want to send one sin wave or two at the same time (for DTMF). It also looks like you can change the sin wave relatively quickly  while transmitting, so I can even send 1200 Baud FSK signals. I wrote a simple morse code function to send my call sign (KK6BWA) though the radio for testing.

Here is a video of the radio sending the morse code over 145.525MHz.
 


Since the chip itself can be configured to send data over the 220MHz band. I tried that as well. However, I only have another UV5R, so I have nothing to receive the signal on. Thankfully, Steve (WB8GRS) suggested to use harmonics and tune the other UV5R to the first  harmonic. I configured the hacked radio to TX on 223.5MHz and the other UV5R to receive over (223.5*2) 447MHz. Since the RDA1846 has a special register that needs to be set to put it into the 220MHz band, I tried TXing with the register set to the other bands while on 220MHz. Unfortunately, by only setting the register to the 220MHz band, I was able to receive the signal, confirming the the stock UV5R will not be able to TX/RX on that band without setting this register. To my surprise I was able to receive the harmonics about 400 feet  away before the signal started degrading.

Here is a video of the radio TXing on 223.5MHz and receiving over 447MHz.
 


The RDA1846 is also able to set the TX deviation, so I tried messing around with that register to see if I can get a better transmission over the harmonics. Here is the same test as above, but each time I set the deviation param to a different number:
 



Lastly, I tried to read the internal registers on the radio, which indicate the signal level strength, Voice signal strength, DTMF decoded output and some flags. Anyone knows why would the signal level strength change when different frequencies (DTMF) was going over the  air? The signal level strength does seem to be working, since I was getting different values when I was tuning the radio to other far away stations.

 


Next step would be to design a PCB that I can place an atmega or an arm chip in the radio.

Here is the final code used for testing. It allows you to set registers by "Saa uu ll " where  aa is the register address, uu is the upper byte to set and ll is the lower byte to set. "Raa" to read a register at address aa. "V" to display register values like signal strength, DTMF, etc. "T" to transmit my call sign in morse.
Using the arduino serial monitor its simple to just copy and paste settings. For example, to initialize the chip, copy the following into the arduino serial monitor (insure you are at 38400 baud rate).
S30 00 01
S30 00 04
S04 0F D0
S0B 1A 10
S2B 32 C8
S2C 19 64
S32 62 7C
S33 0A F2
S47 2C 2F
S4E 29 3A
S54 1D 4C
S56 06 52
S6E 06 2D
S70 10 29
S7F 00 01
S05 00 1F
S7F 00 00
S30 30 06


Then to receive the NOAA channel on 162.550MHz send the following sequence
S30 30 06
S29 00 13
S2A d7 b0
S0F 6b e4
S48 00 88
S49 01 b3
S30 30 06
S30 30 2E


Here is the arduino code
/***************************************************/
// Interfacing with the uvr5 RDA1846 using arduino //
// Written by Lior Elazary KK6BWA                  //
// 2013                                            //
/***************************************************/

#include <Wire.h>
//  Arduino analog input 5 - I2C SCL
//  Arduino analog input 4 - I2C SDA

//The RDA1846 chip address
#define ADDRESS B1110001

/*********************************************/
// Simple Arduino Morse Beacon               //
// Written by Mark VandeWettering K6HX       //
// Email: k6hx@arrl.net                      //
/*********************************************/

struct t_mtab { char c, pat; } ;

struct t_mtab morsetab[] = {
 {'.', 106},
 {',', 115},
 {'?', 76},
 {'/', 41},
 {'A', 6},
 {'B', 17},
 {'C', 21},
 {'D', 9},
 {'E', 2},
 {'F', 20},
 {'G', 11},
 {'H', 16},
 {'I', 4},
 {'J', 30},
 {'K', 13},
 {'L', 18},
 {'M', 7},
 {'N', 5},
 {'O', 15},
 {'P', 22},
 {'Q', 27},
 {'R', 10},
 {'S', 8},
 {'T', 3},
 {'U', 12},
 {'V', 24},
 {'W', 14},
 {'X', 25},
 {'Y', 29},
 {'Z', 19},
 {'1', 62},
 {'2', 60},
 {'3', 56},
 {'4', 48},
 {'5', 32},
 {'6', 33},
 {'7', 35},
 {'8', 39},
 {'9', 47},
 {'0', 63}
} ;

#define N_MORSE  (sizeof(morsetab)/sizeof(morsetab[0]))

#define SPEED  (20)
#define DOTLEN  (1200/SPEED)
#define DASHLEN  (3*(1200/SPEED))

void dash()
{
 delay(10);        
 Wire.beginTransmission(ADDRESS);  
 Wire.write(0x36);  
 Wire.write(0x09);  
 Wire.write(0x00);  
 Wire.endTransmission(1);

 delay(DASHLEN);
 delay(10);        
 Wire.beginTransmission(ADDRESS);  
 Wire.write(0x36);  
 Wire.write(0x00);  
 Wire.write(0x00);  
 Wire.endTransmission(1);

 delay(DOTLEN) ;
}

void dit()
{
 delay(10);        
 Wire.beginTransmission(ADDRESS);  
 Wire.write(0x36);  
 Wire.write(0x09);  
 Wire.write(0x00);  
 Wire.endTransmission(1);

 delay(DOTLEN);
 delay(10);        
 Wire.beginTransmission(ADDRESS);  
 Wire.write(0x36);  
 Wire.write(0x00);  
 Wire.write(0x00);  
 Wire.endTransmission(1);
 delay(DOTLEN);
}

void send(char c)
{
 int i ;
 if (c == ' ') {
 Serial.print(c) ;
 delay(7*DOTLEN) ;
 return ;
 }
 for (i=0; i<N_MORSE; i++) {
 if (morsetab[i].c == c) {
 unsigned char p = morsetab[i].pat ;
 Serial.print(morsetab[i].c) ;

 while (p != 1) {
 if (p & 1)
 dash() ;
 else
 dit() ;
 p = p / 2 ;
 }
 delay(2*DOTLEN) ;
 return ;
 }
 }
 /* if we drop off the end, then we send a space */
 Serial.print("?") ;
}

void sendmsg(char *str)
{
 while (*str)
 send(*str++) ;
 Serial.println("");
}
/****************** End of morse lib **********************/


void setup() {
 Wire.begin();
 Serial.begin(38400);
}

byte getVal(char c)
{
 if(c >= '0' && c <= '9')
 return (byte)(c - '0');
 else
 return (byte)(c-'A'+10);
}

short int readReg(unsigned char reg)
{
 Wire.beginTransmission(ADDRESS);  
 Wire.write(reg);
 Wire.endTransmission(0);

 Wire.beginTransmission(ADDRESS);  
 Wire.requestFrom(ADDRESS,2);
 unsigned char rDataU = Wire.read();
 unsigned char rDataL = Wire.read();
 Wire.endTransmission(1);
 short int data = word(rDataU, rDataL);
 return data;
}

void loop()
{
 // send data only when you receive data:
 if (Serial.available() > 0)
 {
 unsigned char d = Serial.read();
 if (d == 'S')
 {
 int i=0;
 char data[8];
 while(i < 8)
 if (Serial.available() > 0)
 data[i++] = Serial.read();

 unsigned char address = getVal(data[1]) + (getVal(data[0]) << 4); 
 unsigned char dataU = getVal(data[4]) + (getVal(data[3]) << 4); 
 unsigned char dataL = getVal(data[7]) + (getVal(data[6]) << 4); 
 Serial.println(address, HEX);
 Serial.println(dataU, HEX);
 Serial.println(dataL, HEX);
 Serial.println();
 Wire.beginTransmission(ADDRESS);  
 Wire.write(address);  
 Wire.write(dataU);  
 Wire.write(dataL);  
 Wire.endTransmission(1);
 }
 if (d == 'R')
 {
 int i=0;
 char data[2];
 while(i < 2)
 if (Serial.available() > 0)
 data[i++] = Serial.read();

 unsigned char address = getVal(data[1]) + (getVal(data[0]) << 4); 
 short int ss = readReg(address);
 Serial.print("Register: ");
 Serial.print(address, HEX);
 Serial.print(" =");
 Serial.println(ss, HEX);
 }
 else if (d == 'V')
 {
 //Read registers
 short int ss = readReg(0x6C);
 Serial.print("RX Signal Strength ");
 Serial.println(ss);
 short int vs = readReg(0x60);
 Serial.print("Voice Signal Strength ");
 Serial.println(vs);
 short int dtmf = readReg(0x60);
 Serial.print("DTMF ");
 Serial.println(dtmf, HEX);
 short int flags = readReg(0x5C);
 Serial.print("Flags ");
 Serial.println(flags, BIN);
 delay(100);
 Serial.write(27); // ESC
 Serial.print("[2J"); // clear screen
 Serial.write(27); // ESC
 Serial.print("[H"); // cursor to home
 }

 if (d == 'T')
 {
 Wire.beginTransmission(ADDRESS);  
 Wire.write(0x30);  
 Wire.write(0x30);  
 Wire.write(0x46);  
 Wire.endTransmission(1);
 sendmsg("KK6BWA ");
 Wire.beginTransmission(ADDRESS);  
 Wire.write(0x30);  
 Wire.write(0x30);  
 Wire.write(0x06);  
 Wire.endTransmission(1);
 }

 }
}






Last Updated on Friday, 08 March 2013 20:01