I recently bought 2 of Arduino Nano R4, at beginning they work well, until I ran SparkFun TMP102 with qwiic port.
first I ran into issue with R4 qwiic port with "wire.begin()", after look up some posts, I realize that the example from SparkFUN is only for A3,4,5 not for qwiic port. need to "wire1.begin()", but still not work.
anyone has correct code?
Define 'stil not work/
Did it compile ok?
Does the begin take any arguments? Maybe pins?
Post your code in code tags so we can try it.
Hi,
Actually now
- Arduino Nano R4 can not be detect as COM Port no more, I plug in to other laptop show the same,I think they are dead.
- I am now using Arduino UNO Q connect same Sparkfun TMP102 qwiic to UNO Q qwiic port, set to Wire1.begin(), Serial.begin().
- remove all Alert pin statement in the sample code.
- compile completed, but nothing out of Serial monitor
- I was trying 5pin connect to A3,4,5 to Nano R4 with original example code, it works.
Now my 2 Nano R4 both not working, can not recognize as comport.
super frustration.
I moved your topic to an appropriate forum category @simonnanoc.
In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Please follow the recommendations in the guide linked in post #4 and post your code and relevant error messages. Then we may be in a better position to help. Remember, we can't see what you see on your screen.
Its Wire1.begin(), btw.
On the UNO Q, Serial.begin() activates hardware serial pins Tx0/Tx1 which, in this case, are NOT connected to the USB port. To get output on the Serial Monitor, you need to use:
Monitor.begin();
and then;
Monitor.println("My message");
etc.
Sounds like a USB cable problem. Have you tried another cable?
Any LEDs lighting up?
Ok, when you decide to answer the questions, maybe someone can help.
Changing the setup is not helpful.
Hi
I was using same cable for UNO Q, that recognized fine. not a cable issue.
for the Serial.begin(), I do see the temperature read with serial.begin() from the serial monitor.
After load with same code, see below
I am able to run with Seeed Studio XIAO any qwiic ports to se the result, which print to serial monitor,
I am not sure now the Qwiic port on Nano R4 or UNO Q has been defined correctly?
Temperature: 75.31
Temperature: 77.68
Temperature: 76.21
Temperature: 80.94
Temperature: 81.50
Temperature: 81.95
Temperature: 82.18
Temperature: 82.18
Temperature: 82.18
Temperature: 82.29
Temperature: 82.18
Temperature: /82.18***************************************
Example1_Basic_Temperature_Readings.ino
Example for the TMP102 I2C Temperature Sensor
Alex Wende @ SparkFun Electronics
April 29th 2016
~
This sketch configures the TMP102 temperature sensor and prints the
temperature and alert state (both from the physical pin, as well as by
reading from the configuration register.
Resources:
Wire.h (included with Arduino IDE)
SparkFunTMP102.h
Development environment specifics:
Arduino 1.0+
This code is beerware; if you see me (or any other SparkFun employee) at
the local, and you've found our code helpful, please buy us a round!
Distributed as-is; no warranty is given.
******************************************************************************/
// Include the SparkFun TMP102 library.
// Click here to get the library: http://librarymanager/All#SparkFun_TMP102
#include <Wire.h> // Used to establied serial communication on the I2C bus
#include <SparkFunTMP102.h> // Used to send and recieve specific information from our sensor
// Connections
// VCC = 3.3V
// GND = GND
// SDA = A4
// SCL = A5
TMP102 sensor0;
// Sensor address can be changed with an external jumper to:
// ADD0 - Address
// VCC - 0x49
// SDA - 0x4A
// SCL - 0x4B
void setup() {
Serial.begin(115200);
Wire.begin(); //Join I2C Bus
/* The TMP102 uses the default settings with the address 0x48 using Wire.
Optionally, if the address jumpers are modified, or using a different I2C bus,
these parameters can be changed here. E.g. sensor0.begin(0x49,Wire1)
It will return true on success or false on failure to communicate. */
if(!sensor0.begin())
{
Serial.println("Cannot connect to TMP102.");
Serial.println("Is the board connected? Is the device ID correct?");
while(1);
}
Serial.println("Connected to TMP102!");
delay(100);
}
void loop()
{
float temperature;
boolean alertPinState, alertRegisterState;
// Turn sensor on to start temperature measurement.
// Current consumtion typically ~10uA.
sensor0.wakeup();
// read temperature data
temperature = sensor0.readTempF();
//temperature = sensor0.readTempC();
// Place sensor in sleep mode to save power.
// Current consumtion typically <0.5uA.
sensor0.sleep();
// Print temperature and alarm state
Serial.print("Temperature: ");
Serial.println(temperature);
delay(1000); // Wait 1000ms
If you are using v1.5.2 of the R4 boards package, then there was another post on here the other day about Wire1 not working in that version:
https://forum.arduino.cc/t/r4-version-1-5-2-issue-with-wire1-port/1425293
You could try reverting back to v1.5.1 or using the workaround mentioned in post #5.
Dunno about the UNO Q.
Please edit your post - select your code then click the <CODE/> icon at the top of the post editor window. This formats your code example for the forum to make it more readable. You can also use the Edit -> Copy for Forum feature in the IDE to copy code and paste it into your post.
Sorry, I am only going off of hints of information here on this thread:
From it I am assuming you are using the library: SparkFun_TMP102_Arduino_Library
And running their example sketch: Example1_Basic_Temperature_Readings
Their library allows you to specify which Wire object to use on it's begin method:
bool begin(uint8_t deviceAddress = 0x48, TwoWire &wirePort = Wire);
In that example they show you what to do for WIre1:
/* The TMP102 uses the default settings with the address 0x48 using Wire.
Optionally, if the address jumpers are modified, or using a different I2C bus,
these parameters can be changed here. E.g. sensor0.begin(0x49,Wire1)
It will return true on success or false on failure to communicate. */
if(!sensor0.begin())
Change that begin line to:
if(!sensor0.begin(0x48, Wire1))
still not working
#include <Wire.h> // Used to establied serial communication on the I2C bus
#include <SparkFunTMP102.h> // Used to send and recieve specific information from our sensor
// Connections
// VCC = 3.3V
// GND = GND
// SDA = A4
// SCL = A5
TMP102 sensor0;
// Sensor address can be changed with an external jumper to:
// ADD0 - Address
// VCC - 0x49
// SDA - 0x4A
// SCL - 0x4B
void setup() {
Serial.begin(115200);
Wire1.begin(); //Join I2C Bus
}
void loop()
{
float temperature;
sensor0.begin(0x48, Wire1);
temperature = sensor0.readTempF();
//temperature = sensor0.readTempC();
// Print temperature and alarm state
Serial.println(temperature);
delay(5000); // Wait 1000ms
}
Note: Please put code in code tags, it makes it a lot easier to read and it
preserves things like indention.
It is easiest to simply select your text and click on the <code> item in
the toolbar.
Or at times I simply do it by typing in three ` characters at the start and again at end
like:
```
My code
...
```
Note on my keyboards that character is to the left of the 1 key.
Note: I would move the begin statement into setup instead of repeat calling
it in loop.
And in your test run what did you try it on? Q and/or Nano R4 or ???
I have merged your cross-posts @simonnanoc.
Cross-posting is against the Arduino Forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
@simonnanoc this is the third warning I have given you in the single day you have been a forum member. I requested you read the forum user guide, but your behavior shows that you did not do so. It is time for you to start behaving in a responsible and respectful manner. READ THE GUIDE!!!!!! If you won't respond to my polite requests, I will be forced to resort to account suspension to get your attention. I don't want to do that, and I'm sure you don't want it either.
Thanks in advance for your cooperation.
As others have said, what do you mean by:
Is it that you don't see anything in the Serial monitor? Or did it crash?
Here is your sketch within code tags after I pasted into Arduino window and formatted. Note, I moved the begin, and a few minor other changes.
#include <Wire.h> // Used to establied serial communication on the I2C bus
#include <SparkFunTMP102.h> // Used to send and recieve specific information from our sensor
// Connections
// VCC = 3.3V
// GND = GND
// SDA = A4
// SCL = A5
TMP102 sensor0;
// Sensor address can be changed with an external jumper to:
// ADD0 - Address
// VCC - 0x49
// SDA - 0x4A
// SCL - 0x4B
void setup() {
Serial.begin(115200);
Wire1.begin();
if (!sensor0.begin(0x48, Wire1)) {
Serial.print("TMP102 sensor begin failed");
}
}
void loop() {
float temperature;
temperature = sensor0.readTempF();
//temperature = sensor0.readTempC();
// Print temperature and alarm state
Serial.println(temperature);
delay(5000); // Wait 5 seconds
}
Notes/Comments:
-
Added test to see if the device begin succeeded.
-
On the Q, with your current code, nothing will show up in the Arduino
IDE Serial monitor. Why? The Serial object goes to IO pins D0, D1 on the Q
To see these you typically need to hook up an USB To Serial adapter (3.3v version) to these two pins.
And on your PC, you need to startup some Serial Terminal software on the communication port that corresponds to your USB To serial adapter and
have it configured to 115200.
(Side track)
@ptillisch (and others) currently I believe it must be configured for 115200 as
the Zephyr Debug Monitor is configured to be used by this Serial port.
Likewise I wish the Arduino_Modulino examples were better setup for the Q, that is
for example for the buttons_basic example:
/*
* Modulino Buttons - Basic
*
* This example code is in the public domain.
* Copyright (c) 2025 Arduino
* SPDX-License-Identifier: MPL-2.0
*/
#include <Arduino_Modulino.h>
// Create a ModulinoButtons object
ModulinoButtons buttons;
bool button_a = true;
bool button_b = true;
bool button_c = true;
void setup() {
Serial.begin(115200);
// Initialize Modulino I2C communication
Modulino.begin();
// Detect and connect to buttons module
buttons.begin();
// Turn on the LEDs above buttons A, B, and C
buttons.setLeds(true, true, true);
}
void loop() {
// Check for new button events, returns true when button state changes
if (buttons.update()) {
// You can use either index (0=A, 1=B, 2=C) or letter ('A', 'B', 'C') to check buttons
// Below we use the letter-based method for better readability
if (buttons.isPressed('A')) {
Serial.println("Button A pressed!");
button_a = !button_a;
} else if (buttons.isPressed("B")) {
Serial.println("Button B pressed!");
button_b = !button_b;
} else if (buttons.isPressed('C')) {
Serial.println("Button C pressed!");
button_c = !button_c;
}
// Update the LEDs above buttons, depending on the variables value
buttons.setLeds(button_a, button_b, button_c);
}
}
I had to change it from 9600 to 115200 to see anything...
uart:~$
System Heap end: 0x20055440
System Heap start: 0x20035440
Sketch Heap start: 0x2000c3e0, size 0x20000
uart:~$ Button C pressed!
Button B pressed!
Button A pressed!
Button C pressed!
Button B pressed!
Button A pressed!
On Q, they should output to Monitor instead of Serial.
Wish in Q core they would have Serial instead of Monitor
Serial1 on pins 0,1...
(End side track)
If you wish to see stuff on the Serial monitor using the Q the sketch would look
more like:
#include <Wire.h> // Used to establied serial communication on the I2C bus
#include <SparkFunTMP102.h> // Used to send and recieve specific information from our sensor
#include <Arduino_RouterBridge.h>
// Connections
// VCC = 3.3V
// GND = GND
// SDA = A4
// SCL = A5
TMP102 sensor0;
// Sensor address can be changed with an external jumper to:
// ADD0 - Address
// VCC - 0x49
// SDA - 0x4A
// SCL - 0x4B
void setup() {
Monitor.begin();
Wire1.begin();
if (!sensor0.begin(0x48, Wire1)) {
Serial.print("TMP102 sensor begin failed");
}
}
void loop() {
float temperature;
temperature = sensor0.readTempF();
//temperature = sensor0.readTempC();
// Print temperature and alarm state
Monitor.println(temperature);
delay(5000); // Wait 5 seconds
}
Not sure why the begin of the device does not fail, although I have not
looked much at the Sparkfun code. But my wire scanner code only
finds
Scanning Wire...
No I2C devices found
Scanning Wire1...
Device found at address 0x3E (unknown chip)
done
Hopefully there is enough stuff here to get you going