Initial commit: Simple Sensor firmware for Heltec T114 with BME280
Some checks failed
Build and deploy Docs site to GitHub Pages / github-pages (push) Has been cancelled
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (Heltec_v3_repeater) (push) Has been cancelled
PR Build Check / build (Heltec_v3_room_server) (push) Has been cancelled
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Has been cancelled
PR Build Check / build (PicoW_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (RAK_4631_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_room_server) (push) Has been cancelled
PR Build Check / build (wio-e5-mini_repeater) (push) Has been cancelled

- MeshCore-based Simple Sensor firmware
- Heltec T114 without display
- BME280 sensor support (temp/humidity/pressure)
- Radio: 868.856018 MHz, SF7, BW62.5 kHz, CR4/7
- 2-byte path hash
- PlatformIO project
This commit is contained in:
UA1ZBE
2026-06-01 16:19:09 +03:00
commit 42f55e12ae
725 changed files with 98374 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#include <Arduino.h>
#include <Wire.h>
#include "T1000eBoard.h"
void T1000eBoard::begin() {
NRF52BoardDCDC::begin();
btn_prev_state = HIGH;
#ifdef BUTTON_PIN
pinMode(BATTERY_PIN, INPUT);
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
#endif
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
#endif
Wire.begin();
delay(10); // give sx1262 some time to power up
}

View File

@@ -0,0 +1,93 @@
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
#include <helpers/NRF52Board.h>
class T1000eBoard : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
T1000eBoard() : NRF52Board("T1000E_OTA") {}
void begin();
uint16_t getBattMilliVolts() override {
#ifdef BATTERY_PIN
#ifdef PIN_3V3_EN
digitalWrite(PIN_3V3_EN, HIGH);
#endif
analogReference(AR_INTERNAL_3_0);
analogReadResolution(12);
delay(10);
float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096;
#ifdef PIN_3V3_EN
digitalWrite(PIN_3V3_EN, LOW);
#endif
analogReference(AR_DEFAULT); // put back to default
analogReadResolution(10);
return volts * 1000;
#else
return 0;
#endif
}
const char* getManufacturerName() const override {
return "Seeed Tracker T1000-E";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
#ifdef HAS_GPS
digitalWrite(GPS_VRTC_EN, LOW);
digitalWrite(GPS_RESET, LOW);
digitalWrite(GPS_SLEEP_INT, LOW);
digitalWrite(GPS_RTC_INT, LOW);
digitalWrite(GPS_EN, LOW);
#endif
#ifdef BUZZER_EN
digitalWrite(BUZZER_EN, LOW);
#endif
#ifdef PIN_3V3_EN
digitalWrite(PIN_3V3_EN, LOW);
#endif
#ifdef PIN_3V3_ACC_EN
digitalWrite(PIN_3V3_ACC_EN, LOW);
#endif
#ifdef SENSOR_EN
digitalWrite(SENSOR_EN, LOW);
#endif
// set led on and wait for button release before poweroff
#ifdef LED_PIN
digitalWrite(LED_PIN, HIGH);
#endif
#ifdef BUTTON_PIN
while(digitalRead(BUTTON_PIN));
#endif
#ifdef LED_PIN
digitalWrite(LED_PIN, LOW);
#endif
#ifdef BUTTON_PIN
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
#endif
sd_power_system_off();
}
};

View File

@@ -0,0 +1,119 @@
[t1000-e]
extends = nrf52_base
board = tracker-t1000-e
board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52_base.build_flags}
-I src/helpers/nrf52
-I lib/nrf52/s140_nrf52_7.3.0_API/include
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
-I variants/t1000-e
-I src/helpers/ui
-D T1000_E
-D PIN_USER_BTN=6
-D USER_BTN_PRESSED=HIGH
-D PIN_STATUS_LED=24
-D RADIO_CLASS=CustomLR1110
-D WRAPPER_CLASS=CustomLR1110Wrapper
-D LORA_TX_POWER=22
-D RF_SWITCH_TABLE
-D RX_BOOSTED_GAIN=true
-D P_LORA_BUSY=7 ; P0.7
-D P_LORA_SCLK=11 ; P0.11
-D P_LORA_NSS=12 ; P0.12
-D P_LORA_DIO_1=33 ; P1.1
-D P_LORA_MISO=40 ; P1.8
-D P_LORA_MOSI=41 ; P1.9
-D P_LORA_RESET=42 ; P1.10
-D LR11X0_DIO_AS_RF_SWITCH=true
-D LR11X0_DIO3_TCXO_VOLTAGE=1.6
-D ENV_INCLUDE_GPS=1
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/nrf52/T1000eBoard.cpp>
+<../variants/t1000-e>
debug_tool = jlink
upload_protocol = nrfutil
[env:t1000e_repeater]
extends = t1000-e
build_flags = ${t1000-e.build_flags}
-I examples/companion_radio/ui-orig
-D ADVERT_NAME='"t1000-e Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${t1000-e.build_src_filter}
+<../examples/simple_repeater>
lib_deps = ${t1000-e.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
[env:t1000e_room_server]
extends = t1000-e
build_flags = ${t1000-e.build_flags}
-I examples/companion_radio/ui-orig
-D ADVERT_NAME='"t1000-e Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
-D RF_SWITCH_TABLE
build_src_filter = ${t1000-e.build_src_filter}
+<../examples/simple_room_server>
lib_deps = ${t1000-e.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
[env:t1000e_companion_radio_usb]
extends = t1000-e
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
build_flags = ${t1000-e.build_flags}
-I examples/companion_radio/ui-orig
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=NullDisplayDriver
-D PIN_BUZZER=25
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
build_src_filter = ${t1000-e.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps = ${t1000-e.lib_deps}
densaugeo/base64 @ ~1.4.0
stevemarple/MicroNMEA @ ^2.0.6
end2endzone/NonBlockingRTTTL@^1.3.0
[env:t1000e_companion_radio_ble]
extends = t1000-e
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
build_flags = ${t1000-e.build_flags}
-I examples/companion_radio/ui-orig
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D BLE_TX_POWER=0
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=NullDisplayDriver
-D PIN_BUZZER=25
-D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
-D ADVERT_NAME='"@@MAC"'
build_src_filter = ${t1000-e.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps = ${t1000-e.lib_deps}
densaugeo/base64 @ ~1.4.0
stevemarple/MicroNMEA @ ^2.0.6
end2endzone/NonBlockingRTTTL@^1.3.0

View File

@@ -0,0 +1,103 @@
#include "t1000e_sensors.h"
#include <Arduino.h>
#define HEATER_NTC_BX 4250 // thermistor coefficient B
#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor
#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin
#define NTC_REF_VCC 3300 // mV, max voltage of 3V3 sensor rail
#define LIGHT_REF_VCC 2400 //
static unsigned int ntc_res2[136] = {
113347, 107565, 102116, 96978, 92132, 87559, 83242, 79166, 75316, 71677, 68237, 64991, 61919, 59011,
56258, 53650, 51178, 48835, 46613, 44506, 42506, 40600, 38791, 37073, 35442, 33892, 32420, 31020,
29689, 28423, 27219, 26076, 24988, 23951, 22963, 22021, 21123, 20267, 19450, 18670, 17926, 17214,
16534, 15886, 15266, 14674, 14108, 13566, 13049, 12554, 12081, 11628, 11195, 10780, 10382, 10000,
9634, 9284, 8947, 8624, 8315, 8018, 7734, 7461, 7199, 6948, 6707, 6475, 6253, 6039,
5834, 5636, 5445, 5262, 5086, 4917, 4754, 4597, 4446, 4301, 4161, 4026, 3896, 3771,
3651, 3535, 3423, 3315, 3211, 3111, 3014, 2922, 2834, 2748, 2666, 2586, 2509, 2435,
2364, 2294, 2228, 2163, 2100, 2040, 1981, 1925, 1870, 1817, 1766, 1716, 1669, 1622,
1578, 1535, 1493, 1452, 1413, 1375, 1338, 1303, 1268, 1234, 1202, 1170, 1139, 1110,
1081, 1053, 1026, 999, 974, 949, 925, 902, 880, 858,
};
static int8_t ntc_temp2[136] = {
-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
};
static float get_heater_temperature(unsigned int vcc_volt, unsigned int ntc_volt) {
int i = 0;
float Vout = 0, Rt = 0, temp = 0;
Vout = ntc_volt;
Rt = (HEATER_NTC_RP * vcc_volt) / Vout - HEATER_NTC_RP;
for (i = 0; i < 136; i++) {
if (Rt >= ntc_res2[i]) {
break;
}
}
temp = ntc_temp2[i - 1] + 1 * (ntc_res2[i - 1] - Rt) / (float)(ntc_res2[i - 1] - ntc_res2[i]);
temp = (temp * 100 + 5) / 100;
return temp;
}
static int get_light_lv(unsigned int light_volt) {
float Vout = 0, Vin = 0, Rt = 0, temp = 0;
unsigned int light_level = 0;
// Seeed's firmware maps the photocell reading to a 0-100 % range rather than lux.
if (light_volt <= 80) {
light_level = 0;
return light_level;
} else if (light_volt >= 2480) {
light_level = 100;
return light_level;
}
Vout = light_volt;
light_level = 100 * (Vout - 80) / LIGHT_REF_VCC;
return light_level;
}
float t1000e_get_temperature(void) {
unsigned int ntc_v, vcc_v;
digitalWrite(PIN_3V3_EN, HIGH);
digitalWrite(SENSOR_EN, HIGH);
analogReference(AR_INTERNAL_3_0);
analogReadResolution(12);
delay(10);
unsigned int rail_v = (1000.0 * (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096;
vcc_v = (rail_v > NTC_REF_VCC) ? NTC_REF_VCC : rail_v;
ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096;
digitalWrite(PIN_3V3_EN, LOW);
digitalWrite(SENSOR_EN, LOW);
return get_heater_temperature(vcc_v, ntc_v);
}
uint32_t t1000e_get_light(void) {
int lux = 0;
unsigned int lux_v = 0;
digitalWrite(PIN_3V3_EN, HIGH);
digitalWrite(SENSOR_EN, HIGH);
analogReference(AR_INTERNAL_3_0);
analogReadResolution(12);
delay(10);
lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096;
lux = get_light_lv(lux_v);
digitalWrite(SENSOR_EN, LOW);
digitalWrite(PIN_3V3_EN, LOW);
return lux;
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <stdint.h>
// Light and temperature sensors are on ADC ports
// functions adapted from Seeed examples to get values
// see : https://github.com/Seeed-Studio/Seeed-Tracker-T1000-E-for-LoRaWAN-dev-board
extern uint32_t t1000e_get_light();
extern float t1000e_get_temperature();

201
variants/t1000-e/target.cpp Normal file
View File

@@ -0,0 +1,201 @@
#include <Arduino.h>
#include "t1000e_sensors.h"
#include "target.h"
#include <helpers/sensors/MicroNMEALocationProvider.h>
T1000eBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock rtc_clock;
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
T1000SensorManager sensors = T1000SensorManager(nmea);
#ifdef DISPLAY_CLASS
NullDisplayDriver display;
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
#ifdef RF_SWITCH_TABLE
static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
RADIOLIB_LR11X0_DIO5,
RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7,
RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, {LOW, LOW, LOW, LOW }},
{ LR11x0::MODE_RX, {HIGH, LOW, LOW, HIGH }},
{ LR11x0::MODE_TX, {HIGH, HIGH, LOW, HIGH }},
{ LR11x0::MODE_TX_HP, {LOW, HIGH, LOW, HIGH }},
{ LR11x0::MODE_TX_HF, {LOW, LOW, LOW, LOW }},
{ LR11x0::MODE_GNSS, {LOW, LOW, HIGH, LOW }},
{ LR11x0::MODE_WIFI, {LOW, LOW, LOW, LOW }},
END_OF_MODE_TABLE,
};
#endif
bool radio_init() {
//rtc_clock.begin(Wire);
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(2);
radio.explicitHeader();
#ifdef RF_SWITCH_TABLE
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
#endif
#ifdef RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
#endif
return true; // success
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setFrequency(freq);
radio.setSpreadingFactor(sf);
radio.setBandwidth(bw);
radio.setCodingRate(cr);
}
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
void T1000SensorManager::start_gps() {
gps_active = true;
//_nmea->begin();
// this init sequence should be better
// comes from seeed examples and deals with all gps pins
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, HIGH);
delay(10);
pinMode(GPS_VRTC_EN, OUTPUT);
digitalWrite(GPS_VRTC_EN, HIGH);
delay(10);
pinMode(GPS_RESET, OUTPUT);
digitalWrite(GPS_RESET, HIGH);
delay(10);
digitalWrite(GPS_RESET, LOW);
pinMode(GPS_SLEEP_INT, OUTPUT);
digitalWrite(GPS_SLEEP_INT, HIGH);
pinMode(GPS_RTC_INT, OUTPUT);
digitalWrite(GPS_RTC_INT, LOW);
pinMode(GPS_RESETB, INPUT_PULLUP);
}
void T1000SensorManager::sleep_gps() {
gps_active = false;
digitalWrite(GPS_VRTC_EN, HIGH);
digitalWrite(GPS_EN, LOW);
digitalWrite(GPS_RESET, HIGH);
digitalWrite(GPS_SLEEP_INT, HIGH);
digitalWrite(GPS_RTC_INT, LOW);
pinMode(GPS_RESETB, OUTPUT);
digitalWrite(GPS_RESETB, LOW);
//_nmea->stop();
}
void T1000SensorManager::stop_gps() {
gps_active = false;
digitalWrite(GPS_VRTC_EN, LOW);
digitalWrite(GPS_EN, LOW);
digitalWrite(GPS_RESET, HIGH);
digitalWrite(GPS_SLEEP_INT, HIGH);
digitalWrite(GPS_RTC_INT, LOW);
pinMode(GPS_RESETB, OUTPUT);
digitalWrite(GPS_RESETB, LOW);
//_nmea->stop();
}
bool T1000SensorManager::begin() {
// init GPS
Serial1.begin(115200);
return true;
}
bool T1000SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
}
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
// Firmware reports light as a 0-100 % scale, but expose it via Luminosity so app labels it "Luminosity".
telemetry.addLuminosity(TELEM_CHANNEL_SELF, t1000e_get_light());
telemetry.addTemperature(TELEM_CHANNEL_SELF, t1000e_get_temperature());
}
return true;
}
void T1000SensorManager::loop() {
static long next_gps_update = 0;
_nmea->loop();
if (millis() > next_gps_update) {
if (gps_active && _nmea->isValid()) {
node_lat = ((double)_nmea->getLatitude())/1000000.;
node_lon = ((double)_nmea->getLongitude())/1000000.;
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
}
next_gps_update = millis() + 1000;
}
}
int T1000SensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch)
const char* T1000SensorManager::getSettingName(int i) const {
return i == 0 ? "gps" : NULL;
}
const char* T1000SensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
}
return NULL;
}
bool T1000SensorManager::setSettingValue(const char* name, const char* value) {
if (strcmp(name, "gps") == 0) {
if (strcmp(value, "0") == 0) {
sleep_gps(); // sleep for faster fix !
} else {
start_gps();
}
return true;
}
return false; // not supported
}

47
variants/t1000-e/target.h Normal file
View File

@@ -0,0 +1,47 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include "T1000eBoard.h"
#include <helpers/radiolib/CustomLR1110Wrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#ifdef DISPLAY_CLASS
#include "NullDisplayDriver.h"
#endif
class T1000SensorManager: public SensorManager {
bool gps_active = false;
LocationProvider * _nmea;
void start_gps();
void sleep_gps();
void stop_gps();
public:
T1000SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
bool begin() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
void loop() override;
int getNumSettings() const override;
const char* getSettingName(int i) const override;
const char* getSettingValue(int i) const override;
bool setSettingValue(const char* name, const char* value) override;
LocationProvider* getLocationProvider() { return _nmea; }
};
#ifdef DISPLAY_CLASS
extern NullDisplayDriver display;
#endif
extern T1000eBoard board;
extern WRAPPER_CLASS radio_driver;
extern VolatileRTCClock rtc_clock;
extern T1000SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View File

@@ -0,0 +1,98 @@
/*
* variant.cpp
* Copyright (C) 2023 Seeed K.K.
* MIT License
*/
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] =
{
0, // P0.00
1, // P0.01
2, // P0.02, AIN0 BATTERY_PIN
3, // P0.03
4, // P0.04, SENSOR_EN
5, // P0.05, EXT_PWR_DETEC
6, // P0.06, PIN_BUTTON1
7, // P0.07, LORA_BUSY
8, // P0.08, GPS_VRTC_EN
9, // P0.09
10, // P0.10
11, // P0.11, PIN_SPI_SCK
12, // P0.12, PIN_SPI_NSS
13, // P0.13, PIN_SERIAL1_TX
14, // P0.14, PIN_SERIAL1_RX
15, // P0.15, GPS_RTC_INT
16, // P0.16, PIN_SERIAL2_TX
17, // P0.17, PIN_SERIAL2_RX
18, // P0.18
19, // P0.19
20, // P0.20
21, // P0.21
22, // P0.22
23, // P0.23
24, // P0.24, LED_GREEN
25, // P0.25, BUZZER_PIN
26, // P0.26, PIN_WIRE_SDA
27, // P0.27, PIN_WIRE_SCL
28, // P0.28
29, // P0.29, AIN5, LUX_SENSOR
30, // P0.30
31, // P0.31, AIN7, TEMP_SENSOR
32, // P1.00
33, // P1.01, LORA_DIO_1
34, // P1.02
35, // P1.03, EXT_CHRG_DETECT
36, // P1.04
37, // P1.05, LR1110_EN
38, // P1.06, 3V3_EN PWR TO SENSORS
39, // P1.07, PIN_3V3_ACC_EN
40, // P1.08, PIN_SPI_MISO
41, // P1.09, PIN_SPI_MOSI
42, // P1.10, LORA_RESET
43, // P1.11, GPS_EN
44, // P1.12, GPS_SLEEP_INT
45, // P1.13, FLASH_ENABLE
46, // P1.14, GPS_RESETB
47, // P1.15, PIN_GPS_RESET
255, // NRFX_SPIM_PIN_NOT_USED
};
void initVariant()
{
// All pins output HIGH by default.
// https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69
pinMode(BATTERY_PIN, INPUT);
pinMode(TEMP_SENSOR, INPUT);
pinMode(LUX_SENSOR, INPUT);
pinMode(EXT_CHRG_DETECT, INPUT);
pinMode(EXT_PWR_DETECT, INPUT);
pinMode(GPS_RESETB, INPUT);
pinMode(PIN_BUTTON1, INPUT);
pinMode(PIN_3V3_EN, OUTPUT);
pinMode(PIN_3V3_ACC_EN, OUTPUT);
pinMode(BUZZER_EN, OUTPUT);
pinMode(SENSOR_EN, OUTPUT);
pinMode(GPS_EN, OUTPUT);
pinMode(GPS_RESET, OUTPUT);
pinMode(GPS_VRTC_EN, OUTPUT);
pinMode(GPS_SLEEP_INT, OUTPUT);
pinMode(GPS_RTC_INT, OUTPUT);
pinMode(LED_PIN, OUTPUT);
digitalWrite(PIN_3V3_EN, LOW);
digitalWrite(PIN_3V3_ACC_EN, LOW);
digitalWrite(BUZZER_EN, LOW);
digitalWrite(SENSOR_EN, LOW);
digitalWrite(GPS_EN, LOW);
digitalWrite(GPS_RESET, LOW);
digitalWrite(GPS_VRTC_EN, LOW);
digitalWrite(GPS_SLEEP_INT, HIGH);
digitalWrite(GPS_RTC_INT, LOW);
digitalWrite(LED_PIN, LOW);
}

136
variants/t1000-e/variant.h Normal file
View File

@@ -0,0 +1,136 @@
/*
* variant.h
* Copyright (C) 2023 Seeed K.K.
* MIT License
*/
#pragma once
#include "WVariant.h"
////////////////////////////////////////////////////////////////////////////////
// Low frequency clock source
#define USE_LFXO // 32.768 kHz crystal oscillator
#define VARIANT_MCK (64000000ul)
// #define USE_LFRC // 32.768 kHz RC oscillator
////////////////////////////////////////////////////////////////////////////////
// Power
#define NRF_APM // detect usb power
#define PIN_3V3_EN (38) // P1.6 Power to Sensors
#define BATTERY_PIN (2) // P0.2/AIN0
#define BATTERY_IMMUTABLE
#define ADC_MULTIPLIER (2.0F)
#define EXT_CHRG_DETECT (35) // P1.3
#define EXT_PWR_DETECT (5) // P0.5
#define ADC_RESOLUTION (14)
#define BATTERY_SENSE_RES (12)
#define AREF_VOLTAGE (3.0)
////////////////////////////////////////////////////////////////////////////////
// Number of pins
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (6)
#define NUM_ANALOG_OUTPUTS (0)
////////////////////////////////////////////////////////////////////////////////
// UART pin definition
#define PIN_SERIAL1_RX (14) // P0.14
#define PIN_SERIAL1_TX (13) // P0.13
#define PIN_SERIAL2_RX (17) // P0.17
#define PIN_SERIAL2_TX (16) // P0.16
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
#define HAS_WIRE (1)
#define WIRE_INTERFACES_COUNT (1)
#define PIN_WIRE_SDA (26) // P0.26
#define PIN_WIRE_SCL (27) // P0.27
#define I2C_NO_RESCAN
#define HAS_QMA6100P
#define QMA_6100P_INT_PIN (34) // P1.2
////////////////////////////////////////////////////////////////////////////////
// SPI pin definition
#define SPI_INTERFACES_COUNT (1)
#define PIN_SPI_MISO (40) // P1.8
#define PIN_SPI_MOSI (41) // P1.9
#define PIN_SPI_SCK (11) // P0.11
#define PIN_SPI_NSS (12) // P0.12
////////////////////////////////////////////////////////////////////////////////
// Builtin LEDs
#define LED_BUILTIN (-1)
#define LED_BLUE (-1) // No blue led
#define LED_GREEN (24) // P0.24
#define LED_PIN LED_GREEN
#define LED_STATE_ON HIGH
////////////////////////////////////////////////////////////////////////////////
// Builtin buttons
#define PIN_BUTTON1 (6) // P0.6
#define BUTTON_PIN PIN_BUTTON1
////////////////////////////////////////////////////////////////////////////////
// LR1110
#define LORA_DIO_1 (33) // P1.1
#define LORA_NSS (PIN_SPI_NSS) // P0.12
#define LORA_RESET (42) // P1.10
#define LORA_BUSY (7) // P0.7
#define LORA_SCLK (PIN_SPI_SCK) // P0.11
#define LORA_MISO (PIN_SPI_MISO) // P1.8
#define LORA_MOSI (PIN_SPI_MOSI) // P1.9
#define LR11X0_DIO_AS_RF_SWITCH true
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
////////////////////////////////////////////////////////////////////////////////
// GPS
#define HAS_GPS 1
#define GPS_RX_PIN PIN_SERIAL1_RX
#define GPS_TX_PIN PIN_SERIAL1_TX
#define GPS_EN (43) // P1.11
#define GPS_RESET (47) // P1.15
#define GPS_VRTC_EN (8) // P0.8
#define GPS_SLEEP_INT (44) // P1.12
#define GPS_RTC_INT (15) // P0.15
#define GPS_RESETB (46) // P1.14
////////////////////////////////////////////////////////////////////////////////
// Temp+Lux Sensor
#define SENSOR_EN (4) // P0.4
#define TEMP_SENSOR (31) // P0.31/AIN7
#define LUX_SENSOR (29) // P0.29/AIN5
////////////////////////////////////////////////////////////////////////////////
// Accelerometer (I2C addr : ??? )
#define PIN_3V3_ACC_EN (39) // P1.7
////////////////////////////////////////////////////////////////////////////////
// Buzzer
#define BUZZER_EN (37) // P1.5
#define BUZZER_PIN (25) // P0.25