Skip to content

Commit

Permalink
first test
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed May 2, 2024
1 parent 4f7bbc4 commit 4a7eae2
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/LoRa_APRS_Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BluetoothSerial SerialBT;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
#endif

String versionDate = "2024.04.26";
String versionDate = "2024.05.02";

uint8_t myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();
Expand Down
41 changes: 30 additions & 11 deletions src/pins_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
#undef OLED_RST


#if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS) && !defined(ESP32_C3_DIY_LoRa_GPS) || !defined(TTGO_T_DECK_GPS)
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
#endif

#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
#define GPS_RX 12
#define GPS_TX 34
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
#endif


#if defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA32_V2_1_GPS)
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
#define GPS_RX 12
#define GPS_TX 34
//#define BUTTON_PIN -1
#define BATTERY_PIN 35 //LoRa32 Battery PIN 100k/100k
#define LORA_SCK 5
#define LORA_MISO 19
Expand All @@ -31,7 +31,11 @@
#define LORA_IRQ 26 // IRQ --> DIO0
#endif


#ifdef ESP32_DIY_1W_LoRa_GPS
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
#define GPS_RX 17
#define GPS_TX 16
#define BUTTON_PIN 15
Expand All @@ -47,6 +51,7 @@
#define RADIO_TXEN 25
#endif


#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
#define RADIO_SCLK_PIN 5
#define RADIO_MISO_PIN 19
Expand All @@ -58,20 +63,28 @@
#define RADIO_BUSY_PIN 32
#endif


#ifdef TTGO_T_Beam_V0_7
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
#define GPS_RX 15
#define GPS_TX 12
#define BUTTON_PIN 39
#define BATTERY_PIN 35
#endif


#ifdef TTGO_T_LORA32_V2_1_TNC
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
#define GPS_RX -1
#define GPS_TX -1
#define BATTERY_PIN 35
//#define BUTTON_PIN -1
#endif


#ifdef TTGO_T_Beam_S3_SUPREME_V3
#define OLED_SDA 17
#define OLED_SCL 18
Expand All @@ -89,7 +102,11 @@
#define RADIO_BUSY_PIN 4
#endif


#ifdef OE5HWN_MeshCom
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
#define GPS_RX 17
#define GPS_TX 16
#define BUTTON_PIN 12
Expand All @@ -105,14 +122,14 @@
#define RADIO_TXEN 13
#endif


#ifdef ESP32_C3_DIY_LoRa_GPS
#define OLED_SDA 8
#define OLED_SCL 9
#define OLED_RST 10
#define GPS_RX 20
#define GPS_TX 21
#define BATTERY_PIN 1
//#define BUTTON_PIN -1
#define LORA_SCK 4
#define LORA_MISO 5
#define LORA_MOSI 6
Expand All @@ -121,6 +138,7 @@
#define LORA_IRQ 2 // IRQ --> DIO0
#endif


#ifdef HELTEC_V3_GPS
#define OLED_SDA 17
#define OLED_SCL 18
Expand All @@ -129,7 +147,7 @@
#define GPS_TX 48
#define BUTTON_PIN 0
#define BATTERY_PIN 1
#define VExt_CTRL 36
#define VEXT_CTRL 36
#define ADC_CTRL 37 // Heltec V3 needs ADC_CTRL = LOW powers the voltage divider to read BatteryPin
#define RADIO_SCLK_PIN 9
#define RADIO_MISO_PIN 11
Expand All @@ -140,6 +158,7 @@
#define RADIO_BUSY_PIN 13
#endif


#ifdef HELTEC_WIRELESS_TRACKER
#define GPS_RX 34
#define GPS_TX 33
Expand All @@ -148,7 +167,7 @@
#define BUTTON_PIN 0
#define BATTERY_PIN 1
#define ADC_CTRL 2 // HELTEC Wireless Tracker ADC_CTRL = HIGH powers the voltage divider to read BatteryPin. Only on V05 = V1.1
#define VExt_CTRL 3 // To turn on GPS and TFT
#define VEXT_CTRL 3 // To turn on GPS and TFT
#define BOARD_I2C_SDA 7
#define BOARD_I2C_SCL 6
#define RADIO_SCLK_PIN 9
Expand All @@ -160,6 +179,7 @@
#define RADIO_BUSY_PIN 13 // SX1262 BUSY
#endif


#ifdef TTGO_T_DECK_GPS
#define GPS_RX 43
#define GPS_TX 44
Expand All @@ -176,7 +196,7 @@
#define RADIO_DIO1_PIN 45
#define RADIO_BUSY_PIN 13

/*#define BOARD_I2S_WS 5 // esto es apra el audio!
/*#define BOARD_I2S_WS 5 // esto es para el audio!
#define BOARD_I2S_BCK 7
#define BOARD_I2S_DOUT 6*/

Expand All @@ -186,7 +206,6 @@
#define TrackBallDown 15 // G S3
#define TrackBallLeft 1 // G S4
#define TrackBallRight 2 // G S2

#endif


Expand Down
44 changes: 32 additions & 12 deletions src/power_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,30 @@ namespace POWER_Utils {
return (PMU.getBattVoltage() / 1000.0);
#else
#ifdef BATTERY_PIN
int adc_value = analogRead(BATTERY_PIN);
double voltage = (adc_value * 3.3 ) / 4095.0;
#ifdef ADC_CTRL
#ifdef HELTEC_WIRELESS_TRACKER
digitalWrite(ADC_CTRL, HIGH);
#endif
#ifdef HELTEC_V3_GPS
digitalWrite(ADC_CTRL, LOW);
#endif
#endif
int adc_value = analogRead(BATTERY_PIN);
#ifdef ADC_CTRL
#ifdef HELTEC_WIRELESS_TRACKER
digitalWrite(ADC_CTRL, LOW);
#endif
#ifdef HELTEC_V3_GPS
digitalWrite(ADC_CTRL, HIGH);
#endif
#endif
double voltage = (adc_value * 3.3 ) / 4095.0;
#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(OE5HWN_MeshCom)
return (2 * (voltage + 0.1)) * (1 + (lora32BatReadingCorr/100)); // (2 x 100k voltage divider) 2 x voltage divider/+0.1 because ESP32 nonlinearity ~100mV ADC offset/extra correction
return (2 * (voltage + 0.1)) * (1 + (lora32BatReadingCorr/100)); // (2 x 100k voltage divider) 2 x voltage divider/+0.1 because ESP32 nonlinearity ~100mV ADC offset/extra correction
#endif
#if defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER) || defined(ESP32_C3_DIY_LoRa_GPS)
double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side.
return (voltage / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side.
return (voltage / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
#endif
#else
return 0.0;
Expand Down Expand Up @@ -279,7 +295,6 @@ namespace POWER_Utils {
}

void setup() {
//Wire.end();
#ifdef HAS_AXP192
Wire.begin(SDA, SCL);
if (begin(Wire)) {
Expand Down Expand Up @@ -334,13 +349,19 @@ namespace POWER_Utils {
PMU.setSysPowerDownVoltage(2600);
#endif

#if defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER)
pinMode(VExt_CTRL,OUTPUT); // this is for GPS and TFT screen on Wireless_Tracker and only for Oled in Heltec V3
digitalWrite(VExt_CTRL, HIGH);
pinMode(ADC_CTRL, OUTPUT);
digitalWrite(ADC_CTRL, HIGH);
#ifdef BATTERY_PIN
pinMode(BATTERY_PIN, INPUT);
#endif

#ifdef VEXT_CTRL
pinMode(VEXT_CTRL,OUTPUT); // this is for GPS and TFT screen on Wireless_Tracker and only for Oled in Heltec V3
digitalWrite(VEXT_CTRL, HIGH);
#endif

#ifdef ADC_CTRL
pinMode(ADC_CTRL, OUTPUT);
#endif

#if defined(HELTEC_WIRELESS_TRACKER)
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
#endif
Expand All @@ -366,7 +387,6 @@ namespace POWER_Utils {

delay(500);
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);

#endif
}

Expand Down

0 comments on commit 4a7eae2

Please sign in to comment.