Update sensor examples

This commit is contained in:
lewisxhe 2026-04-08 14:52:34 +08:00
commit 7624e98d89
17 changed files with 216 additions and 7570 deletions

View file

@ -1,235 +0,0 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 lewis he
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @file QMC6310_CalibrateExample.ino
* @author Lewis He (lewishe@outlook.com)
* @date 2022-10-16
*
*/
#include <Wire.h>
#include <SPI.h>
#include <Arduino.h>
#include "SensorQMC6310.hpp"
#include "LoRaBoards.h"
SensorQMC6310 qmc;
void calibrate()
{
qmc.setDataOutputRate(SensorQMC6310::DATARATE_200HZ);
int32_t x_min = 65535;
int32_t x_max = -65535;
int32_t y_min = 65535;
int32_t y_max = -65535;
int32_t z_min = 65535;
int32_t z_max = -65535;
Serial.println("Place the sensor on the plane and slowly rotate the sensor...");
int32_t range = 1000;
int32_t i = 0;
int32_t x = 0, y = 0, z = 0;;
float a = 0.5 ;
float x_offset = 0;
float y_offset = 0;
float z_offset = 0;
while (i < range) {
i += 1;
if (qmc.isDataReady()) {
qmc.readData();
x = a * qmc.getRawX() + (1 - a) * x;
y = a * qmc.getRawY() + (1 - a) * y;
z = a * qmc.getRawZ() + (1 - a) * z;
if (x < x_min) {
x_min = x;
i = 0;
}
if (x > x_max) {
x_max = x;
i = 0;
}
if (y < y_min) {
y_min = y;
i = 0;
}
if (y > y_max) {
y_max = y;
i = 0;
}
if (z < z_min) {
z_min = z;
i = 0;
}
if (z > z_max) {
z_max = z;
i = 0;
}
int j = round(10 * i / range);
Serial.print("[");
for (int k = 0; k < j; ++k) {
Serial.print("*");
}
Serial.println("]");
}
delay(5);
}
x_offset = (x_max + x_min) / 2;
y_offset = (y_max + y_min) / 2;
z_offset = (z_max + z_min) / 2;
Serial.printf("x_min:%d x_max:%d y_min:%d y_max:%d z_min:%d z_max:%d\n", x_min, x_max, y_min, y_max, z_min, z_max);
Serial.printf("x_offset:%.2f y_offset:%.2f z_offset:%.2f \n", x_offset, y_offset, z_offset);
// Set the calibration value and the user calculates the deviation
qmc.setOffset(x_offset, y_offset, z_offset);
}
void setup()
{
Serial.begin(115200);
while (!Serial);
setupBoards();
// For QMC6310U, the device address is 0x1C.
// For QMC6310N, the device address is 0x3C.
// The sensor device address is provided by the setupBoards I2C scanner.
extern uint8_t mag_address;
if (!qmc.begin(Wire, mag_address, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6310 - check your wiring!");
while (1) {
delay(1000);
}
}
/* Get Magnetometer chip id*/
Serial.print("Device ID:");
Serial.println(qmc.getChipID(), HEX);
/* Config Magnetometer */
qmc.configMagnetometer(
/*
* Run Mode
* MODE_SUSPEND
* MODE_NORMAL
* MODE_SINGLE
* MODE_CONTINUOUS
* * */
SensorQMC6310::MODE_CONTINUOUS,
/*
* Full Range
* RANGE_30G
* RANGE_12G
* RANGE_8G
* RANGE_2G
* * */
SensorQMC6310::RANGE_8G,
/*
* Output data rate
* DATARATE_10HZ
* DATARATE_50HZ
* DATARATE_100HZ
* DATARATE_200HZ
* * */
SensorQMC6310::DATARATE_200HZ,
/*
* Over sample Ratio1
* OSR_8
* OSR_4
* OSR_2
* OSR_1
* * * */
SensorQMC6310::OSR_1,
/*
* Down sample Ratio1
* DSR_8
* DSR_4
* DSR_2
* DSR_1
* * */
SensorQMC6310::DSR_1);
// Calibration algorithm reference from
// https://github.com/CoreElectronics/CE-PiicoDev-QMC6310-MicroPython-Module
calibrate();
Serial.println("Calibration done .");
delay(5000);
Serial.println("Read data now...");
}
void loop()
{
//Wiat data ready
if (qmc.isDataReady()) {
qmc.readData();
Serial.print("GYR: ");
Serial.print("X:");
Serial.print(qmc.getX());
Serial.print(" Y:");
Serial.print(qmc.getY());
Serial.print(" Z:");
Serial.print(qmc.getZ());
Serial.println(" uT");
Serial.print("RAW: ");
Serial.print("X:");
Serial.print(qmc.getRawX());
Serial.print(" Y:");
Serial.print(qmc.getRawY());
Serial.print(" Z:");
Serial.println(qmc.getRawZ());
/*
float x, y, z;
qmc.getMag(x, y, z);
Serial.print("X:");
Serial.print(x);
Serial.print(" Y:");
Serial.print(y);
Serial.print(" Z:");
Serial.println(x);
*/
}
delay(100);
}

File diff suppressed because it is too large Load diff

View file

@ -1,145 +0,0 @@
/**
* @file boards.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-04-25
* @last-update 2024-08-07
*/
#pragma once
#include "utilities.h"
#ifdef HAS_SDCARD
#include <SD.h>
#endif
#if defined(ARDUINO_ARCH_ESP32)
#include <FS.h>
#include <WiFi.h>
#endif
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#ifdef DISPLAY_MODEL
#include <U8g2lib.h>
#endif
#ifdef HAS_PMU
#include <XPowersLib.h>
#endif
#include <esp_mac.h>
#ifndef DISPLAY_ADDR
#define DISPLAY_ADDR 0x3C
#endif
// #define ENABLE_BLE //Enable ble function
enum {
POWERMANAGE_ONLINE = _BV(0),
DISPLAY_ONLINE = _BV(1),
RADIO_ONLINE = _BV(2),
GPS_ONLINE = _BV(3),
PSRAM_ONLINE = _BV(4),
SDCARD_ONLINE = _BV(5),
AXDL345_ONLINE = _BV(6),
BME280_ONLINE = _BV(7),
BMP280_ONLINE = _BV(8),
BME680_ONLINE = _BV(9),
QMC6310U_ONLINE = _BV(10),
QMC6310N_ONLINE = _BV(11),
QMI8658_ONLINE = _BV(12),
PCF8563_ONLINE = _BV(13),
OSC32768_ONLINE = _BV(14),
QMC6309_ONLINE = _BV(15),
};
typedef struct {
String chipModel;
float psramSize;
uint8_t chipModelRev;
uint8_t chipFreq;
uint8_t flashSize;
uint8_t flashSpeed;
} DevInfo_t;
void setupBoards(bool disable_u8g2 = false);
#ifdef HAS_SDCARD
bool beginSDCard();
#else
#define beginSDCard()
#endif
#ifdef DISPLAY_MODEL
bool beginDisplay();
#endif
void printResult(bool radio_online);
#ifdef BOARD_LED
void flashLed();
#else
#define flashLed()
#endif
void scanDevices(TwoWire *w);
bool beginGPS();
bool recoveryGPS();
void scanWiFi();
#ifdef HAS_PMU
extern XPowersLibInterface *PMU;
extern bool pmuInterrupt;
void loopPMU(void (*pressed_cb)(void));
bool beginPower();
void disablePeripherals();
#else
#define beginPower()
#define disablePeripherals()
#endif
#ifdef DISPLAY_MODEL
extern U8G2 *disp;
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
#endif
#if defined(ARDUINO_ARCH_ESP32)
#if defined(HAS_SDCARD)
extern SPIClass SDCardSPI;
#endif
#define SerialGPS Serial1
#elif defined(ARDUINO_ARCH_STM32)
extern HardwareSerial SerialGPS;
#endif
#ifdef NTC_PIN
float getTempForNTC();
#endif
#ifdef ENABLE_BLE
void setupBLE();
#else
#define setupBLE()
#endif
extern uint32_t deviceOnline;

View file

@ -1,211 +0,0 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 lewis he
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @file QMC6310_GetDataExample.ino
* @author Lewis He (lewishe@outlook.com)
* @date 2022-10-16
*
*/
#include <Wire.h>
#include <SPI.h>
#include <Arduino.h>
#include "SensorQMC6310.hpp"
#include "SH1106Wire.h" //Oled display from https://github.com/ThingPulse/esp8266-oled-ssd1306
#include "LoRaBoards.h"
SH1106Wire display(0x3c, I2C_SDA, I2C_SCL);
SensorQMC6310 qmc;
int last_dx, last_dy, dx, dy, angle;
const int centreX = 32;
const int centreY = 30;
const int radius = 22;
//Compass application from https://github.com/G6EJD/ESP8266_micro_compass_HMC5883_OLED
void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, OLEDDISPLAY_COLOR color)
{
display.setColor(color);
float distance;
int dx, dy, x2o, y2o, x3, y3, x4, y4, k;
distance = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
dx = x2 + (x1 - x2) * alength / distance;
dy = y2 + (y1 - y2) * alength / distance;
k = awidth / alength;
x2o = x2 - dx;
y2o = dy - y2;
x3 = y2o * k + dx;
y3 = x2o * k + dy;
x4 = dx - y2o * k;
y4 = dy - x2o * k;
display.drawLine(x1, y1, x2, y2);
display.drawLine(x1, y1, dx, dy);
display.drawLine(x3, y3, x4, y4);
display.drawLine(x3, y3, x2, y2);
display.drawLine(x2, y2, x4, y4);
}
void setup()
{
Serial.begin(115200);
while (!Serial);
setupBoards();
// For QMC6310U, the device address is 0x1C.
// For QMC6310N, the device address is 0x3C.
// The sensor device address is provided by the setupBoards I2C scanner.
extern uint8_t mag_address;
if (!qmc.begin(Wire, mag_address, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6310 - check your wiring!");
while (1) {
delay(1000);
}
}
display.init();
last_dx = centreX;
last_dy = centreY;
/* Get Magnetometer chip id*/
Serial.print("Device ID:");
Serial.println(qmc.getChipID(), HEX);
/* Config Magnetometer */
int r = qmc.configMagnetometer(
/*
* Run Mode
* MODE_SUSPEND
* MODE_NORMAL
* MODE_SINGLE
* MODE_CONTINUOUS
* * */
SensorQMC6310::MODE_NORMAL,
/*
* Full Range
* RANGE_30G
* RANGE_12G
* RANGE_8G
* RANGE_2G
* * */
SensorQMC6310::RANGE_2G,
/*
* Output data rate
* DATARATE_10HZ
* DATARATE_50HZ
* DATARATE_100HZ
* DATARATE_200HZ
* * */
SensorQMC6310::DATARATE_100HZ,
/*
* Over sample Ratio1
* OSR_8
* OSR_4
* OSR_2
* OSR_1
* * * */
SensorQMC6310::OSR_1,
/*
* Down sample Ratio1
* DSR_8
* DSR_4
* DSR_2
* DSR_1
* * */
SensorQMC6310::DSR_1);
if (r != 0) {
Serial.println("Device config failed!");
while (1)delay(1000);
}
// Print register configuration information
qmc.dumpCtrlRegister();
Serial.println("Read data now...");
}
void loop()
{
//Wiat data ready
if (qmc.isDataReady()) {
qmc.readData();
display.drawString(29, 0, "N");
display.drawString( 0, 28, "W");
display.drawString(60, 28, "E");
display.drawString(29, 53, "S");
display.drawLine(1, 1, 7, 7);
display.drawLine(62, 1, 56, 7);
display.drawLine(1, 62, 7, 56);
display.drawLine(56, 56, 62, 62);
//Compass application from https://github.com/G6EJD/ESP8266_micro_compass_HMC5883_OLED
float heading = atan2(qmc.getY(), qmc.getX()); // Result is in radians
// Now add the 'Declination Angle' for you location. Declination is the variation in magnetic field at your location.
// Find your declination here: http://www.magnetic-declination.com/
// At my location it is : -2° 20' W, or -2.33 Degrees, which needs to be in radians so = -2.33 / 180 * PI = -0.041 West is + E is -
// Make declination = 0 if you can't find your Declination value, the error is negible for nearly all locations
float declination = -0.041;
heading = heading + declination;
if (heading < 0) heading += 2 * PI; // Correct for when signs are reversed.
if (heading > 2 * PI) heading -= 2 * PI; // Correct for when heading exceeds 360-degree, especially when declination is included
angle = int(heading * 180 / M_PI); // Convert radians to degrees for more a more usual result
// For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions
dx = (0.7 * radius * cos((angle - 90) * 3.14 / 180)) + centreX; // calculate X position for the screen coordinates - can be confusing!
dy = (0.7 * radius * sin((angle - 90) * 3.14 / 180)) + centreY; // calculate Y position for the screen coordinates - can be confusing!
arrow(last_dx, last_dy, centreX, centreY, 2, 2, BLACK); // Erase last arrow
arrow(dx, dy, centreX, centreY, 2, 2, WHITE); // Draw arrow in new position
display.setColor(BLACK);
display.fillRect(80, 50, 25, 48);
display.setColor(WHITE);
display.drawString(80, 50, String(angle) + "°");
display.display();
last_dx = dx;
last_dy = dy;
// for debug.
Serial.print("GYR: ");
Serial.print("X:");
Serial.print(qmc.getX());
Serial.print(" Y:");
Serial.print(qmc.getY());
Serial.print(" Z:");
Serial.print(qmc.getZ());
Serial.println(" uT");
}
delay(100);
}

View file

@ -1,780 +0,0 @@
/**
* @file utilities.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-05-12
* @last-update 2025-07-07
*/
#pragma once
// Support board list , Macro definition below, select the board definition to be used
// 将要使用的板子型号注释打开,只能打开一个型号,如果不明白自己买的型号是什么,请找客服核对型号
/*********************************** Model definition start 型号定义起始 ***********************************/
// 1. --------------T3 V1.3 -------------------------------
// https://lilygo.cc/products/lora-v1-3
// #define T3_V1_3_SX1276
// #define T3_V1_3_SX1278
// 2. --------------T3 V1.6.1 -------------------------------
// https://lilygo.cc/products/lora3
// #define T3_V1_6_SX1276
// #define T3_V1_6_SX1278
// 3. --------------T3 V3.0 TCXO-------------------------------
// Product: https://lilygo.cc/products/t3-tcxo
// #define T3_V3_0_SX1276_TCXO
// 4. --------------T-BEAM ESP32-------------------------------
// Product: https://lilygo.cc/products/t-beam
// #define T_BEAM_SX1262
// #define T_BEAM_SX1276
// #define T_BEAM_SX1278
// #define T_BEAM_LR1121
// 5. --------------T-BEAM S3------------------------------
// Product: https://lilygo.cc/products/t-beam-supreme
// #define T_BEAM_S3_SUPREME_SX1262
// #define T_BEAM_S3_SUPREME_LR1121
// 6. --------------T3 S3 V1.0 or T3 S3 V1.3 -------------------
// Product: https://lilygo.cc/products/t3s3-v1-0 , same v1.3
// Product: https://lilygo.cc/products/t3-s3-v1-3
// #define T3_S3_V1_2_SX1262
// #define T3_S3_V1_2_SX1276
// #define T3_S3_V1_2_SX1278
// #define T3_S3_V1_2_SX1280
// #define T3_S3_V1_2_SX1280_PA
// #define T3_S3_V1_2_LR1121
// #define T3_S3_V1_2_LR1121_PA
// 7. --------------T-Motion -------------------------------------
// Product: https://lilygo.cc/products/t-motion-s76g-stm32-lora
// #define T_MOTION
// --------------T3 C6 -------------------------------------
// Product: https://lilygo.cc/products/t-lora-c6
// #define T3_C6
// --------------T-Beam BPF -------------------------------------
// Product: https://lilygo.cc/products/t-beam-bpf
// #define T_BEAM_S3_BPF
// --------------LoRa 2W -------------------------------------
// Product: ...
// #define T_BEAM_1W
// #define T3_V1_6_SX1276_TCXO // Production has stopped
/*********************************** Model definition end 型号定义结尾 ***********************************/
#define UNUSED_PIN (0)
#if defined(T_BEAM_SX1262) || defined(T_BEAM_SX1276) || defined(T_BEAM_SX1278) || defined(T_BEAM_LR1121)
#if defined(T_BEAM_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T_BEAM_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T_BEAM_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#elif defined(T_BEAM_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#endif // T_BEAM_SX1262
#define GPS_RX_PIN 34
#define GPS_TX_PIN 12
#define BUTTON_PIN 38
#define BUTTON_PIN_MASK GPIO_SEL_38
#define I2C_SDA 21
#define I2C_SCL 22
#define PMU_IRQ 35
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
// LR1121 Only
#define RADIO_DIO9_PIN 33
#define BOARD_LED 4
#define LED_ON LOW
#define LED_OFF HIGH
#define BUTTON_PIN 38
#define GPS_BAUD_RATE 9600
#define HAS_GPS
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
#define HAS_PMU
#define PMU_WIRE_PORT Wire
#define BOARD_VARIANT_NAME "T-Beam"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#elif defined(T3_V1_3_SX1276) || defined(T3_V1_3_SX1278)
#if defined(T3_V1_3_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_V1_3_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#endif // T3_V1_3_SX1276
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 14
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
#define ADC_PIN 35
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.3"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V1_6_SX1276) || defined(T3_V1_6_SX1278)
#if defined(T3_V1_6_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_V1_6_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#endif // T3_V1_6_SX1276
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define ADC_PIN 35
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.6"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V1_6_SX1276_TCXO)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN -1//33
/*
* In the T3 V1.6.1 TCXO version, Radio DIO1 is connected to Radios
* internal temperature-compensated crystal oscillator enable
* */
// TCXO pin must be set to HIGH before enabling Radio
#define RADIO_TCXO_ENABLE 33
#define RADIO_BUSY_PIN 32
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define ADC_PIN 35
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.6 TCXO"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V3_0) || defined(T3_V3_0_SX1276_TCXO)
#ifdef T3_V3_0_SX1276_TCXO
#ifndef USING_SX1276
#define USING_SX1276
#endif
#endif
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST 4
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_RST_PIN 23
// TCXO pin must be set to HIGH before enabling Radio
#define RADIO_TCXO_ENABLE 12 //only sx1276 tcxo version
#define RADIO_BUSY_PIN 32
#if defined(USING_SX1262)
#define RADIO_DIO1_PIN 26
#define RADIO_BUSY_PIN 32
#elif defined(USING_SX1276) || defined(USING_SX1278)
//!SX1276/78 module only
#define RADIO_DIO0_PIN 26
#define RADIO_DIO1_PIN 32
#elif defined(USING_LR1121)
#define RADIO_DIO9_PIN 26 //LR1121 DIO9
#define RADIO_BUSY_PIN 32 //LR1121 BUSY
#endif
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V3.0"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BUTTON_PIN 0
#define ADC_PIN 35
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262) || \
defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276) || \
defined(T3_S3_V1_2_SX1278) || defined(ARDUINO_LILYGO_T3S3_SX1278) || \
defined(T3_S3_V1_2_SX1280) || defined(ARDUINO_LILYGO_T3S3_SX1280) || \
defined(T3_S3_V1_2_SX1280_PA) || defined(ARDUINO_LILYGO_T3S3_SX1280PA) || \
defined(T3_S3_V1_2_LR1121) || defined(ARDUINO_LILYGO_T3S3_LR1121) || \
defined(T3_S3_V1_2_LR1121_PA) || defined(ARDUINO_LILYGO_T3S3_LR1121PA)
#if defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_S3_V1_2_SX1278) || defined(ARDUINO_LILYGO_T3S3_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#elif defined(T3_S3_V1_2_SX1280) || defined(ARDUINO_LILYGO_T3S3_SX1280)
#ifndef USING_SX1280
#define USING_SX1280
#endif
#elif defined(T3_S3_V1_2_SX1280_PA) || defined(ARDUINO_LILYGO_T3S3_SX1280PA)
#ifndef USING_SX1280PA
#define USING_SX1280PA
#endif
#elif defined(T3_S3_V1_2_LR1121) || defined(ARDUINO_LILYGO_T3S3_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#elif defined(T3_S3_V1_2_LR1121_PA) || defined(ARDUINO_LILYGO_T3S3_LR1121PA)
#ifndef USING_LR1121PA
#define USING_LR1121PA
#endif
#endif // T3_S3_V1_2_SX1262
#define I2C_SDA 18
#define I2C_SCL 17
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 3
#define RADIO_MOSI_PIN 6
#define RADIO_CS_PIN 7
#define SDCARD_MOSI 11
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 37
#define LED_ON HIGH
#define BUTTON_PIN 0
#define ADC_PIN 1
#define RADIO_RST_PIN 8
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#if defined(USING_SX1262)
#define RADIO_DIO1_PIN 33
#define RADIO_BUSY_PIN 34
#elif defined(USING_SX1276) || defined(USING_SX1278)
//!SX1276/78 module only
#define RADIO_BUSY_PIN 33 //DIO1
#define RADIO_DIO0_PIN 9
#define RADIO_DIO1_PIN 33
#define RADIO_DIO2_PIN 34
#define RADIO_DIO3_PIN 21
#define RADIO_DIO4_PIN 10
#define RADIO_DIO5_PIN 36
#elif defined(USING_SX1280)
#define RADIO_DIO1_PIN 9 //SX1280 DIO1 = IO9
#define RADIO_BUSY_PIN 36 //SX1280 BUSY = IO36
#elif defined(USING_SX1280PA)
#define RADIO_DIO1_PIN 9 //SX1280 DIO1 = IO9
#define RADIO_BUSY_PIN 36 //SX1280 BUSY = IO36
#define RADIO_RX_PIN 21
#define RADIO_TX_PIN 10
#elif defined(USING_LR1121)
#define RADIO_DIO9_PIN 36 //LR1121 DIO9 = IO36
#define RADIO_BUSY_PIN 34 //LR1121 BUSY = IO34
#define LILYGO_RADIO_2G4_TX_POWER_LIMIT 13 //LR1121 2.4G TX Power Limit
#elif defined(USING_LR1121PA)
#define RADIO_DIO9_PIN 36 //LR1121 DIO9 = IO36
#define RADIO_BUSY_PIN 34 //LR1121 BUSY = IO34
#define LILYGO_RADIO_2G4_TX_POWER_LIMIT 0 //LR1121 2.4G TX Power Limit
#define USING_LR1121
#endif
#define BUTTON_PIN 0
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3-S3-V1.X"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#elif defined(T_BEAM_S3_SUPREME_SX1262) || defined(T_BEAM_S3_SUPREME_LR1121)
#ifndef T_BEAM_S3_SUPREME
#define T_BEAM_S3_SUPREME
#endif
#if defined(T_BEAM_S3_SUPREME_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T_BEAM_S3_SUPREME_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#endif
#define I2C_SDA (17)
#define I2C_SCL (18)
#define I2C1_SDA (42)
#define I2C1_SCL (41)
#define PMU_IRQ (40)
#define GPS_RX_PIN (9)
#define GPS_TX_PIN (8)
#define GPS_EN_PIN (7)
#define GPS_PPS_PIN (6)
#define BUTTON_PIN (0)
#define BUTTON_PIN_MASK (GPIO_SEL_0)
#define BUTTON_COUNT (1)
#define BUTTON_ARRAY {BUTTON_PIN}
#define RADIO_SCLK_PIN (12)
#define RADIO_MISO_PIN (13)
#define RADIO_MOSI_PIN (11)
#define RADIO_CS_PIN (10)
#define RADIO_DIO0_PIN (-1)
#define RADIO_RST_PIN (5)
#define RADIO_DIO1_PIN (1)
#define RADIO_BUSY_PIN (4)
// LR1121 Version
#define RADIO_DIO9_PIN (1)
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
#define SPI_CS (47)
#define IMU_CS (34)
#define IMU_INT (33)
#define SDCARD_MOSI SPI_MOSI
#define SDCARD_MISO SPI_MISO
#define SDCARD_SCLK SPI_SCK
#define SDCARD_CS SPI_CS
#define RTC_INT (14)
#define GPS_BAUD_RATE (9600)
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define HAS_PMU
#define __HAS_SPI1__
#define HAS_SENSOR
#define PMU_WIRE_PORT Wire1
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "T-Beam S3"
#elif defined(T_MOTION_S76G)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#define RADIO_SCLK_PIN PB13
#define RADIO_MISO_PIN PB14
#define RADIO_MOSI_PIN PB15
#define RADIO_CS_PIN PB12
#define RADIO_RST_PIN PB10
#define RADIO_DIO0_PIN PB11
#define RADIO_DIO1_PIN PC13
#define RADIO_DIO2_PIN PB9
#define RADIO_DIO3_PIN PB4
#define RADIO_DIO4_PIN PB3
#define RADIO_DIO5_PIN PA15
#undef RADIO_BUSY_PIN
#undef RADIO_DIO1_PIN
#define RADIO_BUSY_PIN PC13 //DIO1
#define RADIO_DIO1_PIN PB11 //DIO0
#define RADIO_SWITCH_PIN PA1 //1:Rx, 0:Tx
#define GPS_EN_PIN PC6
#define GPS_RST_PIN PB2
#define GPS_RX_PIN PC11
#define GPS_TX_PIN PC10
#define GPS_ENABLE_PIN PC6
#define GPS_BAUD_RATE 115200
#define GPS_PPS_PIN PB5
#define UART_RX_PIN PA10
#define UART_TX_PIN PA9
#define I2C_SCL PB6
#define I2C_SDA PB7
#define BOARD_VARIANT_NAME "T-Motion S76G"
#define HAS_GPS
#elif defined(T3_C6)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#define RADIO_SCLK_PIN 6
#define RADIO_MISO_PIN 1
#define RADIO_MOSI_PIN 0
#define RADIO_CS_PIN 18
#define RADIO_DIO1_PIN 23
#define RADIO_BUSY_PIN 22
#define RADIO_RST_PIN 21
#define I2C_SDA 8
#define I2C_SCL 9
#define BOARD_LED 7
#define LED_ON HIGH
#define RADIO_RX_PIN 15
#define RADIO_TX_PIN 14
#define BOARD_VARIANT_NAME "T3-C6"
#define USING_DIO2_AS_RF_SWITCH
#elif defined(T_BEAM_S3_BPF)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#define I2C_SDA (8)
#define I2C_SCL (9)
#define PMU_IRQ (4)
#define GPS_RX_PIN (5)
#define GPS_TX_PIN (6)
#define GPS_PPS_PIN (7)
#define BUTTON_PIN (0)
#define BUTTON2_PIN (3) /*BUTTON 2 = GPIO3*/
#define BUTTON_PIN_MASK GPIO_SEL_0 /*BUTTON 1 = GPIO0*/
#define BUTTON_COUNT (2)
#define BUTTON_ARRAY {BUTTON_PIN, BUTTON2_PIN /*BUTTON 2 = GPIO3*/}
#define RADIO_SCLK_PIN (12)//(41)
#define RADIO_MISO_PIN (13)//(42)
#define RADIO_MOSI_PIN (11)//(2)
#define RADIO_CS_PIN (1)
#define RADIO_RST_PIN (18)
#define RADIO_DIO0_PIN (14)
#define RADIO_DIO1_PIN (21)
// #define RADIO_TCXO_ENABLE (17)
#define RADIO_LDO_EN (16)
#define RADIO_CTRL (39)
#define SPI_MOSI (11)
#define SPI_SCK (12)
#define SPI_MISO (13)
#define SPI_CS (10)
#define SDCARD_MOSI SPI_MOSI
#define SDCARD_MISO SPI_MISO
#define SDCARD_SCLK SPI_SCK
#define SDCARD_CS SPI_CS
#define GPS_BAUD_RATE 9600
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define HAS_PMU
#define SD_SHARE_SPI_BUS
#define PMU_WIRE_PORT Wire
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "T-Beam BPF"
#elif defined(T_BEAM_1W)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#define I2C_SDA (8)
#define I2C_SCL (9)
#define GPS_RX_PIN (5)
#define GPS_TX_PIN (6)
#define GPS_PPS_PIN (7)
#define GPS_EN_PIN (16)
#define BUTTON_PIN (0) /*BUTTON 1 = GPIO0*/
#define BUTTON2_PIN (17) /*BUTTON 2 = GPIO17*/
#define BUTTON_PIN_MASK GPIO_SEL_0
#define BUTTON_COUNT (2)
#define BUTTON_ARRAY {BUTTON_PIN,BUTTON2_PIN/*BUTTON 2 = GPIO3*/}
#define SPI_MOSI (11)
#define SPI_SCK (13)
#define SPI_MISO (12)
#define SPI_CS (10)
#define SDCARD_CS SPI_CS
#define RADIO_SCLK_PIN (SPI_SCK)
#define RADIO_MISO_PIN (SPI_MISO)
#define RADIO_MOSI_PIN (SPI_MOSI)
#define RADIO_CS_PIN (15)
#define RADIO_RST_PIN (3)
#define RADIO_LDO_EN (40)
#define RADIO_CTRL (21)
#define RADIO_DIO1_PIN (1)
#define RADIO_BUSY_PIN (38)
#define BOARD_LED 18
#define LED_ON HIGH
#define LED_OFF LOW
#define NTC_PIN (14)
#define FAN_CTRL (41)
#define ADC_PIN (4)
#define BAT_ADC_PULLUP_RES (300000.0)
#define BAT_ADC_PULLDOWN_RES (150000.0)
#define BAT_MAX_VOLTAGE (7.4)
#define BAT_VOL_COMPENSATION (0.25)
#define GPS_SLEEP_HOLD_ON_LOW
#define GPS_BAUD_RATE 9600
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define SD_SHARE_SPI_BUS // SD-CARD AND RADIO SHARE SPI BUS
#define __HAS_SPI1__
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "LoRa 2W"
#else
#error "When using it for the first time, please define the board model in <utilities.h> 首次使用时,请在<utilities.h> 文件最上方定义板卡模型"
#endif
#if defined(USING_SX1262)
#define RADIO_TYPE_STR "SX1262"
#elif defined(USING_SX1276)
#define RADIO_TYPE_STR "SX1276"
#elif defined(USING_SX1278)
#define RADIO_TYPE_STR "SX1278"
#elif defined(USING_LR1121)
#define RADIO_TYPE_STR "LR1121"
#elif defined(USING_SX1280)
#define RADIO_TYPE_STR "SX1280"
#elif defined(USING_SX1280PA)
#define RADIO_TYPE_STR "SX1280PA"
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,145 +0,0 @@
/**
* @file boards.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-04-25
* @last-update 2024-08-07
*/
#pragma once
#include "utilities.h"
#ifdef HAS_SDCARD
#include <SD.h>
#endif
#if defined(ARDUINO_ARCH_ESP32)
#include <FS.h>
#include <WiFi.h>
#endif
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#ifdef DISPLAY_MODEL
#include <U8g2lib.h>
#endif
#ifdef HAS_PMU
#include <XPowersLib.h>
#endif
#include <esp_mac.h>
#ifndef DISPLAY_ADDR
#define DISPLAY_ADDR 0x3C
#endif
// #define ENABLE_BLE //Enable ble function
enum {
POWERMANAGE_ONLINE = _BV(0),
DISPLAY_ONLINE = _BV(1),
RADIO_ONLINE = _BV(2),
GPS_ONLINE = _BV(3),
PSRAM_ONLINE = _BV(4),
SDCARD_ONLINE = _BV(5),
AXDL345_ONLINE = _BV(6),
BME280_ONLINE = _BV(7),
BMP280_ONLINE = _BV(8),
BME680_ONLINE = _BV(9),
QMC6310U_ONLINE = _BV(10),
QMC6310N_ONLINE = _BV(11),
QMI8658_ONLINE = _BV(12),
PCF8563_ONLINE = _BV(13),
OSC32768_ONLINE = _BV(14),
QMC6309_ONLINE = _BV(15),
};
typedef struct {
String chipModel;
float psramSize;
uint8_t chipModelRev;
uint8_t chipFreq;
uint8_t flashSize;
uint8_t flashSpeed;
} DevInfo_t;
void setupBoards(bool disable_u8g2 = false);
#ifdef HAS_SDCARD
bool beginSDCard();
#else
#define beginSDCard()
#endif
#ifdef DISPLAY_MODEL
bool beginDisplay();
#endif
void printResult(bool radio_online);
#ifdef BOARD_LED
void flashLed();
#else
#define flashLed()
#endif
void scanDevices(TwoWire *w);
bool beginGPS();
bool recoveryGPS();
void scanWiFi();
#ifdef HAS_PMU
extern XPowersLibInterface *PMU;
extern bool pmuInterrupt;
void loopPMU(void (*pressed_cb)(void));
bool beginPower();
void disablePeripherals();
#else
#define beginPower()
#define disablePeripherals()
#endif
#ifdef DISPLAY_MODEL
extern U8G2 *disp;
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
#endif
#if defined(ARDUINO_ARCH_ESP32)
#if defined(HAS_SDCARD)
extern SPIClass SDCardSPI;
#endif
#define SerialGPS Serial1
#elif defined(ARDUINO_ARCH_STM32)
extern HardwareSerial SerialGPS;
#endif
#ifdef NTC_PIN
float getTempForNTC();
#endif
#ifdef ENABLE_BLE
void setupBLE();
#else
#define setupBLE()
#endif
extern uint32_t deviceOnline;

View file

@ -1,149 +0,0 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 lewis he
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @file QMC6310_GetDataExample.ino
* @author Lewis He (lewishe@outlook.com)
* @date 2022-10-16
*
*/
#include <Wire.h>
#include <SPI.h>
#include <Arduino.h>
#include "SensorQMC6310.hpp"
#include "LoRaBoards.h"
SensorQMC6310 qmc;
void setup()
{
Serial.begin(115200);
while (!Serial);
setupBoards();
// For QMC6310U, the device address is 0x1C.
// For QMC6310N, the device address is 0x3C.
// The sensor device address is provided by the setupBoards I2C scanner.
extern uint8_t mag_address;
if (!qmc.begin(Wire, mag_address, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6310 - check your wiring!");
while (1) {
delay(1000);
}
}
/* Get Magnetometer chip id*/
Serial.print("Device ID:");
Serial.println(qmc.getChipID(), HEX);
/* Config Magnetometer */
qmc.configMagnetometer(
/*
* Run Mode
* MODE_SUSPEND
* MODE_NORMAL
* MODE_SINGLE
* MODE_CONTINUOUS
* * */
SensorQMC6310::MODE_CONTINUOUS,
/*
* Full Range
* RANGE_30G
* RANGE_12G
* RANGE_8G
* RANGE_2G
* * */
SensorQMC6310::RANGE_8G,
/*
* Output data rate
* DATARATE_10HZ
* DATARATE_50HZ
* DATARATE_100HZ
* DATARATE_200HZ
* * */
SensorQMC6310::DATARATE_200HZ,
/*
* Over sample Ratio1
* OSR_8
* OSR_4
* OSR_2
* OSR_1
* * * */
SensorQMC6310::OSR_1,
/*
* Down sample Ratio1
* DSR_8
* DSR_4
* DSR_2
* DSR_1
* * */
SensorQMC6310::DSR_1);
Serial.println("Read data now...");
}
void loop()
{
//Wiat data ready
if (qmc.isDataReady()) {
qmc.readData();
Serial.print("GYR: ");
Serial.print("X:");
Serial.print(qmc.getX());
Serial.print(" Y:");
Serial.print(qmc.getY());
Serial.print(" Z:");
Serial.print(qmc.getZ());
Serial.println(" uT");
Serial.print("RAW: ");
Serial.print("X:");
Serial.print(qmc.getRawX());
Serial.print(" Y:");
Serial.print(qmc.getRawY());
Serial.print(" Z:");
Serial.println(qmc.getRawZ());
/*
float x, y, z;
qmc.getMag(x, y, z);
Serial.print("X:");
Serial.print(x);
Serial.print(" Y:");
Serial.print(y);
Serial.print(" Z:");
Serial.println(x);
*/
}
delay(100);
}

View file

@ -1,780 +0,0 @@
/**
* @file utilities.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-05-12
* @last-update 2025-07-07
*/
#pragma once
// Support board list , Macro definition below, select the board definition to be used
// 将要使用的板子型号注释打开,只能打开一个型号,如果不明白自己买的型号是什么,请找客服核对型号
/*********************************** Model definition start 型号定义起始 ***********************************/
// 1. --------------T3 V1.3 -------------------------------
// https://lilygo.cc/products/lora-v1-3
// #define T3_V1_3_SX1276
// #define T3_V1_3_SX1278
// 2. --------------T3 V1.6.1 -------------------------------
// https://lilygo.cc/products/lora3
// #define T3_V1_6_SX1276
// #define T3_V1_6_SX1278
// 3. --------------T3 V3.0 TCXO-------------------------------
// Product: https://lilygo.cc/products/t3-tcxo
// #define T3_V3_0_SX1276_TCXO
// 4. --------------T-BEAM ESP32-------------------------------
// Product: https://lilygo.cc/products/t-beam
// #define T_BEAM_SX1262
// #define T_BEAM_SX1276
// #define T_BEAM_SX1278
// #define T_BEAM_LR1121
// 5. --------------T-BEAM S3------------------------------
// Product: https://lilygo.cc/products/t-beam-supreme
// #define T_BEAM_S3_SUPREME_SX1262
// #define T_BEAM_S3_SUPREME_LR1121
// 6. --------------T3 S3 V1.0 or T3 S3 V1.3 -------------------
// Product: https://lilygo.cc/products/t3s3-v1-0 , same v1.3
// Product: https://lilygo.cc/products/t3-s3-v1-3
// #define T3_S3_V1_2_SX1262
// #define T3_S3_V1_2_SX1276
// #define T3_S3_V1_2_SX1278
// #define T3_S3_V1_2_SX1280
// #define T3_S3_V1_2_SX1280_PA
// #define T3_S3_V1_2_LR1121
// #define T3_S3_V1_2_LR1121_PA
// 7. --------------T-Motion -------------------------------------
// Product: https://lilygo.cc/products/t-motion-s76g-stm32-lora
// #define T_MOTION
// --------------T3 C6 -------------------------------------
// Product: https://lilygo.cc/products/t-lora-c6
// #define T3_C6
// --------------T-Beam BPF -------------------------------------
// Product: https://lilygo.cc/products/t-beam-bpf
// #define T_BEAM_S3_BPF
// --------------LoRa 2W -------------------------------------
// Product: ...
// #define T_BEAM_1W
// #define T3_V1_6_SX1276_TCXO // Production has stopped
/*********************************** Model definition end 型号定义结尾 ***********************************/
#define UNUSED_PIN (0)
#if defined(T_BEAM_SX1262) || defined(T_BEAM_SX1276) || defined(T_BEAM_SX1278) || defined(T_BEAM_LR1121)
#if defined(T_BEAM_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T_BEAM_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T_BEAM_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#elif defined(T_BEAM_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#endif // T_BEAM_SX1262
#define GPS_RX_PIN 34
#define GPS_TX_PIN 12
#define BUTTON_PIN 38
#define BUTTON_PIN_MASK GPIO_SEL_38
#define I2C_SDA 21
#define I2C_SCL 22
#define PMU_IRQ 35
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
// LR1121 Only
#define RADIO_DIO9_PIN 33
#define BOARD_LED 4
#define LED_ON LOW
#define LED_OFF HIGH
#define BUTTON_PIN 38
#define GPS_BAUD_RATE 9600
#define HAS_GPS
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
#define HAS_PMU
#define PMU_WIRE_PORT Wire
#define BOARD_VARIANT_NAME "T-Beam"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#elif defined(T3_V1_3_SX1276) || defined(T3_V1_3_SX1278)
#if defined(T3_V1_3_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_V1_3_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#endif // T3_V1_3_SX1276
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 14
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
#define ADC_PIN 35
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.3"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V1_6_SX1276) || defined(T3_V1_6_SX1278)
#if defined(T3_V1_6_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_V1_6_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#endif // T3_V1_6_SX1276
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define ADC_PIN 35
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.6"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V1_6_SX1276_TCXO)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN -1//33
/*
* In the T3 V1.6.1 TCXO version, Radio DIO1 is connected to Radios
* internal temperature-compensated crystal oscillator enable
* */
// TCXO pin must be set to HIGH before enabling Radio
#define RADIO_TCXO_ENABLE 33
#define RADIO_BUSY_PIN 32
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define ADC_PIN 35
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.6 TCXO"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V3_0) || defined(T3_V3_0_SX1276_TCXO)
#ifdef T3_V3_0_SX1276_TCXO
#ifndef USING_SX1276
#define USING_SX1276
#endif
#endif
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST 4
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_RST_PIN 23
// TCXO pin must be set to HIGH before enabling Radio
#define RADIO_TCXO_ENABLE 12 //only sx1276 tcxo version
#define RADIO_BUSY_PIN 32
#if defined(USING_SX1262)
#define RADIO_DIO1_PIN 26
#define RADIO_BUSY_PIN 32
#elif defined(USING_SX1276) || defined(USING_SX1278)
//!SX1276/78 module only
#define RADIO_DIO0_PIN 26
#define RADIO_DIO1_PIN 32
#elif defined(USING_LR1121)
#define RADIO_DIO9_PIN 26 //LR1121 DIO9
#define RADIO_BUSY_PIN 32 //LR1121 BUSY
#endif
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V3.0"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BUTTON_PIN 0
#define ADC_PIN 35
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262) || \
defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276) || \
defined(T3_S3_V1_2_SX1278) || defined(ARDUINO_LILYGO_T3S3_SX1278) || \
defined(T3_S3_V1_2_SX1280) || defined(ARDUINO_LILYGO_T3S3_SX1280) || \
defined(T3_S3_V1_2_SX1280_PA) || defined(ARDUINO_LILYGO_T3S3_SX1280PA) || \
defined(T3_S3_V1_2_LR1121) || defined(ARDUINO_LILYGO_T3S3_LR1121) || \
defined(T3_S3_V1_2_LR1121_PA) || defined(ARDUINO_LILYGO_T3S3_LR1121PA)
#if defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_S3_V1_2_SX1278) || defined(ARDUINO_LILYGO_T3S3_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#elif defined(T3_S3_V1_2_SX1280) || defined(ARDUINO_LILYGO_T3S3_SX1280)
#ifndef USING_SX1280
#define USING_SX1280
#endif
#elif defined(T3_S3_V1_2_SX1280_PA) || defined(ARDUINO_LILYGO_T3S3_SX1280PA)
#ifndef USING_SX1280PA
#define USING_SX1280PA
#endif
#elif defined(T3_S3_V1_2_LR1121) || defined(ARDUINO_LILYGO_T3S3_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#elif defined(T3_S3_V1_2_LR1121_PA) || defined(ARDUINO_LILYGO_T3S3_LR1121PA)
#ifndef USING_LR1121PA
#define USING_LR1121PA
#endif
#endif // T3_S3_V1_2_SX1262
#define I2C_SDA 18
#define I2C_SCL 17
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 3
#define RADIO_MOSI_PIN 6
#define RADIO_CS_PIN 7
#define SDCARD_MOSI 11
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 37
#define LED_ON HIGH
#define BUTTON_PIN 0
#define ADC_PIN 1
#define RADIO_RST_PIN 8
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#if defined(USING_SX1262)
#define RADIO_DIO1_PIN 33
#define RADIO_BUSY_PIN 34
#elif defined(USING_SX1276) || defined(USING_SX1278)
//!SX1276/78 module only
#define RADIO_BUSY_PIN 33 //DIO1
#define RADIO_DIO0_PIN 9
#define RADIO_DIO1_PIN 33
#define RADIO_DIO2_PIN 34
#define RADIO_DIO3_PIN 21
#define RADIO_DIO4_PIN 10
#define RADIO_DIO5_PIN 36
#elif defined(USING_SX1280)
#define RADIO_DIO1_PIN 9 //SX1280 DIO1 = IO9
#define RADIO_BUSY_PIN 36 //SX1280 BUSY = IO36
#elif defined(USING_SX1280PA)
#define RADIO_DIO1_PIN 9 //SX1280 DIO1 = IO9
#define RADIO_BUSY_PIN 36 //SX1280 BUSY = IO36
#define RADIO_RX_PIN 21
#define RADIO_TX_PIN 10
#elif defined(USING_LR1121)
#define RADIO_DIO9_PIN 36 //LR1121 DIO9 = IO36
#define RADIO_BUSY_PIN 34 //LR1121 BUSY = IO34
#define LILYGO_RADIO_2G4_TX_POWER_LIMIT 13 //LR1121 2.4G TX Power Limit
#elif defined(USING_LR1121PA)
#define RADIO_DIO9_PIN 36 //LR1121 DIO9 = IO36
#define RADIO_BUSY_PIN 34 //LR1121 BUSY = IO34
#define LILYGO_RADIO_2G4_TX_POWER_LIMIT 0 //LR1121 2.4G TX Power Limit
#define USING_LR1121
#endif
#define BUTTON_PIN 0
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3-S3-V1.X"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#elif defined(T_BEAM_S3_SUPREME_SX1262) || defined(T_BEAM_S3_SUPREME_LR1121)
#ifndef T_BEAM_S3_SUPREME
#define T_BEAM_S3_SUPREME
#endif
#if defined(T_BEAM_S3_SUPREME_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T_BEAM_S3_SUPREME_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#endif
#define I2C_SDA (17)
#define I2C_SCL (18)
#define I2C1_SDA (42)
#define I2C1_SCL (41)
#define PMU_IRQ (40)
#define GPS_RX_PIN (9)
#define GPS_TX_PIN (8)
#define GPS_EN_PIN (7)
#define GPS_PPS_PIN (6)
#define BUTTON_PIN (0)
#define BUTTON_PIN_MASK (GPIO_SEL_0)
#define BUTTON_COUNT (1)
#define BUTTON_ARRAY {BUTTON_PIN}
#define RADIO_SCLK_PIN (12)
#define RADIO_MISO_PIN (13)
#define RADIO_MOSI_PIN (11)
#define RADIO_CS_PIN (10)
#define RADIO_DIO0_PIN (-1)
#define RADIO_RST_PIN (5)
#define RADIO_DIO1_PIN (1)
#define RADIO_BUSY_PIN (4)
// LR1121 Version
#define RADIO_DIO9_PIN (1)
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
#define SPI_CS (47)
#define IMU_CS (34)
#define IMU_INT (33)
#define SDCARD_MOSI SPI_MOSI
#define SDCARD_MISO SPI_MISO
#define SDCARD_SCLK SPI_SCK
#define SDCARD_CS SPI_CS
#define RTC_INT (14)
#define GPS_BAUD_RATE (9600)
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define HAS_PMU
#define __HAS_SPI1__
#define HAS_SENSOR
#define PMU_WIRE_PORT Wire1
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "T-Beam S3"
#elif defined(T_MOTION_S76G)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#define RADIO_SCLK_PIN PB13
#define RADIO_MISO_PIN PB14
#define RADIO_MOSI_PIN PB15
#define RADIO_CS_PIN PB12
#define RADIO_RST_PIN PB10
#define RADIO_DIO0_PIN PB11
#define RADIO_DIO1_PIN PC13
#define RADIO_DIO2_PIN PB9
#define RADIO_DIO3_PIN PB4
#define RADIO_DIO4_PIN PB3
#define RADIO_DIO5_PIN PA15
#undef RADIO_BUSY_PIN
#undef RADIO_DIO1_PIN
#define RADIO_BUSY_PIN PC13 //DIO1
#define RADIO_DIO1_PIN PB11 //DIO0
#define RADIO_SWITCH_PIN PA1 //1:Rx, 0:Tx
#define GPS_EN_PIN PC6
#define GPS_RST_PIN PB2
#define GPS_RX_PIN PC11
#define GPS_TX_PIN PC10
#define GPS_ENABLE_PIN PC6
#define GPS_BAUD_RATE 115200
#define GPS_PPS_PIN PB5
#define UART_RX_PIN PA10
#define UART_TX_PIN PA9
#define I2C_SCL PB6
#define I2C_SDA PB7
#define BOARD_VARIANT_NAME "T-Motion S76G"
#define HAS_GPS
#elif defined(T3_C6)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#define RADIO_SCLK_PIN 6
#define RADIO_MISO_PIN 1
#define RADIO_MOSI_PIN 0
#define RADIO_CS_PIN 18
#define RADIO_DIO1_PIN 23
#define RADIO_BUSY_PIN 22
#define RADIO_RST_PIN 21
#define I2C_SDA 8
#define I2C_SCL 9
#define BOARD_LED 7
#define LED_ON HIGH
#define RADIO_RX_PIN 15
#define RADIO_TX_PIN 14
#define BOARD_VARIANT_NAME "T3-C6"
#define USING_DIO2_AS_RF_SWITCH
#elif defined(T_BEAM_S3_BPF)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#define I2C_SDA (8)
#define I2C_SCL (9)
#define PMU_IRQ (4)
#define GPS_RX_PIN (5)
#define GPS_TX_PIN (6)
#define GPS_PPS_PIN (7)
#define BUTTON_PIN (0)
#define BUTTON2_PIN (3) /*BUTTON 2 = GPIO3*/
#define BUTTON_PIN_MASK GPIO_SEL_0 /*BUTTON 1 = GPIO0*/
#define BUTTON_COUNT (2)
#define BUTTON_ARRAY {BUTTON_PIN, BUTTON2_PIN /*BUTTON 2 = GPIO3*/}
#define RADIO_SCLK_PIN (12)//(41)
#define RADIO_MISO_PIN (13)//(42)
#define RADIO_MOSI_PIN (11)//(2)
#define RADIO_CS_PIN (1)
#define RADIO_RST_PIN (18)
#define RADIO_DIO0_PIN (14)
#define RADIO_DIO1_PIN (21)
// #define RADIO_TCXO_ENABLE (17)
#define RADIO_LDO_EN (16)
#define RADIO_CTRL (39)
#define SPI_MOSI (11)
#define SPI_SCK (12)
#define SPI_MISO (13)
#define SPI_CS (10)
#define SDCARD_MOSI SPI_MOSI
#define SDCARD_MISO SPI_MISO
#define SDCARD_SCLK SPI_SCK
#define SDCARD_CS SPI_CS
#define GPS_BAUD_RATE 9600
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define HAS_PMU
#define SD_SHARE_SPI_BUS
#define PMU_WIRE_PORT Wire
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "T-Beam BPF"
#elif defined(T_BEAM_1W)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#define I2C_SDA (8)
#define I2C_SCL (9)
#define GPS_RX_PIN (5)
#define GPS_TX_PIN (6)
#define GPS_PPS_PIN (7)
#define GPS_EN_PIN (16)
#define BUTTON_PIN (0) /*BUTTON 1 = GPIO0*/
#define BUTTON2_PIN (17) /*BUTTON 2 = GPIO17*/
#define BUTTON_PIN_MASK GPIO_SEL_0
#define BUTTON_COUNT (2)
#define BUTTON_ARRAY {BUTTON_PIN,BUTTON2_PIN/*BUTTON 2 = GPIO3*/}
#define SPI_MOSI (11)
#define SPI_SCK (13)
#define SPI_MISO (12)
#define SPI_CS (10)
#define SDCARD_CS SPI_CS
#define RADIO_SCLK_PIN (SPI_SCK)
#define RADIO_MISO_PIN (SPI_MISO)
#define RADIO_MOSI_PIN (SPI_MOSI)
#define RADIO_CS_PIN (15)
#define RADIO_RST_PIN (3)
#define RADIO_LDO_EN (40)
#define RADIO_CTRL (21)
#define RADIO_DIO1_PIN (1)
#define RADIO_BUSY_PIN (38)
#define BOARD_LED 18
#define LED_ON HIGH
#define LED_OFF LOW
#define NTC_PIN (14)
#define FAN_CTRL (41)
#define ADC_PIN (4)
#define BAT_ADC_PULLUP_RES (300000.0)
#define BAT_ADC_PULLDOWN_RES (150000.0)
#define BAT_MAX_VOLTAGE (7.4)
#define BAT_VOL_COMPENSATION (0.25)
#define GPS_SLEEP_HOLD_ON_LOW
#define GPS_BAUD_RATE 9600
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define SD_SHARE_SPI_BUS // SD-CARD AND RADIO SHARE SPI BUS
#define __HAS_SPI1__
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "LoRa 2W"
#else
#error "When using it for the first time, please define the board model in <utilities.h> 首次使用时,请在<utilities.h> 文件最上方定义板卡模型"
#endif
#if defined(USING_SX1262)
#define RADIO_TYPE_STR "SX1262"
#elif defined(USING_SX1276)
#define RADIO_TYPE_STR "SX1276"
#elif defined(USING_SX1278)
#define RADIO_TYPE_STR "SX1278"
#elif defined(USING_LR1121)
#define RADIO_TYPE_STR "LR1121"
#elif defined(USING_SX1280)
#define RADIO_TYPE_STR "SX1280"
#elif defined(USING_SX1280PA)
#define RADIO_TYPE_STR "SX1280PA"
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,145 +0,0 @@
/**
* @file boards.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-04-25
* @last-update 2024-08-07
*/
#pragma once
#include "utilities.h"
#ifdef HAS_SDCARD
#include <SD.h>
#endif
#if defined(ARDUINO_ARCH_ESP32)
#include <FS.h>
#include <WiFi.h>
#endif
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#ifdef DISPLAY_MODEL
#include <U8g2lib.h>
#endif
#ifdef HAS_PMU
#include <XPowersLib.h>
#endif
#include <esp_mac.h>
#ifndef DISPLAY_ADDR
#define DISPLAY_ADDR 0x3C
#endif
// #define ENABLE_BLE //Enable ble function
enum {
POWERMANAGE_ONLINE = _BV(0),
DISPLAY_ONLINE = _BV(1),
RADIO_ONLINE = _BV(2),
GPS_ONLINE = _BV(3),
PSRAM_ONLINE = _BV(4),
SDCARD_ONLINE = _BV(5),
AXDL345_ONLINE = _BV(6),
BME280_ONLINE = _BV(7),
BMP280_ONLINE = _BV(8),
BME680_ONLINE = _BV(9),
QMC6310U_ONLINE = _BV(10),
QMC6310N_ONLINE = _BV(11),
QMI8658_ONLINE = _BV(12),
PCF8563_ONLINE = _BV(13),
OSC32768_ONLINE = _BV(14),
QMC6309_ONLINE = _BV(15),
};
typedef struct {
String chipModel;
float psramSize;
uint8_t chipModelRev;
uint8_t chipFreq;
uint8_t flashSize;
uint8_t flashSpeed;
} DevInfo_t;
void setupBoards(bool disable_u8g2 = false);
#ifdef HAS_SDCARD
bool beginSDCard();
#else
#define beginSDCard()
#endif
#ifdef DISPLAY_MODEL
bool beginDisplay();
#endif
void printResult(bool radio_online);
#ifdef BOARD_LED
void flashLed();
#else
#define flashLed()
#endif
void scanDevices(TwoWire *w);
bool beginGPS();
bool recoveryGPS();
void scanWiFi();
#ifdef HAS_PMU
extern XPowersLibInterface *PMU;
extern bool pmuInterrupt;
void loopPMU(void (*pressed_cb)(void));
bool beginPower();
void disablePeripherals();
#else
#define beginPower()
#define disablePeripherals()
#endif
#ifdef DISPLAY_MODEL
extern U8G2 *disp;
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
#endif
#if defined(ARDUINO_ARCH_ESP32)
#if defined(HAS_SDCARD)
extern SPIClass SDCardSPI;
#endif
#define SerialGPS Serial1
#elif defined(ARDUINO_ARCH_STM32)
extern HardwareSerial SerialGPS;
#endif
#ifdef NTC_PIN
float getTempForNTC();
#endif
#ifdef ENABLE_BLE
void setupBLE();
#else
#define setupBLE()
#endif
extern uint32_t deviceOnline;

View file

@ -1,126 +0,0 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 lewis he
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @file QMC6310_GetPolarExample.ino
* @author Lewis He (lewishe@outlook.com)
* @date 2022-10-16
*
*/
#include <Wire.h>
#include <SPI.h>
#include <Arduino.h>
#include "SensorQMC6310.hpp"
#include "LoRaBoards.h"
SensorQMC6310 qmc;
void setup()
{
Serial.begin(115200);
while (!Serial);
setupBoards();
// For QMC6310U, the device address is 0x1C.
// For QMC6310N, the device address is 0x3C.
// The sensor device address is provided by the setupBoards I2C scanner.
extern uint8_t mag_address;
if (!qmc.begin(Wire, mag_address, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6310 - check your wiring!");
while (1) {
delay(1000);
}
}
/* Get Magnetometer chip id*/
Serial.print("Device ID:");
Serial.println(qmc.getChipID(), HEX);
/* Config Magnetometer */
qmc.configMagnetometer(
/*
* Run Mode
* MODE_SUSPEND
* MODE_NORMAL
* MODE_SINGLE
* MODE_CONTINUOUS
* * */
SensorQMC6310::MODE_NORMAL,
/*
* Full Range
* RANGE_30G
* RANGE_12G
* RANGE_8G
* RANGE_2G
* * */
SensorQMC6310::RANGE_8G,
/*
* Output data rate
* DATARATE_10HZ
* DATARATE_50HZ
* DATARATE_100HZ
* DATARATE_200HZ
* * */
SensorQMC6310::DATARATE_200HZ,
/*
* Over sample Ratio1
* OSR_8
* OSR_4
* OSR_2
* OSR_1
* * * */
SensorQMC6310::OSR_8,
/*
* Down sample Ratio1
* DSR_8
* DSR_4
* DSR_2
* DSR_1
* * */
SensorQMC6310::DSR_1);
qmc.dumpCtrlRegister();
// Declination is the difference between magnetic-north and true-north ("heading") and depends on location
qmc.setDeclination(-2.77); // Found with: https://www.magnetic-declination.com/CHINA/SHENZHEN/475119.html
Serial.println("Read data now...");
}
void loop()
{
Polar data;
// Wait for data ready
if (qmc.readPolar(data)) {
Serial.print(" polar:"); Serial.print(data.polar); Serial.print("°");
Serial.print(" Gauss:"); Serial.print(data.Gauss);
Serial.print(" uT:"); Serial.println(data.uT);
}
delay(100);
}

View file

@ -1,780 +0,0 @@
/**
* @file utilities.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-05-12
* @last-update 2025-07-07
*/
#pragma once
// Support board list , Macro definition below, select the board definition to be used
// 将要使用的板子型号注释打开,只能打开一个型号,如果不明白自己买的型号是什么,请找客服核对型号
/*********************************** Model definition start 型号定义起始 ***********************************/
// 1. --------------T3 V1.3 -------------------------------
// https://lilygo.cc/products/lora-v1-3
// #define T3_V1_3_SX1276
// #define T3_V1_3_SX1278
// 2. --------------T3 V1.6.1 -------------------------------
// https://lilygo.cc/products/lora3
// #define T3_V1_6_SX1276
// #define T3_V1_6_SX1278
// 3. --------------T3 V3.0 TCXO-------------------------------
// Product: https://lilygo.cc/products/t3-tcxo
// #define T3_V3_0_SX1276_TCXO
// 4. --------------T-BEAM ESP32-------------------------------
// Product: https://lilygo.cc/products/t-beam
// #define T_BEAM_SX1262
// #define T_BEAM_SX1276
// #define T_BEAM_SX1278
// #define T_BEAM_LR1121
// 5. --------------T-BEAM S3------------------------------
// Product: https://lilygo.cc/products/t-beam-supreme
// #define T_BEAM_S3_SUPREME_SX1262
// #define T_BEAM_S3_SUPREME_LR1121
// 6. --------------T3 S3 V1.0 or T3 S3 V1.3 -------------------
// Product: https://lilygo.cc/products/t3s3-v1-0 , same v1.3
// Product: https://lilygo.cc/products/t3-s3-v1-3
// #define T3_S3_V1_2_SX1262
// #define T3_S3_V1_2_SX1276
// #define T3_S3_V1_2_SX1278
// #define T3_S3_V1_2_SX1280
// #define T3_S3_V1_2_SX1280_PA
// #define T3_S3_V1_2_LR1121
// #define T3_S3_V1_2_LR1121_PA
// 7. --------------T-Motion -------------------------------------
// Product: https://lilygo.cc/products/t-motion-s76g-stm32-lora
// #define T_MOTION
// --------------T3 C6 -------------------------------------
// Product: https://lilygo.cc/products/t-lora-c6
// #define T3_C6
// --------------T-Beam BPF -------------------------------------
// Product: https://lilygo.cc/products/t-beam-bpf
// #define T_BEAM_S3_BPF
// --------------LoRa 2W -------------------------------------
// Product: ...
// #define T_BEAM_1W
// #define T3_V1_6_SX1276_TCXO // Production has stopped
/*********************************** Model definition end 型号定义结尾 ***********************************/
#define UNUSED_PIN (0)
#if defined(T_BEAM_SX1262) || defined(T_BEAM_SX1276) || defined(T_BEAM_SX1278) || defined(T_BEAM_LR1121)
#if defined(T_BEAM_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T_BEAM_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T_BEAM_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#elif defined(T_BEAM_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#endif // T_BEAM_SX1262
#define GPS_RX_PIN 34
#define GPS_TX_PIN 12
#define BUTTON_PIN 38
#define BUTTON_PIN_MASK GPIO_SEL_38
#define I2C_SDA 21
#define I2C_SCL 22
#define PMU_IRQ 35
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
// LR1121 Only
#define RADIO_DIO9_PIN 33
#define BOARD_LED 4
#define LED_ON LOW
#define LED_OFF HIGH
#define BUTTON_PIN 38
#define GPS_BAUD_RATE 9600
#define HAS_GPS
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
#define HAS_PMU
#define PMU_WIRE_PORT Wire
#define BOARD_VARIANT_NAME "T-Beam"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#elif defined(T3_V1_3_SX1276) || defined(T3_V1_3_SX1278)
#if defined(T3_V1_3_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_V1_3_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#endif // T3_V1_3_SX1276
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 14
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
#define ADC_PIN 35
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.3"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V1_6_SX1276) || defined(T3_V1_6_SX1278)
#if defined(T3_V1_6_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_V1_6_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#endif // T3_V1_6_SX1276
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN 33
// SX1276/78
#define RADIO_DIO2_PIN 32
// SX1262
#define RADIO_BUSY_PIN 32
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define ADC_PIN 35
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.6"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V1_6_SX1276_TCXO)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_DIO0_PIN 26
#define RADIO_RST_PIN 23
#define RADIO_DIO1_PIN -1//33
/*
* In the T3 V1.6.1 TCXO version, Radio DIO1 is connected to Radios
* internal temperature-compensated crystal oscillator enable
* */
// TCXO pin must be set to HIGH before enabling Radio
#define RADIO_TCXO_ENABLE 33
#define RADIO_BUSY_PIN 32
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define ADC_PIN 35
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V1.6 TCXO"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_V3_0) || defined(T3_V3_0_SX1276_TCXO)
#ifdef T3_V3_0_SX1276_TCXO
#ifndef USING_SX1276
#define USING_SX1276
#endif
#endif
#define I2C_SDA 21
#define I2C_SCL 22
#define OLED_RST 4
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
#define RADIO_MOSI_PIN 27
#define RADIO_CS_PIN 18
#define RADIO_RST_PIN 23
// TCXO pin must be set to HIGH before enabling Radio
#define RADIO_TCXO_ENABLE 12 //only sx1276 tcxo version
#define RADIO_BUSY_PIN 32
#if defined(USING_SX1262)
#define RADIO_DIO1_PIN 26
#define RADIO_BUSY_PIN 32
#elif defined(USING_SX1276) || defined(USING_SX1278)
//!SX1276/78 module only
#define RADIO_DIO0_PIN 26
#define RADIO_DIO1_PIN 32
#elif defined(USING_LR1121)
#define RADIO_DIO9_PIN 26 //LR1121 DIO9
#define RADIO_BUSY_PIN 32 //LR1121 BUSY
#endif
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 25
#define LED_ON HIGH
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3 V3.0"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#define BUTTON_PIN 0
#define ADC_PIN 35
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#elif defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262) || \
defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276) || \
defined(T3_S3_V1_2_SX1278) || defined(ARDUINO_LILYGO_T3S3_SX1278) || \
defined(T3_S3_V1_2_SX1280) || defined(ARDUINO_LILYGO_T3S3_SX1280) || \
defined(T3_S3_V1_2_SX1280_PA) || defined(ARDUINO_LILYGO_T3S3_SX1280PA) || \
defined(T3_S3_V1_2_LR1121) || defined(ARDUINO_LILYGO_T3S3_LR1121) || \
defined(T3_S3_V1_2_LR1121_PA) || defined(ARDUINO_LILYGO_T3S3_LR1121PA)
#if defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#elif defined(T3_S3_V1_2_SX1278) || defined(ARDUINO_LILYGO_T3S3_SX1278)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#elif defined(T3_S3_V1_2_SX1280) || defined(ARDUINO_LILYGO_T3S3_SX1280)
#ifndef USING_SX1280
#define USING_SX1280
#endif
#elif defined(T3_S3_V1_2_SX1280_PA) || defined(ARDUINO_LILYGO_T3S3_SX1280PA)
#ifndef USING_SX1280PA
#define USING_SX1280PA
#endif
#elif defined(T3_S3_V1_2_LR1121) || defined(ARDUINO_LILYGO_T3S3_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#elif defined(T3_S3_V1_2_LR1121_PA) || defined(ARDUINO_LILYGO_T3S3_LR1121PA)
#ifndef USING_LR1121PA
#define USING_LR1121PA
#endif
#endif // T3_S3_V1_2_SX1262
#define I2C_SDA 18
#define I2C_SCL 17
#define OLED_RST UNUSED_PIN
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 3
#define RADIO_MOSI_PIN 6
#define RADIO_CS_PIN 7
#define SDCARD_MOSI 11
#define SDCARD_MISO 2
#define SDCARD_SCLK 14
#define SDCARD_CS 13
#define BOARD_LED 37
#define LED_ON HIGH
#define BUTTON_PIN 0
#define ADC_PIN 1
#define RADIO_RST_PIN 8
#define BAT_ADC_PULLUP_RES (100000.0)
#define BAT_ADC_PULLDOWN_RES (100000.0)
#define BAT_MAX_VOLTAGE (4.2)
#define BAT_VOL_COMPENSATION (0.0)
#if defined(USING_SX1262)
#define RADIO_DIO1_PIN 33
#define RADIO_BUSY_PIN 34
#elif defined(USING_SX1276) || defined(USING_SX1278)
//!SX1276/78 module only
#define RADIO_BUSY_PIN 33 //DIO1
#define RADIO_DIO0_PIN 9
#define RADIO_DIO1_PIN 33
#define RADIO_DIO2_PIN 34
#define RADIO_DIO3_PIN 21
#define RADIO_DIO4_PIN 10
#define RADIO_DIO5_PIN 36
#elif defined(USING_SX1280)
#define RADIO_DIO1_PIN 9 //SX1280 DIO1 = IO9
#define RADIO_BUSY_PIN 36 //SX1280 BUSY = IO36
#elif defined(USING_SX1280PA)
#define RADIO_DIO1_PIN 9 //SX1280 DIO1 = IO9
#define RADIO_BUSY_PIN 36 //SX1280 BUSY = IO36
#define RADIO_RX_PIN 21
#define RADIO_TX_PIN 10
#elif defined(USING_LR1121)
#define RADIO_DIO9_PIN 36 //LR1121 DIO9 = IO36
#define RADIO_BUSY_PIN 34 //LR1121 BUSY = IO34
#define LILYGO_RADIO_2G4_TX_POWER_LIMIT 13 //LR1121 2.4G TX Power Limit
#elif defined(USING_LR1121PA)
#define RADIO_DIO9_PIN 36 //LR1121 DIO9 = IO36
#define RADIO_BUSY_PIN 34 //LR1121 BUSY = IO34
#define LILYGO_RADIO_2G4_TX_POWER_LIMIT 0 //LR1121 2.4G TX Power Limit
#define USING_LR1121
#endif
#define BUTTON_PIN 0
#define HAS_SDCARD
#define HAS_DISPLAY
#define BOARD_VARIANT_NAME "T3-S3-V1.X"
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
#elif defined(T_BEAM_S3_SUPREME_SX1262) || defined(T_BEAM_S3_SUPREME_LR1121)
#ifndef T_BEAM_S3_SUPREME
#define T_BEAM_S3_SUPREME
#endif
#if defined(T_BEAM_S3_SUPREME_SX1262)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#elif defined(T_BEAM_S3_SUPREME_LR1121)
#ifndef USING_LR1121
#define USING_LR1121
#endif
#endif
#define I2C_SDA (17)
#define I2C_SCL (18)
#define I2C1_SDA (42)
#define I2C1_SCL (41)
#define PMU_IRQ (40)
#define GPS_RX_PIN (9)
#define GPS_TX_PIN (8)
#define GPS_EN_PIN (7)
#define GPS_PPS_PIN (6)
#define BUTTON_PIN (0)
#define BUTTON_PIN_MASK (GPIO_SEL_0)
#define BUTTON_COUNT (1)
#define BUTTON_ARRAY {BUTTON_PIN}
#define RADIO_SCLK_PIN (12)
#define RADIO_MISO_PIN (13)
#define RADIO_MOSI_PIN (11)
#define RADIO_CS_PIN (10)
#define RADIO_DIO0_PIN (-1)
#define RADIO_RST_PIN (5)
#define RADIO_DIO1_PIN (1)
#define RADIO_BUSY_PIN (4)
// LR1121 Version
#define RADIO_DIO9_PIN (1)
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
#define SPI_CS (47)
#define IMU_CS (34)
#define IMU_INT (33)
#define SDCARD_MOSI SPI_MOSI
#define SDCARD_MISO SPI_MISO
#define SDCARD_SCLK SPI_SCK
#define SDCARD_CS SPI_CS
#define RTC_INT (14)
#define GPS_BAUD_RATE (9600)
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define HAS_PMU
#define __HAS_SPI1__
#define HAS_SENSOR
#define PMU_WIRE_PORT Wire1
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "T-Beam S3"
#elif defined(T_MOTION_S76G)
#ifndef USING_SX1276
#define USING_SX1276
#endif
#define RADIO_SCLK_PIN PB13
#define RADIO_MISO_PIN PB14
#define RADIO_MOSI_PIN PB15
#define RADIO_CS_PIN PB12
#define RADIO_RST_PIN PB10
#define RADIO_DIO0_PIN PB11
#define RADIO_DIO1_PIN PC13
#define RADIO_DIO2_PIN PB9
#define RADIO_DIO3_PIN PB4
#define RADIO_DIO4_PIN PB3
#define RADIO_DIO5_PIN PA15
#undef RADIO_BUSY_PIN
#undef RADIO_DIO1_PIN
#define RADIO_BUSY_PIN PC13 //DIO1
#define RADIO_DIO1_PIN PB11 //DIO0
#define RADIO_SWITCH_PIN PA1 //1:Rx, 0:Tx
#define GPS_EN_PIN PC6
#define GPS_RST_PIN PB2
#define GPS_RX_PIN PC11
#define GPS_TX_PIN PC10
#define GPS_ENABLE_PIN PC6
#define GPS_BAUD_RATE 115200
#define GPS_PPS_PIN PB5
#define UART_RX_PIN PA10
#define UART_TX_PIN PA9
#define I2C_SCL PB6
#define I2C_SDA PB7
#define BOARD_VARIANT_NAME "T-Motion S76G"
#define HAS_GPS
#elif defined(T3_C6)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#define RADIO_SCLK_PIN 6
#define RADIO_MISO_PIN 1
#define RADIO_MOSI_PIN 0
#define RADIO_CS_PIN 18
#define RADIO_DIO1_PIN 23
#define RADIO_BUSY_PIN 22
#define RADIO_RST_PIN 21
#define I2C_SDA 8
#define I2C_SCL 9
#define BOARD_LED 7
#define LED_ON HIGH
#define RADIO_RX_PIN 15
#define RADIO_TX_PIN 14
#define BOARD_VARIANT_NAME "T3-C6"
#define USING_DIO2_AS_RF_SWITCH
#elif defined(T_BEAM_S3_BPF)
#ifndef USING_SX1278
#define USING_SX1278
#endif
#define I2C_SDA (8)
#define I2C_SCL (9)
#define PMU_IRQ (4)
#define GPS_RX_PIN (5)
#define GPS_TX_PIN (6)
#define GPS_PPS_PIN (7)
#define BUTTON_PIN (0)
#define BUTTON2_PIN (3) /*BUTTON 2 = GPIO3*/
#define BUTTON_PIN_MASK GPIO_SEL_0 /*BUTTON 1 = GPIO0*/
#define BUTTON_COUNT (2)
#define BUTTON_ARRAY {BUTTON_PIN, BUTTON2_PIN /*BUTTON 2 = GPIO3*/}
#define RADIO_SCLK_PIN (12)//(41)
#define RADIO_MISO_PIN (13)//(42)
#define RADIO_MOSI_PIN (11)//(2)
#define RADIO_CS_PIN (1)
#define RADIO_RST_PIN (18)
#define RADIO_DIO0_PIN (14)
#define RADIO_DIO1_PIN (21)
// #define RADIO_TCXO_ENABLE (17)
#define RADIO_LDO_EN (16)
#define RADIO_CTRL (39)
#define SPI_MOSI (11)
#define SPI_SCK (12)
#define SPI_MISO (13)
#define SPI_CS (10)
#define SDCARD_MOSI SPI_MOSI
#define SDCARD_MISO SPI_MISO
#define SDCARD_SCLK SPI_SCK
#define SDCARD_CS SPI_CS
#define GPS_BAUD_RATE 9600
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define HAS_PMU
#define SD_SHARE_SPI_BUS
#define PMU_WIRE_PORT Wire
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "T-Beam BPF"
#elif defined(T_BEAM_1W)
#ifndef USING_SX1262
#define USING_SX1262
#endif
#define I2C_SDA (8)
#define I2C_SCL (9)
#define GPS_RX_PIN (5)
#define GPS_TX_PIN (6)
#define GPS_PPS_PIN (7)
#define GPS_EN_PIN (16)
#define BUTTON_PIN (0) /*BUTTON 1 = GPIO0*/
#define BUTTON2_PIN (17) /*BUTTON 2 = GPIO17*/
#define BUTTON_PIN_MASK GPIO_SEL_0
#define BUTTON_COUNT (2)
#define BUTTON_ARRAY {BUTTON_PIN,BUTTON2_PIN/*BUTTON 2 = GPIO3*/}
#define SPI_MOSI (11)
#define SPI_SCK (13)
#define SPI_MISO (12)
#define SPI_CS (10)
#define SDCARD_CS SPI_CS
#define RADIO_SCLK_PIN (SPI_SCK)
#define RADIO_MISO_PIN (SPI_MISO)
#define RADIO_MOSI_PIN (SPI_MOSI)
#define RADIO_CS_PIN (15)
#define RADIO_RST_PIN (3)
#define RADIO_LDO_EN (40)
#define RADIO_CTRL (21)
#define RADIO_DIO1_PIN (1)
#define RADIO_BUSY_PIN (38)
#define BOARD_LED 18
#define LED_ON HIGH
#define LED_OFF LOW
#define NTC_PIN (14)
#define FAN_CTRL (41)
#define ADC_PIN (4)
#define BAT_ADC_PULLUP_RES (300000.0)
#define BAT_ADC_PULLDOWN_RES (150000.0)
#define BAT_MAX_VOLTAGE (7.4)
#define BAT_VOL_COMPENSATION (0.25)
#define GPS_SLEEP_HOLD_ON_LOW
#define GPS_BAUD_RATE 9600
#define HAS_SDCARD
#define HAS_GPS
#define HAS_DISPLAY
#define SD_SHARE_SPI_BUS // SD-CARD AND RADIO SHARE SPI BUS
#define __HAS_SPI1__
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
#define BOARD_VARIANT_NAME "LoRa 2W"
#else
#error "When using it for the first time, please define the board model in <utilities.h> 首次使用时,请在<utilities.h> 文件最上方定义板卡模型"
#endif
#if defined(USING_SX1262)
#define RADIO_TYPE_STR "SX1262"
#elif defined(USING_SX1276)
#define RADIO_TYPE_STR "SX1276"
#elif defined(USING_SX1278)
#define RADIO_TYPE_STR "SX1278"
#elif defined(USING_LR1121)
#define RADIO_TYPE_STR "LR1121"
#elif defined(USING_SX1280)
#define RADIO_TYPE_STR "SX1280"
#elif defined(USING_SX1280PA)
#define RADIO_TYPE_STR "SX1280PA"
#endif

View file

@ -0,0 +1,216 @@
/**
*
* @license MIT License
*
* Copyright (c) 2026 lewis he
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @file QMC63xx_GetDataExample.ino
* @author Lewis He (lewishe@outlook.com)
* @date 2026-04-08
*
*/
#include <SensorQMC6310.hpp>
#include <SensorQMC6309.hpp>
#include <SensorWireHelper.h>
#include "LoRaBoards.h"
MagnetometerBase *magnetometer;
void setup()
{
Serial.begin(115200);
while (!Serial);
setupBoards();
// The desired output data rate in Hz. Allowed values are 1.0, 10.0, 50.0, 100.0 and 200.0HZ.
float data_rate_hz = 200.0f;
// op_mode: Allowed values are SUSPEND, NORMAL, SINGLE_MEASUREMENT, CONTINUOUS_MEASUREMENT
OperationMode op_mode = OperationMode::CONTINUOUS_MEASUREMENT;
// full_scale: Allowed values are FS_8G, FS_16G ,FS_32G
MagFullScaleRange full_scale = MagFullScaleRange::FS_8G;
// over_sample_ratio: Allowed values are OSR_1, OSR_2, OSR_4, OSR_8
MagOverSampleRatio over_sample_ratio = MagOverSampleRatio::OSR_1;
// down_sample_ratio: QMC6309 does not support downsampling rate settings; this parameter is ignored.
MagDownSampleRatio down_sample_ratio = MagDownSampleRatio::DSR_1;
SensorWireHelper::dumpDevices(Wire);
if (magnetometer == nullptr) {
magnetometer = new SensorQMC6310();
if (!static_cast<SensorQMC6310*>(magnetometer)->begin(Wire, QMC6310U_SLAVE_ADDRESS, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6310U - check your wiring!");
delete magnetometer;
magnetometer = nullptr;
} else {
Serial.println("QMC6310U found!");
// The desired output data rate in Hz. Allowed values are 10.0, 50.0, 100.0 and 200.0HZ.
data_rate_hz = 200.0f;
// op_mode: Allowed values are SUSPEND, NORMAL, SINGLE_MEASUREMENT, CONTINUOUS_MEASUREMENT
op_mode = OperationMode::CONTINUOUS_MEASUREMENT;
// full_scale: Allowed values are FS_2G, FS_8G, FS_12G ,FS_30G
full_scale = MagFullScaleRange::FS_8G;
// over_sample_ratio: Allowed values are OSR_1, OSR_2, OSR_4, OSR_8
over_sample_ratio = MagOverSampleRatio::OSR_1;
// down_sample_ratio: Allowed values are DSR_1, DSR_2, DSR_4, DSR_8
down_sample_ratio = MagDownSampleRatio::DSR_1;
}
}
if (magnetometer == nullptr) {
magnetometer = new SensorQMC6310();
if (!static_cast<SensorQMC6310*>(magnetometer)->begin(Wire, QMC6310N_SLAVE_ADDRESS, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6310 - check your wiring!");
delete magnetometer;
magnetometer = nullptr;
} else {
Serial.println("QMC6310N found!");
// The desired output data rate in Hz. Allowed values are 10.0, 50.0, 100.0 and 200.0HZ.
data_rate_hz = 200.0f;
// op_mode: Allowed values are SUSPEND, NORMAL, SINGLE_MEASUREMENT, CONTINUOUS_MEASUREMENT
op_mode = OperationMode::CONTINUOUS_MEASUREMENT;
// full_scale: Allowed values are FS_2G, FS_8G, FS_12G ,FS_30G
full_scale = MagFullScaleRange::FS_8G;
// over_sample_ratio: Allowed values are OSR_1, OSR_2, OSR_4, OSR_8
over_sample_ratio = MagOverSampleRatio::OSR_1;
// down_sample_ratio: Allowed values are DSR_1, DSR_2, DSR_4, DSR_8
down_sample_ratio = MagDownSampleRatio::DSR_1;
}
}
if (magnetometer == nullptr) {
magnetometer = new SensorQMC6309();
if (!static_cast<SensorQMC6309*>(magnetometer)->begin(Wire, QMC6309_SLAVE_ADDRESS, I2C_SDA, I2C_SCL)) {
Serial.println("Failed to find QMC6309 - check your wiring!");
delete magnetometer;
magnetometer = nullptr;
} else {
Serial.println("QMC6309 found!");
// The desired output data rate in Hz. Allowed values are 1.0, 10.0, 50.0, 100.0 and 200.0HZ.
data_rate_hz = 200.0f;
// op_mode: Allowed values are SUSPEND, NORMAL, SINGLE_MEASUREMENT, CONTINUOUS_MEASUREMENT
op_mode = OperationMode::CONTINUOUS_MEASUREMENT;
// full_scale: Allowed values are FS_8G, FS_16G ,FS_32G
full_scale = MagFullScaleRange::FS_8G;
// over_sample_ratio: Allowed values are OSR_1, OSR_2, OSR_4, OSR_8
over_sample_ratio = MagOverSampleRatio::OSR_1;
// down_sample_ratio: QMC6309 does not support downsampling rate settings; this parameter is ignored.
down_sample_ratio = MagDownSampleRatio::DSR_1;
}
}
while (magnetometer == nullptr) {
Serial.println("No magnetometer found!");
delay(1000);
}
/* Config Magnetometer */
if (magnetometer->configMagnetometer(
op_mode,
full_scale,
data_rate_hz,
over_sample_ratio,
down_sample_ratio)) {
Serial.println("Magnetometer configured successfully.");
} else {
Serial.println("Magnetometer configuration failed.");
while (1);
}
SensorInfo info = magnetometer->getSensorInfo();
Serial.print("Manufacturer: "); Serial.println(info.manufacturer);
Serial.print("Model: "); Serial.println(info.model);
Serial.print("I2C Address: 0x"); Serial.println(info.i2c_address, HEX);
Serial.print("Version: "); Serial.println(info.version);
Serial.print("UID: 0x"); Serial.println(info.uid);
Serial.print("Type: "); Serial.println(SensorUtils::typeToString(info.type));
SensorConfig cfg = magnetometer->getConfig();
Serial.print("DataRate: "); Serial.println(cfg.sample_rate);
Serial.print("FullScaleRange: "); Serial.println(cfg.range);
Serial.print("Mode: "); Serial.println((uint8_t)cfg.mode);
Serial.println();
//Find the magnetic declination : https://www.magnetic-declination.com/
float declination_deg = MagnetometerUtils::dmsToDecimalDegrees(-3, 20); // -3.3333
magnetometer->setDeclination(declination_deg);
Serial.print(" Magnetic Declination: ");
Serial.print(declination_deg, 2);
Serial.println("°");
Serial.print(" Sensitivity: ");
Serial.print(magnetometer->getSensitivity(), 6);
Serial.println(" Gauss/LSB");
delay(3000);
Serial.println("Read data now...");
}
void loop()
{
MagnetometerData data;
if (magnetometer->readData(data)) {
// Gauss to μT
float x = MagnetometerUtils::gaussToMicroTesla(data.magnetic_field.x);
float y = MagnetometerUtils::gaussToMicroTesla(data.magnetic_field.y);
float z = MagnetometerUtils::gaussToMicroTesla(data.magnetic_field.z);
Serial.print("Mag:");
Serial.print(" X:"); Serial.print(x);
Serial.print(" Y:"); Serial.print(y);
Serial.print(" Z:"); Serial.print(z);
Serial.print(" μT");
Serial.print(" Metadata:");
Serial.print(" X:");
Serial.print(data.raw.x);
Serial.print(" Y:");
Serial.print(data.raw.y);
Serial.print(" Z:");
Serial.print(data.raw.z);
Serial.print(" Heading (rad): ");
Serial.print(data.heading, 6);
Serial.print(" rad");
Serial.print(" Heading (deg): ");
Serial.print(data.heading_degrees, 2);
Serial.print("°");
float strength = MagnetometerUtils::calculateMagneticStrength(data);
Serial.print(" Magnetic Strength: ");
Serial.print(strength, 2);
Serial.println(" μT");
if (data.overflow) {
Serial.println("\tWarning: Data Overflow occurred!");
}
}
delay(10);
}