Arduino Pro Mini Pin Pulled To 3.3v in Setup(), But Only 2.3v in Loop() DRA818V

Hey all,

I am working on a project which uses a GPS and Arduino Pro Mini to parse GPS data and encode it in packet radio. The data is then transmitted through the DRA818V VHF transmitter module.

All of the code works fine, and the DRA818V is keyed through an active low PTT pin. Here is my setup,

void setup()  
{


  //initialize the LEDS
  pinMode(LEDG, OUTPUT);
  pinMode(LEDR, OUTPUT);

  
  Serial.begin(115200);

  //Start the DRA818V Module
  Serial.println("Booting ...");

  Serial.print("initializing I/O ... ");  
  dra_serial = new SoftwareSerial(RX, TX); // Instantiate the Software Serial Object.

  //Turn the DRA818V Power Saving mode off
  pinMode(PD, OUTPUT);            
  digitalWrite(PD, HIGH);
  
  Serial.println("done");

  Serial.print("initializing DRA818 ... ");

  //Initialize the DRA818V Frequency and info
   dra = DRA818::configure(dra_serial, DRA818_VHF, 145.500, 145.500, 4, 8, 0, 0, DRA818_12K5, true, true, true, &Serial);
  if (!dra) {
    Serial.println("\nError while configuring DRA818");
  }
  

  //Initialize the PTT and the H/L power output
  pinMode(PTT, OUTPUT);
  pinMode(PWR, OUTPUT);

  //Turn the DRA818v to low power
  digitalWrite(PWR, LOW);
  
  Serial.println("done");

  //Flash the LED
  digitalWrite(LEDR, HIGH);
  delay(200);
  digitalWrite(LEDR, LOW);
  delay(200);
  digitalWrite(LEDR, HIGH);
  delay(200);
  digitalWrite(LEDR, LOW);
  
  Serial.println("Starting ... ");

  //Key the DRA818V for one second
  digitalWrite(PTT, LOW);
  delay(1000);
  digitalWrite(PTT, HIGH);

  //Initialize the GPS
  ss.begin(GPSBaud);

  Serial.println(F("Arduino APRS Tracker"));

  //Initialize the RTTY
  RTTY.attach(12);
  
  //Initialize the APRS settings
  APRS_init(ADC_REFERENCE, OPEN_SQUELCH);
  APRS_setCallsign(APRS_CALLSIGN,APRS_SSID);
  APRS_setSymbol(APRS_SYMBOL);

  
}

When the system first powers on, everything works properly and the DRA818V keys for one second from the setup. After that though, the DRA818V should get keyed again when the locationUpdate() function is called, as shown below,

void locationUpdate() {

  //End the GPS Serial
  ss.end();

  //Key the DRA818v
  digitalWrite(PTT, LOW);

  //Turn on the LED
  digitalWrite(LEDG, HIGH);

  //Wait 500 ms for the DRA818v to warm up
  delay(500);

  //Setup the APRS comment
  char comment []= "Arduino APRS Tracker";
  char temp[8];
  char APRS_comment [36]="/A=";

  //Setup the APRS comment data
  Serial.println(alt);
  sprintf(temp, "%06f", alt);
  strcat(APRS_comment,"ALT: ");
  strcat(APRS_comment,temp);
  strcat(APRS_comment,"' ");
  strcat(APRS_comment,comment);
 Serial.println(APRS_comment);


  //Set the Lat/Lon
  APRS_setLat((char*)deg_to_nmea(lat, true));
  APRS_setLon((char*)deg_to_nmea(lon, false));
      


  
  // TX
  APRS_sendLoc(APRS_comment, strlen(APRS_comment));


  // start GPS Serial again
  ss.begin(9600);

  //unkey the radio
  digitalWrite(PTT, HIGH);

  //Turn off the LED
  digitalWrite(17, LOW);
  
}

The issue is, the DRA818V won't key anymore. I checked using my volt meter, and the PTT pin is only going up to 2.3v at HIGH, and then down to 0v for LOW. When the module is keyed for 1 second in the setup though, the PTT pin goes all the way up to 3.3v.

I'm very confused on why this might be. I've tried using other pins on the Arduino, and it only seems to be once I connect the DRA818V to that pin that it doesn't function properly, even though it functions in the setup.

Noah

Which Mini pin is connected to PTT?

Hi,

The issue is, the DRA818V won't key anymore. I checked using my volt meter, and the PTT pin is only going up to 2.3v at HIGH, and then down to 0v for LOW. When the module is keyed for 1 second in the setup though, the PTT pin goes all the way up to 3.3v.

Are you sure when you measure 2.3V that the pin is going HIGH and not HIGH/LOW oscillating?
If you measure that point but with your DMM in AC mode, what do you get?

The fact that the initialization in setup you get 3V3 means you have the pin configured correctly.

You need to look though your code and see if after you turn the output HIGH, somewhere in your code you are then switching it LOW, and this cycles one each loop.

Thanks.. Tom... :slight_smile:

Most multimeters only measure a time-averaged voltage, so unless the voltage is steady for several seconds you cannot trust the reading to be accurate, merely indicative.

TomGeorge:
Hi,
Are you sure when you measure 2.3V that the pin is going HIGH and not HIGH/LOW oscillating?
If you measure that point but with your DMM in AC mode, what do you get?

The fact that the initialization in setup you get 3V3 means you have the pin configured correctly.

You need to look though your code and see if after you turn the output HIGH, somewhere in your code you are then switching it LOW, and this cycles one each loop.

Thanks.. Tom... :slight_smile:

Thanks Tom,
I was able to figure out that the APRS_init() function is what causes the pin to stay at this 2.4v level, as when I removed it, the PTT worked perfectly, although whenever I try to send data without this initialization function it causes the Arduino to reset, so it is clearly needed. I used my multimeter to check for AC voltage, and I found that whenever that pin goes to LOW, about .5v of AC shows up, and none when the pin is HIGH.

I'm really confused by this issue, as I can't even figure out if it's a hardware or software issue. When the DRA818v isn't connected to the Arduino PTT, it goes all the way up to 3.3v, but it also seems to work fine when I don't call that APRS_init() function with the DRA818v connected.
Any thoughts?

If you would like my completed code it is below.

#include <baudot.h>
#include <RTTY.h>
#include "DRA818.h"
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <LibAPRS.h>

// Manual update button
#define BUTTON_PIN 13

// GPS SoftwareSerial
// Shares pins with (MISO 12/ MOSI 11) used for SPI
static const int RXPin = 2, TXPin = 3;
static const uint32_t GPSBaud = 9600;


#define PD      14  // to the DRA818 PD pin
#define RX       9  // arduino serial RX pin to the DRA818 TX pin
#define TX       8   // arduino serial TX pin to the DRA818 RX pin
#define PTT      10
#define PWR      11


#define LEDG      17
#define LEDR      16

SoftwareSerial *dra_serial; // Serial connection to DRA818
DRA818 *dra;                // the DRA object once instanciated
float freq;  

// LibAPRS
#define OPEN_SQUELCH true
#define ADC_REFERENCE REF_3V3

float flat, flon;


// APRS settings
char APRS_CALLSIGN[]="KM4VXF";
const int APRS_SSID=5;
char APRS_SYMBOL='>';


unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long period = 5000;  //the value is a number of milliseconds



TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);


//long instead of float for latitude and longitude
long lat = 0;
long lon = 0;
float alt;

int year=0;
byte month=0, day=0, hour=0, minute=0, second=0, hundredths=0;
unsigned long age=0;
float falt=0;
float fkmph=0;
int ialt=0;

// buffer for conversions
#define CONV_BUF_SIZE 16
static char conv_buf[CONV_BUF_SIZE];


void setup()  
{


  //initialize the LEDS
  pinMode(LEDG, OUTPUT);
  pinMode(LEDR, OUTPUT);

  
  Serial.begin(115200);

  //Start the DRA818V Module
  Serial.println("Booting ...");

  Serial.print("initializing I/O ... ");  
  dra_serial = new SoftwareSerial(RX, TX); // Instantiate the Software Serial Object.

  //Turn the DRA818V Power Saving mode off
  pinMode(PD, OUTPUT);            
  digitalWrite(PD, HIGH);
  
  Serial.println("done");

  Serial.print("initializing DRA818 ... ");

  //Initialize the DRA818V Frequency and info
   dra = DRA818::configure(dra_serial, DRA818_VHF, 145.500, 145.500, 4, 8, 0, 0, DRA818_12K5, true, true, true, &Serial);
  if (!dra) {
    Serial.println("\nError while configuring DRA818");
  }
  

  //Initialize the PTT and the H/L power output
  pinMode(PTT, OUTPUT);
  pinMode(PWR, OUTPUT);

  //Turn the DRA818v to low power
  digitalWrite(PWR, LOW);
  
  Serial.println("done");

  //Flash the LED
  digitalWrite(LEDR, HIGH);
  delay(200);
  digitalWrite(LEDR, LOW);
  delay(200);
  digitalWrite(LEDR, HIGH);
  delay(200);
  digitalWrite(LEDR, LOW);
  
  Serial.println("Starting ... ");

  //Key the DRA818V for one second
  digitalWrite(PTT, LOW);
  delay(1000);
  digitalWrite(PTT, HIGH);

  //Initialize the GPS
  ss.begin(GPSBaud);

  Serial.println(F("Arduino APRS Tracker"));

  //Initialize the RTTY
  RTTY.attach(12);
  
  //Initialize the APRS settings
  APRS_init(ADC_REFERENCE, OPEN_SQUELCH);
  APRS_setCallsign(APRS_CALLSIGN,APRS_SSID);
  APRS_setSymbol(APRS_SYMBOL);

  
}

void loop()
{
  
  bool newData = false;



  // For one second we parse GPS data
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  Serial.println(newData);

 //if (newData)
  //{



  long scale=1000000UL;
  long lat = gps.location.rawLat().deg*scale+gps.location.rawLat().billionths/1000UL;
  if(gps.location.rawLat().negative) lat=-lat;
  long lon = gps.location.rawLng().deg*scale+gps.location.rawLng().billionths/1000UL;
  if(gps.location.rawLng().negative) lon=-lon;

  float alt = gps.altitude.feet();

    
    currentMillis = millis();  
    if (currentMillis - startMillis >= period)  {
      
      Serial.println(F("APRS UPDATE"));
      Serial.println(lat);
      Serial.println(lon);

      Serial.println(deg_to_nmea(lat, true));
      Serial.println(deg_to_nmea(lon, false));
      Serial.println(alt);
      locationUpdate();
      delay(2000);
      //rttyUpdate();
      startMillis = millis();
      
     }
    

 // }

}

void rttyUpdate() {
 
  char comment []= "Send data to noahjfodor@protonmail.com or text 407-716-1691";
  char temp[8];
 
  char latitude[9];
  char longitude[10];
  
  // Convert altitude in string and pad left
  sprintf(temp, "%06d", ialt);
  dtostrf(flat, 1, 5, latitude);
  dtostrf(flon, 1, 5, longitude);

  Serial.println("RTTY Update");

  ss.end();
  
  digitalWrite(LEDG, HIGH);
  digitalWrite(PTT, LOW);
  delay(500);
  
  RTTY.tx("  \n\n");
  RTTY.tx(APRS_CALLSIGN);
  RTTY.tx(" WEATHER BALLOON");
  RTTY.tx("\n\nLAT/LON: ");
  RTTY.tx(latitude);
  RTTY.tx(" ");
  RTTY.tx(longitude);
  RTTY.tx("\nALT: ");
  RTTY.tx(temp);
  RTTY.tx(" FT");
  RTTY.tx("\n");
  RTTY.tx(comment);
  
  digitalWrite(PTT, HIGH);
  digitalWrite(LEDG, LOW);
  ss.begin(9600);
  
}


void locationUpdate() {




  //Key the DRA818v
  digitalWrite(PTT, LOW);


  //End the GPS Serial
  ss.end();
  
  //Turn on the LED
  digitalWrite(LEDG, HIGH);

  //Wait 500 ms for the DRA818v to warm up
  delay(500);

  //Setup the APRS comment
  char comment []= "Arduino APRS Tracker";
  char temp[8];
  char APRS_comment [36]="/A=";

  //Setup the APRS comment data
  Serial.println(alt);
  sprintf(temp, "%06f", alt);
  strcat(APRS_comment,"ALT: ");
  strcat(APRS_comment,temp);
  strcat(APRS_comment,"' ");
  strcat(APRS_comment,comment);
 Serial.println(APRS_comment);


  //Set the Lat/Lon
  APRS_setLat((char*)deg_to_nmea(lat, true));
  APRS_setLon((char*)deg_to_nmea(lon, false));
      


  
  // TX
  APRS_sendLoc(APRS_comment, strlen(APRS_comment));

  //Turn off the LED
  digitalWrite(LEDG, LOW);

  // start GPS Serial again
  ss.begin(9600);

  //unkey the radio
  digitalWrite(PTT, HIGH);

  
}

/*
**  Convert degrees in long format to APRS string format
**  DDMM.hhN for latitude and DDDMM.hhW for longitude
**  D is degrees, M is minutes and h is hundredths of minutes.
**  http://www.aprs.net/vm/DOS/PROTOCOL.HTM
*/
char* deg_to_nmea(long deg, boolean is_lat) {
  bool is_negative=0;
  if (deg < 0) is_negative=1;

  // Use the absolute number for calculation and update the buffer at the end
  deg = labs(deg);

  unsigned long b = (deg % 1000000UL) * 60UL;
  unsigned long a = (deg / 1000000UL) * 100UL + b / 1000000UL;
  b = (b % 1000000UL) / 10000UL;

  conv_buf[0] = '0';
  // in case latitude is a 3 digit number (degrees in long format)
  if( a > 9999) {
    snprintf(conv_buf , 6, "%04lu", a);
  } else {
    snprintf(conv_buf + 1, 5, "%04lu", a);
  }

  conv_buf[5] = '.';
  snprintf(conv_buf + 6, 3, "%02lu", b);
  conv_buf[9] = '\0';
  if (is_lat) {
    if (is_negative) {conv_buf[8]='S';}
    else conv_buf[8]='N';
    return conv_buf+1;
    // conv_buf +1 because we want to omit the leading zero
    }
  else {
    if (is_negative) {conv_buf[8]='W';}
    else conv_buf[8]='E';
    return conv_buf;
    }
}

void aprs_msg_callback(struct AX25Msg *msg) {
}

Noah

Just got it working. Although the weird 2.4v thing is still happening, I found that the power down pin for the DRA818v would go LOW after the setup, shutting it down. By setting this to be high during the loop it fixed the problem.

Noah