Open Hidvegi82 opened 4 years ago
From what I know this module does not have the battery sense, thus resistor divider connected to input 35 or 36 like for example the older version of TTGO T-Beam. Or maybe it has ? It could be as well connected externally: thus from two 100k resistors from the battery terminal to GPIO #36.
Thank you very much, it works!
Just one more question, sorry... Can I change the time zone? (It is here utc+2h)
Did you connect the resistor divider to pin #36 and it shows the correct voltage ? Time zone on the OLED ? No, it is always UTC time, thus "Z" at the end.
Yes, i did connect 2 resistors from battery port to GPIO#36, and now, i can see the correct voltage and percent.
"Time zone on the OLED ? No, it is always UTC time, thus "Z" at the end." Oh, so I can understand what the "Z" at the end. :D
Great, thank you for the picture. The percentage is based on the battery voltage and the relation is simplified: anything above 4.1V is considered 100%, anything below 3.6V is considered empty and in between the two the conversion is linear.
you do not need to solder anything, the Battery-sense-pin changed to gpio37 also you will have to switch on the power for output (gpio21) schematica found at https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/SchematicDiagram/WiFi_LoRa_32(V2)/WIFI_LoRa_32_V2(868-915).PDF changed a proc.cpp in _static void ReadStatus(OGNPacket &Packet) :
#ifdef WITH_ESP32
// Packet.clrTemperature();
#ifdef WITH_HELTEC_V2
uint16_t BattVolt = 1.6 * BatterySense(); // [mV] measure battery voltage
#else
uint16_t BattVolt = BatterySense(); // [mV] measure battery voltage
#endif
changed hal.cpp (with some cleanup because it was bit confusing):
header is now sorted by boards :
/*
https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
GPIO HELTEC v2 HELTEC TTGO JACEK M5_JACEK T-Beam T-Beamv10 FollowMe Restrictions
0 Button Button Button . LCD/DC LCD/DC Can lock the boot, better not pull it down
1 CONS/TxD CONS/TxD CONS/TxD CONS/TxD CONS/TxD CONS/TxD CONS/TxD Console/Program
2 SD/MISO . LCD/MOSI LCD/MOSI LED/DBG Bootstrap: LOW to enter UART download mode
3 CONS/RxD CONS/RxD CONS/RxD CONS/RxD CONS/RxD CONS/RxD CONS/RxD Console/Program
4 OLED/SDA OLED/SDA OLED/SDA ADC/CS LCD/BCKL LCD/BCKL PERF/RST
5 RF/SCK RF/SCK RF/SCK RF/SCK GPS/ANT RF/SCK RF/SCK RF/CS PWM at boot
6 SD/CLK SD/CLK SD/CLK SPI flash
7 SD/DATA0 SD/DATA0 SPI flash
8 SD/DATA1 SD/DATA1 SPI flash
9 SD/DATA2 SD/DATA2 SPI flash
10 SD/DATA3 SD/DATA3 SPI flash
11 SD/CMD SD/CMD SD/CMD SPI flash
12 GPS/TxD GPS/RxD GPS/RxD SD/CS GPS/RxD GPS/TxD SD/MISO HSPI/MISO JTAG/TDI Bootstrap: select output voltage to power the flash chip
13 GPS/Ena GPS/Ena SD/SCK LCD/SCL LCD/CLK LCD/CLK SD/MOSI HSPI/MOSI JTAG/TCK
14 RF/RST RF/RST RF/RST Beeper ? LED/PCB . SD/CLK HSPI/CLK JTAG/TMS PWM at boot
15 OLED/SCL OLED/SCL OLED/SCL SD/MOSI GPS/TxD . HSPI/CS0 JTAG/TDO PWM at boot
16 OLED/RST OLED/RST OLED/RST RF/IRQ GPS/Tx RAM/CS GPS/TX U2_RXD
17 Beeper Beeper Beeper RF/RST GPS/Rx Beeper GPS/RX U2_TXD
18 RF/CS RF/CS RF/CS RF/MISO RF/CS RF/SCK RF/CS VSPI/CLK
19 RF/MISO RF/MISO RF/MISO RF/MOSI RF/MISO RF/MISO RF/MISO RF/MISO VSPI/MISO
20 not listed
21 Vext_p_on . LED? RF/CS I2C/SCL I2C/SDA I2C/SDA I2C/SDA VSPI/QUADHP
22 . . . PWR/ON I2C/SDA I2C/CLK I2C/SCL VSPI/QUADWP
23 . . . PWR/LDO RF/RST RF/MOSI RF/RST RF/MOSI VSPI/MOSI
24 not listed
25 LED LED Speaker . Speaker Speaker Speaker TT/RX
26 RF/IRQ RF/IRQ RF/IRQ SCL RF/IRQ RF/IRQ RF/IRQ PWR/Good
27 RF/MOSI RF/MOSI RF/MOSI SDA RF/MOSI RF/MOSI TT/TX
28 not listed
29 not listed
30 not listed
31 not listed
32 . . . GPS/TxD ? . TT/RST XTAL
33 . . . OLED/RST ? . GPS/EN XTAL
34 RF/DIO2 GPS/PPS GPS/PPS GPS/RxD KNOB/Sense GPS/TxD GPS/PPS
35 RF/DIO1 GPS/TxD GPS/TxD GPS/PPS BAT/Sense AXP/IRQ RF/IRQ
36 . BAT/Sense BAT/Ext. . Vbat/Sense
37 BAT/Sense . GPS/PPS
38 GPS/PPS . Button Button
39 GPS/RxD . Button Button Button
*/
// ************************* TTGO *************************
#if defined(WITH_TTGO)
//RFM
#define PIN_LED_PCB GPIO_NUM_2 // status LED on the PCB
#define PIN_RFM_RST GPIO_NUM_14 // Reset
#define PIN_RFM_IRQ GPIO_NUM_26 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_18 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_27 // SPI MOSI
//GPS VK2828U GN-801 MAVlink
#define PIN_GPS_TXD GPIO_NUM_13 // green green green
#define PIN_GPS_RXD GPIO_NUM_35 // blue yellow yellow
#define PIN_GPS_PPS GPIO_NUM_34 // white blue
//i2c
#define PIN_I2C_SCL GPIO_NUM_15 // SCL pin
#define PIN_I2C_SDA GPIO_NUM_4 // SDA pin
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
#define PIN_OLED_RST GPIO_NUM_16 // OLED RESET: low-active
//beeper
#define PIN_BEEPER GPIO_NUM_17
//button
#define PIN_BUTTON GPIO_NUM_0
#endif
// ************************* HELTEC *************************
#if defined(WITH_HELTEC)
//RFM
#define PIN_LED_PCB GPIO_NUM_25 // status LED on the PCB: 25, GPIO25 is DAC2
#define PIN_RFM_RST GPIO_NUM_14 // Reset
#define PIN_RFM_IRQ GPIO_NUM_26 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_18 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_27 // SPI MOSI
//GPS VK2828U GN-801 MAVlink
#define PIN_GPS_TXD GPIO_NUM_13 // green green green
#define PIN_GPS_RXD GPIO_NUM_35 // blue yellow yellow
#define PIN_GPS_PPS GPIO_NUM_34 // white blue
//i2c
#define PIN_I2C_SCL GPIO_NUM_15 // SCL pin
#define PIN_I2C_SDA GPIO_NUM_4 // SDA pin
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
#define PIN_OLED_RST GPIO_NUM_16 // OLED RESET: low-active
//beeper
#define PIN_BEEPER GPIO_NUM_17
//button
#define PIN_BUTTON GPIO_NUM_0
#endif
// ************************* HELTEC v2 *************************
#if defined(WITH_HELTEC_V2)
#define PIN_LED_PCB GPIO_NUM_25 // status LED on the PCB: 25, GPIO25 is DAC2
#define PIN_RFM_RST GPIO_NUM_14 // Reset
#define PIN_RFM_IRQ GPIO_NUM_26 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_18 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_27 // SPI MOSI
//GPS VK2828U GN-801 MAVlink
#define PIN_GPS_TXD GPIO_NUM_12 // green green green 37 not working
#define PIN_GPS_RXD GPIO_NUM_39 // blue yellow yellow
#define PIN_GPS_PPS GPIO_NUM_38 // white blue
// Note: I had a problem with GPS ENABLE on GPIO13, thus I tied the enable wire to 3.3V for the time being.
//i2c
#define PIN_I2C_SCL GPIO_NUM_15 // SCL pin
#define PIN_I2C_SDA GPIO_NUM_4 // SDA pin
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
#define PIN_OLED_RST GPIO_NUM_16 // OLED RESET: low-active
//beeper
#define PIN_BEEPER GPIO_NUM_17
//button
#define PIN_BUTTON GPIO_NUM_0
//power
#define PIN_POWER GPIO_NUM_21 // power to GPS, RF, ...
#endif
// ************************* FollowMe *************************
#ifdef WITH_FollowMe
#define PIN_LED_PCB GPIO_NUM_2 // debug LED
#define PIN_LED_TX GPIO_NUM_15
#ifdef WITH_BQ
#define PIN_POWER_GOOD GPIO_NUM_26
#endif
// #define PIN_RFM_RST GPIO_NUM_32 // Reset
#define PIN_RFM_IRQ GPIO_NUM_35 // 39 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_5 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_18 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_23 // SPI MOSI
//GPS L80 GPS with PPS, Enable and Reset
#define PIN_GPS_TXD GPIO_NUM_17
#define PIN_GPS_RXD GPIO_NUM_16
#define PIN_GPS_PPS GPIO_NUM_34 // high active
#define PIN_GPS_ENA GPIO_NUM_33 // Enable: high-active
#define PIN_PERIPH_RST GPIO_NUM_4 // Reset: high-active
//adb-s
#define AERO_UART UART_NUM_2 // UART2
#define PIN_AERO_TXD GPIO_NUM_25
#define PIN_AERO_RXD GPIO_NUM_27
//i2c
#define PIN_I2C_SCL GPIO_NUM_22 // SCL pin
#define PIN_I2C_SDA GPIO_NUM_21 // SDA pin
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
// #define PIN_OLED_RST GPIO_NUM_15 // OLED RESET: low-active
#define PIN_SD_MISO GPIO_NUM_12 // SD card in simple SPI mode, using HSPI IOMUX pins
#define PIN_SD_MOSI GPIO_NUM_13
#define PIN_SD_SCK GPIO_NUM_14
#define PIN_SD_CS GPIO_NUM_15
#define SD_SPI_DMA 2
#define PIN_BUTTON GPIO_NUM_39 // or 38 ?
#endif
// #define PIN_LED_TX GPIO_NUM_??
// #define PIN_LED_RX GPIO_NUM_??
// ************************* JACEK *************************
#ifdef WITH_JACEK
#define PIN_RFM_RST GPIO_NUM_17 // Reset
#define PIN_RFM_IRQ GPIO_NUM_16 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_21 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_18 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_19 // SPI MOSI
//GPS
#define PIN_GPS_TXD GPIO_NUM_32
#define PIN_GPS_RXD GPIO_NUM_34
#define PIN_GPS_PPS GPIO_NUM_35
//i2c
#define PIN_I2C_SCL GPIO_NUM_26 // SCL pin
#define PIN_I2C_SDA GPIO_NUM_27 // SDA pin
#define PIN_OLED_RST GPIO_NUM_33 // OLED RESET: low-active
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
#define PIN_POWER GPIO_NUM_22 // power to GPS, RF, ...
#define PIN_POWER_LDO GPIO_NUM_23 // LOW=low power LDO, HIGH=higher power LDO
#define PIN_SD_CS GPIO_NUM_12 // SD card interface in SPI mode
#define PIN_SD_SCK GPIO_NUM_13
#define PIN_SD_MISO GPIO_NUM_2
#define PIN_SD_MOSI GPIO_NUM_15
#define SD_SPI_DMA 2
#define PIN_BEEPER GPIO_NUM_14
#define PIN_BUTTON GPIO_NUM_38
#endif // JACEK
// ************************* M5_JACEK *************************
#ifdef WITH_M5_JACEK
//RFM
#define PIN_RFM_RST GPIO_NUM_13 // Reset
#define PIN_RFM_IRQ GPIO_NUM_35 // Packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_12 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_18 // SPI clock (same as LCD)
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO (save as LCD)
#define PIN_RFM_MOSI GPIO_NUM_23 // SPI MOSI (save as LCD)
//GPS
#define PIN_GPS_TXD GPIO_NUM_17
#define PIN_GPS_RXD GPIO_NUM_16
#define PIN_GPS_PPS GPIO_NUM_26
#define PIN_GPS_ANT GPIO_NUM_5 // internal(H) or external(L) GPS antenna
//i2c
#define PIN_I2C_SCL GPIO_NUM_22 // SCL pin
#define PIN_I2C_SDA GPIO_NUM_21 // SDA pin
#define PIN_SD_CS GPIO_NUM_11 // SD card interface in SPI mode
#define PIN_SD_SCK GPIO_NUM_6
#define PIN_SD_MISO GPIO_NUM_7
#define PIN_SD_MOSI GPIO_NUM_8
#define SD_SPI_DMA 2
#define PIN_BEEPER GPIO_NUM_25 // DAC
#define PIN_BUTTON_L GPIO_NUM_37 // Left
#define PIN_BUTTON GPIO_NUM_38 // Center
#define PIN_BUTTON_R GPIO_NUM_39 // Right
#endif // M5_JACEK
// ************************* TBEAM *************************
#if defined(WITH_TBEAM)
#define PIN_LED_PCB GPIO_NUM_14 // blue LED on the PCB: 14
#define PIN_RFM_RST GPIO_NUM_23 // Reset - not clear if T-Beam is using it, or maybe only the older version
#define PIN_RFM_IRQ GPIO_NUM_26 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_18 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_27 // SPI MOSI
// #define PIN_LED_PCB_INV
#ifdef WITH_ST7789
#define LCD_PIN_MOSI GPIO_NUM_2 // SDA
#define LCD_PIN_MISO GPIO_NUM_NC // MISO not connected
#define LCD_PIN_CLK GPIO_NUM_13 // SCL
#define LCD_SPI_SPEED 10000000 // [Hz]
#define LCD_SPI_HOST HSPI_HOST // VSPI_HOST or HSPI_HOST
#define LCD_SPI_DMA 2 // DMA channel
#define LCD_SPI_MODE 3 // for ST7789 with CS tied to LOW
#endif // ST7789
//GPS
#define PIN_GPS_TXD GPIO_NUM_15
#define PIN_GPS_RXD GPIO_NUM_12
//i2c
#define PIN_I2C_SCL GPIO_NUM_22 // SCL pin => this way the pin pattern fits the BMP280 module
#define PIN_I2C_SDA GPIO_NUM_21 // SDA pin
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
//beeper
#define PIN_BEEPER GPIO_NUM_25 // same as DAC
#endif // TBEAM
// ************************* TBEAM v10 *************************
#ifdef WITH_TBEAM_V10
#define PIN_RFM_RST GPIO_NUM_23 // Reset 23
#define PIN_RFM_IRQ GPIO_NUM_26 // packet done on receive or transmit
#define PIN_RFM_SS GPIO_NUM_18 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
#define PIN_RFM_MOSI GPIO_NUM_27 // SPI MOSI
#ifdef WITH_ST7789
#define LCD_PIN_MOSI GPIO_NUM_14 // 13 // SDA
#define LCD_PIN_MISO GPIO_NUM_NC // MISO not connected
#define LCD_PIN_CLK GPIO_NUM_13 // 2 // SCL
// #define LCD_PIN_MOSI GPIO_NUM_2 // 13 // SDA
// #define LCD_PIN_MISO GPIO_NUM_NC // MISO not connected
// #define LCD_PIN_CLK GPIO_NUM_13 // 14 // SCL
// #define LCD_PIN_RST GPIO_NUM_15 // NC // RST
#define LCD_SPI_SPEED 10000000 // [Hz]
#define LCD_SPI_HOST HSPI_HOST // VSPI_HOST or HSPI_HOST
#define LCD_SPI_DMA 2 // DMA channel
#define LCD_SPI_MODE 3 // for ST7789 with CS tied to LOW
#endif // ST7789
#define PIN_AXP_IRQ GPIO_NUM_35
//GPS
#define PIN_GPS_TXD GPIO_NUM_12
#define PIN_GPS_RXD GPIO_NUM_34
#define PIN_GPS_PPS GPIO_NUM_37
//i2c
#define PIN_I2C_SCL GPIO_NUM_22 // SCL pin => this way the pin pattern fits the BMP280 module
#define PIN_I2C_SDA GPIO_NUM_21 // SDA pin
#define OLED_I2C_ADDR 0x3C // I2C address of the OLED display
//beeper
#define PIN_BEEPER GPIO_NUM_25 // same as DAC
//button
#define PIN_BUTTON GPIO_NUM_38
#endif // TBEAM
#define RFM_SPI_HOST VSPI_HOST // or H or VSPI_HOST ?
#define RFM_SPI_DMA 1 // DMA channel
#define RFM_SPI_SPEED 4000000 // [Hz] 4MHz SPI clock rate for RF chip
#define CONS_UART UART_NUM_0 // UART0 for the console (the system does this for us)
#define GPS_UART UART_NUM_1 // UART1 for GPS data read and dialog
#define I2C_BUS I2C_NUM_1 // use bus #1 to talk to OLED and Baro sensor
uint8_t BARO_I2C = (uint8_t)I2C_BUS;
#if !defined(WITH_AXP) && !defined(WITH_BQ) && !defined(WITH_OLED) && !defined(WITH_U8G2_OLED) && !defined(WITH_BMP180) && !defined(WITH_BMP280) && !defined(WITH_BME280)
#undef PIN_I2C_SCL
#undef PIN_I2C_SDA
#endif
#ifndef PIN_BUTTON
#define PIN_BUTTON GPIO_NUM_39
#endif
// ======================================================================================================
// 48-bit unique ID of the chip
then the in section // Power control
#ifdef WITH_HELTEC_V2
void POWER_Dir (void) { gpio_set_direction(PIN_POWER, GPIO_MODE_OUTPUT); }
void POWER_On (void) { gpio_set_level(PIN_POWER, 0); } //
void POWER_Off (void) { gpio_set_level(PIN_POWER, 1); }
#endif
#ifdef WITH_JACEK
void POWER_Dir (void) { gpio_set_direction(PIN_POWER, GPIO_MODE_OUTPUT); }
void POWER_On (void) { gpio_set_level(PIN_POWER, 0); } //
void POWER_Off (void) { gpio_set_level(PIN_POWER, 1); }
void POWER_LDO_Dir(void) { gpio_set_direction(PIN_POWER_LDO, GPIO_MODE_OUTPUT); }
void POWER_LDO_On (void) { gpio_set_level(PIN_POWER_LDO, 1); } //
void POWER_LDO_Off(void) { gpio_set_level(PIN_POWER_LDO, 0); }
#endif
in section // ADC
#ifdef WITH_TBEAM
static adc1_channel_t ADC_Chan_Batt = ADC1_GPIO35_CHANNEL;
static adc1_channel_t ADC_Chan_Knob = ADC1_GPIO34_CHANNEL;
#elseif WITH_HELTEC_V2
static adc1_channel_t ADC_Chan_Batt = ADC1_GPIO37_CHANNEL;
#else
static adc1_channel_t ADC_Chan_Batt = ADC1_GPIO36_CHANNEL;
#endif
in _void IO_Configuration(void)_
#ifdef WITH_JACEK
POWER_LDO_Dir(); // speific power control
POWER_LDO_On();
POWER_Dir();
POWER_On();
#endif
#ifdef WITH_HELTEC_V2
POWER_Dir();
POWER_On();
#endif
#ifdef WITH_M5_JACEK
GPS_ANT_Dir();
GPS_ANT_Sel(1); // 0 = external entenna
#endif
everything is running fine but without outdoor-test
sorry, I made an mistake in section //ADC must be
#ifdef WITH_TBEAM
static adc1_channel_t ADC_Chan_Batt = ADC1_GPIO35_CHANNEL;
static adc1_channel_t ADC_Chan_Knob = ADC1_GPIO34_CHANNEL;
#else
#ifdef WITH_HELTEC_V2
static adc1_channel_t ADC_Chan_Batt = ADC1_GPIO37_CHANNEL;
#else
static adc1_channel_t ADC_Chan_Batt = ADC1_GPIO36_CHANNEL;
#endif
#endif
Hi I tested the changes today, but the gpio36 still needed the resistor divider. Then you sent the correction (in section ADC), and now it works perfectly. Tomorrow I'm doing an outdoor test. Thank you!
Sorry, it rained for 2 days. I did an outdoor test today. The display shows battery data OK, BMP280 data OK, GPS data OK. But the tracker did not appear on the map even next to the reciever. Although http://wiki.glidernet.org/esp32-ogn-tracker says "With Heltec V2 Board the parameter FreqCorr by default is ok (0), do not change.", after i set FreqCorr to -20, appeared the tracker on the map. So everything is perfect! I have a little problem ... When the battery is fully charged, the charge indicator LED will continue to light. Is this controlled by software or the panel? This is a 3.7V Li-Po battery, I will try it with an 18650 Li-ion battery. Thanks again for your help!
Hi,
I use Heltec Lora 32 v2 with Oled. I tried it with LiPo and Li-ion batteries but the display show 0% and ~0.3V (+00.0mV/min). The device runs on battery well and charges from usb.
Thanks!