Code works on UNO but not on Nano Every

Hi,

I used an Arduino Uno and ublox gps neo 8m. The code works and I get every second my location via serial monitor. For finishing the project I bought a Nano every. I uploaded the code but I get once in the ~3 min my location via serial monitor. The Tx lights on the Nano doesnt blink also.

#include <AD9850.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 0, TXPin = 1;
static const uint32_t GPSBaud = 9600;

const int W_CLK_PIN = 8;
const int FQ_UD_PIN = 9;
const int DATA_PIN = 10;
const int RESET_PIN = 11;

double freq = 1;
double trimFreq = 124999500;

int phase = 0;

unsigned int speed = 0;

TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);
  DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN);
  DDS.calibrate(trimFreq);
}

void loop()
{
  // Dispatch incoming characters
  while (ss.available() > 0)
    gps.encode(ss.read());


  if (gps.speed.isUpdated())
  {
    Serial.print(F("SPEED      Fix Age="));
    Serial.print(gps.speed.age());
    Serial.print(F("ms Raw="));
    Serial.print(gps.speed.value());
    Serial.print(F(" km/h="));
    Serial.println(gps.speed.kmph()); 
    speed=gps.speed.kmph();
    //calculate the frequency with map()
    freq = map(speed, 0, 100, 0, 160);
    DDS.setfreq(freq, phase);   
  }

}

Did you install the core for Nano Every?

They have different processors. You may have to research your libraries and find alternatives.

Check your wiring closely for the serial pins. It looks like tx and RX are switched in location from the nano to the Uno. It’s still RX 0 and tx 1 however.

One would have thought Arduino would have picked a better product name than to reuse the word "Nano..."

Combining intelligent hardware peripherals along with the low-power capability of the AVR® core, megaAVR® microcontrollers (MCUs) broaden the effectiveness of your real-time control systems. Devices like the ATmega4809, ATmega4808, ATmega3209 and ATmega3208 offer individualized options for larger memory, pin counts and packages, while devices such as the ATmega1609, ATmega1608, ATmega809 and ATmega808 offer lower memory and pin-count variants. In addition to their easy-to-configure Core Independent Peripherals, all of these devices include a high-speed Analog-to-Digital Converter (ADC) that enables efficient noise reduction. This makes devices in the ATmega4809 family optimal as companion MCUs for complex microprocessor-based systems, or as stand-alone processors in command-and-control environments.

I did install the core. Arduino IDE prompt itself to install it.

@studiogamma I checked the pins indeed. The strange thing is that it sometimes output information through.

You don't need SoftwareSerial. Pins 0 and 1 are Serial1 on a Nano Every.

This might solve the problem.

Your topic has been moved to the dedicated Nano Every section of the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

What is the AD9850 supposed to be doing?

The gps module works on 3.3v and 5v. It works also on the Uno pinned to the 5v.

@jremington the AD9850 is the module I'm using to driven my speedometer.

@sterretje to clarify: I just delete the softwareserial library and the softwareserial line?

1 Like

Can you adjust the code what might have to work?

I think this is the code modified for the Nano Every. gps module Tx to Every Rx and gps module Tx to Every Tx.

#include <AD9850.h>
#include <TinyGPS++.h>
//#include <SoftwareSerial.h>

//static const int RXPin = 0, TXPin = 1;
static const uint32_t GPSBaud = 9600;

const int W_CLK_PIN = 8;
const int FQ_UD_PIN = 9;
const int DATA_PIN = 10;
const int RESET_PIN = 11;

double freq = 1;
double trimFreq = 124999500;

int phase = 0;

unsigned int speed = 0;

TinyGPSPlus gps;
//SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  //ss.begin(GPSBaud);
  Serial1.begin(GPSBaud);
  DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN);
  DDS.calibrate(trimFreq);
}

void loop()
{
  // Dispatch incoming characters
  //while (ss.available() > 0)
  while (Serial1.available() > 0)
    //gps.encode(ss.read());
    gps.encode(Serial1.read());


  if (gps.speed.isUpdated())
  {
    Serial.print(F("SPEED      Fix Age="));
    Serial.print(gps.speed.age());
    Serial.print(F("ms Raw="));
    Serial.print(gps.speed.value());
    Serial.print(F(" km/h="));
    Serial.println(gps.speed.kmph()); 
    speed=gps.speed.kmph();
    //calculate the frequency with map()
    freq = map(speed, 0, 100, 0, 160);
    DDS.setfreq(freq, phase);   
  }

}

@cattledog @sterretje heroes!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.