I get this message when i try to upload a script to an arduino nano.
avrdude: error reading signature data, rc=-1
The script works fine in an identical board (i bought two of the same type)
The script is for outputting GPS Speed data to an Oled display. I think the first time i uploaded i didn't notice the error message and that's why i was uploading again as the project didn't work, It looked like the GPS was getting a signal but the Oled screen was just blank. I tried another Oled and also blank. I tried the Oleds back on the other board and that all works fine. The boards i have are both Nano with screw down connector rails on them which i had to soder on. IM wondering if when soldering on the screwdowns to the second board i may have blown something.
This is the script.
Is there a way of changing the pins to connect the Oled to incase i fried the A4 and A5 pins when soldering?
#include <SPI.h> //Serial Peripheral Interface (SPI) library for synchronous serial data protocol
#include <Wire.h> //Wire library used for I2C communication: Arduino Pro Mini pins used = A4 (SDA) and A5 (SCL)
#include <Adafruit_SSD1306.h> //Adafruit driver for OLED
#include <SoftwareSerial.h> //SoftwareSerial library used to allow serial communication on other digital pins
#include <TinyGPS.h> //GPS Library used to read the data from GPS Module
//
#define OLED_RESET 5
Adafruit_SSD1306 display(OLED_RESET);
TinyGPS gps; //Create the TinyGPS object, giving it a name of your choice (here we use the name gps)
SoftwareSerial nss(3, 4); //set sotfware serial communications to arduino ports 3 and 4 (TX = D3 and RX = D4)
//
void setup() {
nss.begin(9600);
unsigned long age, date, time, chars = 0;
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize the OLED and set the I2C address to 0x3C (for the 128x64 OLED)
display.clearDisplay(); //Clear display buffer.
display.setCursor(0, 0);
display.setTextSize(1);
display.setTextColor(WHITE);
// display.print("INITIALISING.");//print "INITIALISING ....." to display
display.setCursor(0, 0); //set text start position to column=0 and row=40
display.setTextColor(WHITE); //
display.print("Locatingllites"); //print "Trying to locate GPS satellites ..." to display
display.setCursor(0, 20); //set text start position to column=0 and row=57
display.print("Please"); //print "Please Wait" to display
display.display(); //update OLED with new display data
delay(1000); //short delay
display.clearDisplay(); //clear display
}
//MAIN PROGRAMME LOOP
void loop() {
bool newdata = false;
unsigned long start = millis();
while (millis() - start < 1000) { // Every 1 seconds we print an update
if (feedgps())
newdata = true;
}
if (newdata)
{
gpsdump(gps);
}
}
//PRINT GPS DATA TO OLED DISPLAY
void gpsdump(TinyGPS &gps)
{
print_date(gps); //print date and time at top of OLED display
display.clearDisplay();
display.setTextSize(1); //set text size to 1
display.setTextColor(WHITE); //
display.setCursor(0, 0); //set text start position for date and time (row = 0, column =0)
print_date(gps); //prints date and time on top line to OLED
display.setTextSize(2);
display.setCursor(16, 16); // Col 16 row 24
display.println(gps.f_speed_mph(), 1); //print speed(mph) data to display
display.setTextSize(2);
display.setCursor(56, 16); //set text start position to column=56 and row=24
display.println(" Mph"); //print "MPH" to display
display.setCursor(112, 16);
display.setTextSize(1);
display.println(gps.satellites());//print number of satellites detected to display
display.display(); //update OLED display
}
//TEST FOR NEW DATA FROM THE GPS MODULE
bool feedgps()
{
while (nss.available())
{
if (gps.encode(nss.read())) //Each byte of NEMA data must be giving to TinyGPS by using encode(). True is returned when new data has been fully decoded and can be used
return true;
}
return false;
}
//GET DATE AND TIME FOR DISPLAY
static void print_date(TinyGPS &gps)
{
int year;
byte month, day, hour, minute, second, hundredths;
unsigned long age;
gps.crack_datetime(&year, &month, &day, &hour, &minute, &second);
{
char sz[32];
sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d",
day, month, year, (hour + 1), minute, second);
// NOTE ! changed hour to (hour+1) to allow for BST
// remove brackets and +1 to reset
display.print(sz); //Print date and time to OLED
}
}