Skip to content

Commit 7281ec2

Browse files
authored
Merge pull request #3 from ssbc/tbeam_07
Tbeam 07 tweaks, serial USB detection for uploading
2 parents 62242cd + ef703f3 commit 7281ec2

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

esp32/loramesh-TBeam/Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ESPTOOL=/Users/tschudin/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1/
1717
BOOTAPP0PATH=/Users/tschudin/Library/Arduino15/packages/esp32/hardware/esp32/2.0.9/tools/partitions/boot_app0.bin
1818

1919
# name of the ino file:
20-
MAIN=loramesh-TBEAM.ino
20+
MAIN=loramesh-TBeam.ino
2121

2222
ifeq ($(BOARD),heltec)
2323
FQBN=esp32:esp32:heltec_wifi_lora_32_V2
@@ -33,11 +33,15 @@ endif
3333
ifndef SERIAL
3434
ifeq ($(BOARD),heltec) # heltec LORA32
3535
SERIAL = $(shell ls /dev/tty.usbserial-*)
36-
else # T-Beam
37-
SERIAL = $(shell ls /dev/tty.wchusbserial*)
36+
else # T-Beam
37+
SERIAL= $(shell ls /dev/tty* | grep 'ACM\|USB\|wchusb')
3838
endif
3939
endif
4040

41+
ifdef FLAG #use for sending an extra #def flag to be appended to files, such as FLAG=TBEAM_07
42+
EXTRA_FLAG=,compiler.cpp.extra_flag=-D$(FLAG)
43+
endif
44+
4145
# ----------------------------------------------------------------------
4246

4347
all:
@@ -49,7 +53,7 @@ compile:
4953
rm -f partitions.csv
5054
ln -s $(PARTITIONS_CSV) partitions.csv
5155
$(BINDIR)/arduino-cli compile -v --fqbn $(FQBN) $(MAIN) \
52-
--build-properties build.partitions=partitions.csv,upload.maximum_size=1572864
56+
--build-properties build.partitions=partitions.csv,upload.maximum_size=1572864$(EXTRA_FLAG)
5357

5458
upload:
5559
$(foreach var,$(SERIAL), $(BINDIR)/arduino-cli upload -v --fqbn $(FQBN) -p $(var) .;)

esp32/loramesh-TBeam/hw_setup.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
#include "config.h"
1212

13+
#ifdef TBEAM_07
14+
#define GPS_TX 12
15+
#define GPS_RX 15
16+
#endif
17+
1318
#if !defined(NO_WIFI)
1419
WiFiUDP udp;
1520
#endif
@@ -139,6 +144,10 @@ void hw_setup() // T-BEAM or Heltec LoRa32v2
139144
}
140145
#endif // T-Beam
141146

147+
#if defined(TBEAM_07)
148+
GPS.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX);
149+
#endif
150+
142151
#if defined(HAS_LORA)
143152
LoRa.setSignalBandwidth(the_lora_config->bw);
144153
LoRa.setSpreadingFactor(the_lora_config->sf);

esp32/loramesh-TBeam/loramesh-TBeam.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void setup()
212212
#if defined(AXP_DEBUG)
213213
unsigned long int m = millis();
214214
lora_log.printf("t=%d.%03d battery=%.04gV\n", m/1000, m%1000,
215-
axp.getBattVoltage()/1000);
215+
getBattVoltage());
216216
next_log_battery = m + LOG_BATTERY_INTERVAL;
217217
#endif
218218
lora_log.printf("millis,batt,utc,mac,lat,lon,ele,plen,prssi,psnr,pfe,rssi\n");
@@ -431,7 +431,7 @@ void do_io()
431431
unsigned long int now = millis();
432432
lora_log.printf("t=%d.%03d ", now/1000, now%1000);
433433
# if defined(AXP_DEBUG)
434-
lora_log.printf("battery=%.04gV ", axp.getBattVoltage()/1000);
434+
lora_log.printf("battery=%.04gV ", getBattVoltage());
435435
# endif
436436
lora_log.printf("|dmxt|=%d |blbt|=%d |feeds|=%d |entries|=%d |chunks|=%d |freeHeap|=%dXX\r\n",
437437
dmx->dmxt_cnt, dmx->blbt_cnt, repo->rplca_cnt, repo->entry_cnt, repo->chunk_cnt, ESP.getFreeHeap());
@@ -498,7 +498,7 @@ void do_io()
498498
sprintf(stat_line + strlen(stat_line)-1, "%d", lora_cnt);
499499
#else
500500
sprintf(stat_line + strlen(stat_line)-1, "%d, batt:%.04g",
501-
lora_cnt, axp.getBattVoltage()/1000);
501+
lora_cnt, getBattVoltage());
502502
#endif
503503
ble_send_stats((unsigned char*) stat_line, strlen(stat_line));
504504
#endif

esp32/loramesh-TBeam/mgmt.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ void mgmt_send_status();
133133
void mgmt_send_beacon();
134134

135135

136+
float getBattVoltage() {
137+
#ifdef TBEAM_07
138+
return analogRead(35) * 0.85 * (2.0 / 1024.0); // 0.85 is voltage divider ratio measured
139+
#else
140+
return axp.getBattVoltage()/1000;
141+
#endif
142+
}
136143

137144
//------------------------------------------------------------------------------
138145
// CREATE PAYLOADS
@@ -158,7 +165,7 @@ unsigned char* _mkStatus()
158165
status.state.beacon = mgmt_beacon;
159166
status.state.voltage = 0;
160167
#if defined(AXP_DEBUG)
161-
status.state.voltage = axp.getBattVoltage()/1000;
168+
status.state.voltage = getBattVoltage();
162169
#endif
163170
status.state.feeds = repo->rplca_cnt;
164171
status.state.entries = repo->entry_cnt;
@@ -192,6 +199,7 @@ unsigned char* _mkStatus()
192199
return (unsigned char*) &status;
193200
}
194201

202+
195203
// fill buffer with key packet
196204
unsigned char* _mkKey(bool op, unsigned char* key)
197205
{

0 commit comments

Comments
 (0)