“Which TTGO, which firmware, do you restart the device, have you asked to reset the counters?”
TBEAM-V22-1-1 yes restart new device in V3,
reset counters, i dont know what you mean ?
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
Serial.println("AXP192 Begin PASS");
} else {
Serial.println("AXP192 Begin FAIL");
}
//! enable all irq channel
axp.setPowerOutPut(AXP202_LDO2, AXP202_ON);
// axp.setPowerOutPut(AXP202_LDO3, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
axp.setDCDC1Voltage(3300);
axp.setPowerOutPut(AXP202_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP202_DCDC3, AXP202_ON);
axp.setPowerOutPut(AXP202_EXTEN, AXP202_ON);
///axp.setLDO3Voltage(3300);
///axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); // GPS voeding uitzetten
/*
Serial.printf("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
Serial.printf("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
Serial.printf("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
Serial.printf("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
*/
/*
Serial.print("DC1:");
Serial.print(axp.isDCDC1Enable() ? String(axp.getDCDC1Voltage()) + " mv" : "DISABLE");
Serial.print(" ");
Serial.print("DC2:");
Serial.print(axp.isDCDC2Enable() ? String(axp.getDCDC2Voltage()) + " mv" : "DISABLE");
Serial.print(" ");
Serial.print("DC3:");
Serial.print(axp.isDCDC3Enable() ? String(axp.getDCDC3Voltage()) + " mv" : "DISABLE");
Serial.print(" ");
Serial.print("LDO2:");
Serial.print(axp.isLDO2Enable() ? String(axp.getLDO2Voltage()) + " mv" : "DISABLE");
Serial.print(" ");
Serial.print("LDO3:");
Serial.print(axp.isLDO3Enable() ? String(axp.getLDO3Voltage()) + " mv" : "DISABLE");
Serial.println(" ");
Serial.print("LDO4:");
Serial.print(axp.isLDO4Enable() ? "ENABLE" : "DISABLE");
Serial.print(" ");
Serial.print("Exten:");
Serial.print(axp.isExtenEnable() ? "ENABLE" : "DISABLE");
Serial.print("\r\n");
*/
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ, 1);
axp.clearIRQ();
if (axp.isChargeing()) {
baChStatus = "Charging";
} else {
baChStatus = "No Charging";
}
///// Serial.println("------------------------ " + String(baChStatus));
// if (bootCount < 5) axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
if (ContinueGPSzendenAAN) {
axp.setChgLEDMode(AXP20X_LED_BLINK_1HZ);
}
else {
if (bootCount < 2) axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
}
//axp.setChgLEDMode(AXP20X_LED_BLINK_1HZ);
//I don't think this board has a built in LED, other than the Charge LED, controlled by this:
// AXP20X_LED_OFF,
// AXP20X_LED_BLINK_1HZ,
// AXP20X_LED_BLINK_4HZ,
// AXP20X_LED_LOW_LEVEL,
Temp_setup();
gps_setup();
//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
//Configure GPIO38 as ext0 wake up source for HIGH logic level
esp_sleep_enable_ext0_wakeup(GPIO_NUM_38, 0); // zet ContinueGPSzendenAAN naar true
//Print the wakeup reason for ESP32
print_wakeup_reason();
smartDelay(50);
Serial.printf("Starting...\r\n");
// LMIC init
os_init();
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();
//------------------------
// Set static session parameters. Instead of dynamically establishing a session
// by joining the network, precomputed session parameters are be provided.
uint8_t appskey[sizeof(APPSKEY)];
uint8_t nwkskey[sizeof(NWKSKEY)];
memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
// Set up the channels used by the Things Network, which corresponds
// to the defaults of most gateways. Without this, only three base
// channels from the LoRaWAN specification are used, which certainly
// works, so it is good for debugging, but can overload those
// frequencies, so be sure to configure the full frequency range of
// your network here (unless your network autoconfigures them).
// Setting up channels should happen after LMIC_setSession, as that
// configures the minimal channel set.
// NA-US channels 0-71 are configured automatically
LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_DECI); // g-band
LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_DECI); // g-band
LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK, DR_FSK), BAND_DECI); // g2-band
// TTN defines an additional channel at 869.525Mhz using SF9 for class B
// devices' ping slots. LMIC does not have an easy way to define set this
// frequency and support for class B is spotty and untested, so this
// frequency is not configured here.
// Disable data rate adaptation
// LMIC_setAdrMode(0);
// Disable link check validation
LMIC_setLinkCheckMode(0);
// Select frequencies range
//------------------------
// Disable link-check mode and ADR, because ADR tends to complicate testing.
// Set the data rate to Spreading Factor 7. This is the fastest supported rate for 125 kHz channels, and it
// minimizes air time and battery power. Set the transmission power to 14 dBi (25 mW).
//This tells LMIC to make the receive windows bigger, in case your clock is 1% faster or slower.
//If it is a timing issue indeed, then you could try to increase the value, like changing it from 1/100 to 10/100.
//(Very large values, like even 100% might not be supported 5.)
LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100); //vergroot het RX2 window
// TTN uses SF9 for its RX2 window.
LMIC.dn2Dr = DR_SF9;
//LMIC_setDrTxpow(DR_SF9, 14);
////LMIC_setDrTxpow(DR_SF9, 20); ////==============================
// Uplink moet op SF7 blijven staan, dan werkt de downlink op SF9 beter.
// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF7, 14); //LMIC_setDrTxpow(DR_SF7,14);
Serial.printf("LMIC setup done!\r\n");
// Start job
do_send(&sendjob);
if (bootCount > 2) sleeptimerInSeconden = (300 - TIME_TO_SLEEP);// zet de timer op 5 Minuten....
}
///// einde setup................_______________