Skip to content

Commit 5aa273a

Browse files
Updates from code review
Added datasheet in documentation folder; updated file names to be in correct SFE format; added keywords.txt and library.properties files; for full list of exact changes, see CodeStream for details on comments.
1 parent 87d3df1 commit 5aa273a

File tree

13 files changed

+912
-706
lines changed

13 files changed

+912
-706
lines changed

Documentation/tmag5273.pdf

2.04 MB
Binary file not shown.

examples/Example1_BasicReadings/Example1_BasicReadings.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <Wire.h> // Used to establish serial communication on the I2C bus
2-
#include "SparkFun_TMAG5273.h" // Used to send and recieve specific information from our sensor
2+
#include "SparkFun_TMAG5273_Arduino_Library.h" // Used to send and recieve specific information from our sensor
33

44
TMAG5273 sensor; // Initialize hall-effect sensor
55

66
// I2C default address
7-
uint8_t i2cAddress = I2C_ADDRESS_INITIAL;
7+
uint8_t i2cAddress = TMAG5273_I2C_ADDRESS_INITIAL;
88

99
void setup()
1010
{
@@ -18,7 +18,10 @@ void setup()
1818
Serial.println("TMAG5273 Example 1: Basic Readings");
1919
Serial.println("");
2020
// If begin is successful (0), then start example
21-
if(sensor.begin(i2cAddress, Wire) == true)
21+
22+
Serial.println(sensor.getManufacturerID(), HEX);
23+
24+
if(sensor.begin(i2cAddress, Wire) == 1)
2225
{
2326
Serial.println("Begin");
2427
}
@@ -36,6 +39,8 @@ void loop()
3639
// Checks if mag channels are on - turns on in setup
3740
if(sensor.getMagneticChannel() != 0)
3841
{
42+
sensor.setTemperatureEn(true);
43+
3944
float magX = sensor.getXData();
4045
float magY = sensor.getYData();
4146
float magZ = sensor.getZData();

examples/Example2_IoT_Motor_Driver_Readings/Example2_IoT_Motor_Driver_Readings.ino

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <Wire.h> // Used to establish serial communication on the I2C bus
2-
#include "SparkFun_TMAG5273.h" // Used to send and recieve specific information from our sensor
2+
#include "SparkFun_TMAG5273_Arduino_Library.h" // Used to send and recieve specific information from our sensor
33
#include <SimpleFOC.h>
44

55
/* For easy reading with this example, try opening the serial plotter! */
@@ -8,7 +8,7 @@
88
TMAG5273 sensor;
99

1010
// I2C default address
11-
uint8_t i2cAddress = I2C_ADDRESS_INITIAL;
11+
uint8_t i2cAddress = TMAG5273_I2C_ADDRESS_INITIAL;
1212

1313
// BLDC motor & driver instance
1414
BLDCMotor motor = BLDCMotor(8);
@@ -56,14 +56,6 @@ void IRAM_ATTR isr2(){
5656
}
5757

5858

59-
// Setup pins for current sense outputs
60-
int curr_sense = 32;
61-
int u_sense = 35;
62-
int v_sense = 36;
63-
int w_sense = 39;
64-
65-
66-
6759
void setup()
6860
{
6961
Wire.begin();
@@ -136,13 +128,12 @@ void loop()
136128
{
137129
Serial.print("Temperature: ");
138130
Serial.println(temp);
139-
Serial.printf("Button 14 has been pressed %u times\n", aux1.numberKeyPresses);
140131
aux1.pressed = false;
141132
delay(1000);
142133
}
143134
if(aux2.pressed)
144135
{
145-
Serial.printf("Button 13 has been pressed %u times\n", aux2.numberKeyPresses);
136+
Serial.println("Changing direction.. ");
146137
aux2.pressed = false;
147138
}
148139

examples/Example3_AngleCalculations/Example3_AngleCalculations.ino

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#include <Wire.h> // Used to establish serial communication on the I2C bus
2-
#include "SparkFun_TMAG5273.h" // Used to send and recieve specific information from our sensor
2+
#include "SparkFun_TMAG5273_Arduino_Library.h" // Used to send and recieve specific information from our sensor
33

44
// Create a new sensor object
55
TMAG5273 sensor;
66

77
// I2C default address
8-
uint8_t i2cAddress = I2C_ADDRESS_INITIAL;
8+
uint8_t i2cAddress = TMAG5273_I2C_ADDRESS_INITIAL;
9+
10+
// Set constants for setting up device
11+
uint8_t conversionAverage = TMAG5273_X32_CONVERSION;
12+
uint8_t magneticChannel = TMAG5273_XYX_ENABLE;
13+
uint8_t angleCalculation = TMAG5273_XY_ANGLE_CALCULATION;
914

1015
void setup()
1116
{
@@ -30,15 +35,15 @@ void setup()
3035
}
3136

3237
// Set the device at 32x average mode
33-
sensor.setConvAvg(X32_CONVERSION);
38+
sensor.setConvAvg(conversionAverage);
3439

3540
// Choose new angle to calculate from
3641
// Can calculate angles between XYX, YXY, YZY, and XZX
37-
sensor.setMagneticChannel(XYX_ENABLE);
42+
sensor.setMagneticChannel(magneticChannel);
3843

3944
// Enable the angle calculation register
4045
// Can choose between XY, YZ, or XZ priority
41-
sensor.setAngleEn(XY_ANGLE_CALCULATION);
46+
sensor.setAngleEn(angleCalculation);
4247

4348
}
4449

examples/Example4_Interrupts/Example4_Interrupts.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <Wire.h> // Used to establish serial communication on the I2C bus
2-
#include "SparkFun_TMAG5273.h" // Used to send and recieve specific information from our sensor
2+
#include "SparkFun_TMAG5273_Arduino_Library.h" // Used to send and recieve specific information from our sensor
33

44
TMAG5273 sensor; // Initialize hall-effect sensor
55

66
// I2C default address
7-
uint8_t i2cAddress = I2C_ADDRESS_INITIAL;
7+
uint8_t i2cAddress = TMAG5273_I2C_ADDRESS_INITIAL;
88

99
// Interrupt pin used
1010
// NOTE: This pin is specific to the SparkFun IoT Motor Driver

examples/Example5_LowPower/Example5_LowPower.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <Wire.h> // Used to establish serial communication on the I2C bus
2-
#include "SparkFun_TMAG5273.h" // Used to send and recieve specific information from our sensor
2+
#include "SparkFun_TMAG5273_Arduino_Library.h" // Used to send and recieve specific information from our sensor
33

44
TMAG5273 sensor; // Initialize hall-effect sensor
55

examples/Example6_I2CSettings/Example6_I2CSettings.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <Wire.h> // Used to establish serial communication on the I2C bus
2-
#include "SparkFun_TMAG5273.h" // Used to send and recieve specific information from our sensor
2+
#include "SparkFun_TMAG5273_Arduino_Library.h" // Used to send and recieve specific information from our sensor
33

44
TMAG5273 sensor; // Initialize hall-effect sensor
55

66
// I2C default address
7-
uint8_t i2cAddress = I2C_ADDRESS_INITIAL;
7+
uint8_t i2cAddress = TMAG5273_I2C_ADDRESS_INITIAL;
88

99
void setup()
1010
{

0 commit comments

Comments
 (0)