I'm trying to connect several QWIIC boards to my arduino and they don't seem to be talking to each other.
I have a Leonardo and a Mega 2560. I bought a PTSolns RTC MicroSD Data Logger (PTS-00204-211) and a SparkFun GPS Breakout - NEO-M9N (GPS-17285) that both connect using QWIIC.
To connect them to my control boards, I bought a SparkFun Qwiic Shield for Arduino (DEV-14352). I also bought several premade cables.
Both the RTC and GPS get power, but I was getting errors trying to run the default GetDateTime sketch. So I loaded the I2CScanner library and ran the example sketch and it's unable to find either the GPS or RTC, and it does this from either the Leo or Mega.
Am I missing something?
I looked at the default pins and was surprised to see it was using the analog pins (A4/A5) for digital communications (I2C). But everything seems to line up on the schematics for the Qwiic Shield. Is the Qwiic Shield defective?
I tried putting it after the includes:
error: redefinition of 'const uint8_t SDA'
/*
Getting time and date using u-blox commands
By: davidallenmann
SparkFun Electronics
Date: April 16th, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to query a u-blox module for the current time and date. We also
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
dramatically.
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Plug a Qwiic cable into the GNSS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GNSS
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;
#define PIN_WIRE_SDA (20)
#define PIN_WIRE_SCL (21)
static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
void setup()
{
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
while (1)
;
}
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
}
void loop()
{
//Query module only every second. Doing it more often will just cause I2C traffic.
//The module only responds when a new position is available
if (millis() - lastTime > 1000)
{
lastTime = millis(); //Update the timer
long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);
long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));
long altitude = myGNSS.getAltitude();
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.print(F(" (mm)"));
byte SIV = myGNSS.getSIV();
Serial.print(F(" SIV: "));
Serial.print(SIV);
Serial.println();
Serial.print(myGNSS.getYear());
Serial.print("-");
Serial.print(myGNSS.getMonth());
Serial.print("-");
Serial.print(myGNSS.getDay());
Serial.print(" ");
Serial.print(myGNSS.getHour());
Serial.print(":");
Serial.print(myGNSS.getMinute());
Serial.print(":");
Serial.print(myGNSS.getSecond());
Serial.print(" Time is ");
if (myGNSS.getTimeValid() == false)
{
Serial.print("not ");
}
Serial.print("valid Date is ");
if (myGNSS.getDateValid() == false)
{
Serial.print("not ");
}
Serial.print("valid");
Serial.println();
}
}
If your shield(s?) are using the SDA/SCL pins beside the AREF pin you shouldn't be putting that anywhere and leaving it up to whatever core platform you're using to define.
With it powered up and your meter’s ground (black wire) connected touch the SCL and SDA pins with the red probe. You should measure at least 4 volts. If it is less then that you need pull up resistors. If you do not have a volt meter you can purchase an inexpensive one for less then the cost of a pack of cigarettes.
Yes, I know the QWIIC connector is there. But it's on a shield that plugs into a Uno footprint board. If you're trying to communicate with the shield over the QWIIC connector, you will be disappointed. The shield communicates with the processor board through the stacking pins.
I suggest you try first to power the GPS board from USB if possible with its I/O connected to your Arduino via the QWIIC shield. The Arduinos are marginally able to power one of your boards at a time from their 3V3 supplies.
Obviously with the shield plugged into the Arduino.
Looking at he Data logger board docs, it looks like it is designed to be powered from the Arduino 5V via stacking and the SPI connections are via stacking as well. I'm not sure why the put the QWIIC connector on it except just as a convenience. You could probably use it to run the GPS board and skip the QWIIC Shiel altogether.
I ran the I2CScanner sketch on my Mega with the Qwiic shield attached. This program sends out a burst of data every 5 seconds. Then I dusted off a cheap scope and probed the A4/A5 lines - the very ones the Qwiic shield is connected to. Nothing. I noticed on the Mega board there are two pins on the opposite side of the board labeled SDA/SCL. I probed those - success, those had data bursts corresponding to the program messages.
So now the question seems to be, how do I change the program to use the right pins?
I saw someone post something about using Wire1 instead of Wire, buy my one attempt to do that saw lots of compile errors.
Green is where I measured the data bursts.
Red is where the Qwiic Shield is currently connected to.
You could consider using the Leonardo instead since it has SDA/SCL where the QWIIC shield expects them. Modifying the shield to work with the Mega doesn't seem to be an easy fix.
Edit: Actually, looking at the Leonardo schematic, it has SDA/SCL over by AREF as well. Looks like the QWIIC shield is UNO R3 pinout specific.