1212 * - WIFI Kit series V1 don't have Vext control function;
1313 *
1414 * HelTec AutoMation, Chengdu, China.
15- * �ɶ��������Զ����Ƽ�����˾
16- * www. heltec.cn
15+ * 成都惠利特自动化科技有限公司
16+ * https:// heltec.org
17171818 *
1919 * this project also release in GitHub:
2424#include < Wire.h>
2525#include " heltec.h"
2626
27- // #define Vext 21
28- //
29- // #define SDA 4 //OLED SDA pin
30- // #define SCL 15 //OLED SCL pin
31- // #define RST 16 //OLED nRST pin
3227#define Fbattery 3700 // The default battery is 3700mv when the battery is fully charged.
3328
3429float XS = 0.00225 ; // The returned reading is multiplied by this XS to get the battery voltage.
3530uint16_t MUL = 1000 ;
3631uint16_t MMUL = 100 ;
37- // SSD1306 display(0x3c, SDA, SCL, RST);
3832
3933void setup ()
4034{
41- // pinMode(Vext, OUTPUT);
42- // digitalWrite(Vext, LOW);
43- // delay(1000);
44- Heltec.begin (true /* DisplayEnable Enable*/ , false /* LoRa Enable*/ , true /* Serial Enable*/ );
35+ Heltec.begin (true /* DisplayEnable Enable*/ , false /* LoRa Enable*/ , true /* Serial Enable*/ );
4536
4637 Heltec.display ->init ();
4738 Heltec.display ->flipScreenVertically ();
@@ -59,18 +50,20 @@ Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Enable*/, true /*Serial
5950
6051void loop ()
6152{
62- uint16_t c = analogRead (13 )*XS*MUL;
63- // uint16_t d = (analogRead(13)*XS*MUL*MMUL)/Fbattery;
64- Serial.println (analogRead (13 ));
65- // Serial.println((String)d);
66- // Serial.printf("%x",analogRead(13));
53+ // WiFi LoRa 32 -- hardare versrion ≥ 2.3
54+ // WiFi Kit 32 -- hardare versrion ≥ 2
55+ // Wireless Stick -- hardare versrion ≥ 2.3
56+ // Wireless Stick Lite -- hardare versrion ≥ 2.3
57+ // Battery voltage read pin changed from GPIO13 to GPI37
58+ uint16_t c = analogRead (37 )*XS*MUL;
59+ Serial.println (analogRead (37 ));
60+ // uint16_t c = analogRead(13)*XS*MUL;
61+ // Serial.println(analogRead(13));
62+
6763 Heltec.display ->drawString (0 , 0 , " Remaining battery still has:" );
6864 Heltec.display ->drawString (0 , 10 , " VBAT:" );
6965 Heltec.display ->drawString (35 , 10 , (String)c);
7066 Heltec.display ->drawString (60 , 10 , " (mV)" );
71- // Heltec.display->drawString(90, 10, (String)d);
72- // Heltec.display->drawString(98, 10, ".";
73- // Heltec.display->drawString(107, 10, "%");
7467 Heltec.display ->display ();
7568 delay (2000 );
7669 Heltec.display ->clear ();
0 commit comments