0

I've been trying to use an attiny85 to reduce my project footprint, thing is, it looks like something is very wrong. The project works just fine using an Arduino Uno and produces the expected results.

What am i missing here?

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

TinyGPSPlus gps;

SoftwareSerial neo(3, 4);
SoftwareSerial output(2, 1);

/*
reset    5V
A3/3     2
A2/4     1  
Gnd      0
*/
void setup()
{     
  output.begin(9600);
  neo.begin(9600);
  output.println(F("GPS init..."));  
}

void loop()
{
  while (neo.available() > 0)
    if (gps.encode(neo.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    output.println(F("{\"Error\" : \"No GPS detected: please check device.\"}"));
    while(true);
  }
}

void displayInfo()
{
    if (gps.location.isUpdated())
  {
    output.print(F("{\"Data\" : {"));
    output.print(F("\"Lon\" : \""));
    output.print(gps.location.lat(), 6);
    output.print(F("\", \"Lat\" : \""));
    output.print(gps.location.lng(), 6);
    output.print(F("\", "));
    output.print(F("\"Valid\" : \""));
    output.print(gps.location.isValid());
    output.print(F("\", "));

    output.print(F("\"TimeStamp\" : "));
    output.print(F("\""));
    output.print(gps.date.year());
    output.print(F("-"));
    if (gps.date.month() < 10) output.print(F("0"));
    output.print(gps.date.month());
    output.print(F("-"));
    if (gps.date.day() < 10) output.print(F("0"));
    output.print(gps.date.day());

    output.print(F("T"));
    if (gps.time.hour() < 10) output.print(F("0"));
    output.print(gps.time.hour());
    output.print(F(":"));
    if (gps.time.minute() < 10) output.print(F("0"));
    output.print(gps.time.minute());
    output.print(F(":"));
    if (gps.time.second() < 10) output.print(F("0"));
    output.print(gps.time.second());
    output.print(F("."));
    if (gps.time.centisecond() < 10) output.print(F("0"));
    if (gps.time.centisecond() < 100) output.print(F("0"));
    output.print(gps.time.centisecond());

    output.print(F("Z\", "));
    output.print(F("\"Satellites\" : "));
    output.print(gps.satellites.value());
    output.print(F(" , \"FixAge\" : "));
    output.print(gps.satellites.value());

    output.println("} }");
  }
}

Thank you

  • 3
    "something is very wrong" is a bit of a vague statement... – Majenko May 9 '18 at 16:19
  • What are the results you get on the Uno and what does ATTiny do exactly? What is the wireup for these 2 setups? – Maximilian Gerhardt May 9 '18 at 16:25
  • neo.listen(); – Majenko May 9 '18 at 16:30
  • I didn't need the neo.listen() when using the uno, but it does makes sense. When using "Serial" instead of "output" i was able to get info from the gps. When i switched to attiny, the data just can't be read, as the bps rate was wrong. – Alexandre Dias May 9 '18 at 18:11
  • Wiring GPS TX -> attiny pin 2; GPS RX ->attiny pin 3; attiny pin 6 -> ftdi RX; attiny pin 7 -> ftdi TX; reading ftdi @9600 – Alexandre Dias May 9 '18 at 18:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.