TTGO T-Deer

Mine have arrived, will take a look tomorrow

That SPI flash module isn’t going to like getting 5V on its IO pins, assuming the board is jumpered to apply 5V to the mega328. I couldn’t find a datasheet on the specific LoRa module to see if its IO pins were 5V tolerant. Can’t imagine why the designer put a 16MHz oscillator and the ability to fry the flash module by installing a jumper. The 8MHz internal oscillator is probably accurate enough to run the LoRa stack without burning up power with an external oscillator module. As others have said, you can’t “legally” run the mega328 on 3.3V at 16MHz. The deal breaker for me is using PB0/D8 to operate the CS line of the flash module, that’s the input capture pin I love to use for super accurate timing, and it can’t be remapped. It might be interesting to see how low you can get the sleep current though.

I use Atmel ICE. Set the jumper to 5 V. Remove the antenna and supply the board with 5 V external power. After I transfer the Lora Sketch, I remove the external power supply. And connect a 3.7V battery. And put the jumper on 3V. Now the Loramodul sends.
The gateway is at a comfortable distance of 10 meters. In sleep mode I use 4.5 mA. When sending 10 mA.
Before I send the first time, sleep mode uses only 2.5 mA. After the first send the sleep mode goes to 4.5 mA. Maybe I’m doing something wrong in the source code. I will investigate this evening.
I’m also unsure if I should remove the red LED.

After removing the red LED. 3.6 mA sleep mode, 9.5 mA during transmission.
With LMIC_shutdown(); 1.1 mA sleep mode.

So, my order was delivered by today. I will start playing around on the weekend.
I think the 5V is defenitely not really good - 3.3V with the matching CP2102 adapter should work.

Mine arrived yesterday and all but worked out of the box, no errors on uploads either.

Using VS/Platformio, set to 5v on usb converter (3v did give errors at the end of uploading code but it did still work), disconnect any battery, make sure lora device is set to 3.3.v - as most ppl have said this is important. Connect DIO1 to D5, DIO2 not needed.

// Pin mapping

const lmic_pinmap lmic_pins = {
.nss = 10,
.rxtx = LMIC_UNUSED_PIN,
.rst = 9,
.dio = {2, 5, LMIC_UNUSED_PIN},
};

PlatformIO/ libraries uses too:-

[env:atmega328pb]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino
upload_speed = 115200
monitor_speed = 9600  
board_build.mcu = atmega328p

lib_deps =
;    https://github.com/matthijskooijman/arduino-lmic
     MCCI LoRaWAN LMIC library
     https://github.com/rocketscream/Low-Power
     https://github.com/sparkfun/SparkFun_HTU21D_Breakout_Arduino_Library
     https://github.com/enjoyneering/BH1750FVI
     https://github.com/LowPowerLab/SFE_BMP180

Don’t ask me about current usage, don’t have kit to measure on battery only. Sleep is working but because there are two leds on, plus the charger circuit too my USB current tester is mostly useless.

I’ve never burt a new bootloader so re the 16mhz/8mhz issue, I’m looking to others for guidance on this :slight_smile:

I still think they are a nice cheap device, wants to drop to 8mhz, remove leds, then it need to be tested re current on battery only.

Red led always on when powered up.
Blue led always on when 5v applied, even with no battery, assume once change complete it drops off.

PS clean upload log below

Linking .pioenvs\atmega328pb\firmware.elf
Checking size .pioenvs\atmega328pb\firmware.elf
Building .pioenvs\atmega328pb\firmware.hex
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [========  ]  77.4% (used 1586 bytes from 2048 bytes)
PROGRAM: [========  ]  83.2% (used 25572 bytes from 30720 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Auto-detected: COM12
Uploading .pioenvs\atmega328pb\firmware.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file ".pioenvs\atmega328pb\firmware.hex"
avrdude: writing flash (25572 bytes):
Writing | ################################################## | 100% 9.59s
avrdude: 25572 bytes of flash written
avrdude: verifying flash memory against .pioenvs\atmega328pb\firmware.hex:
avrdude: load data flash data from input file .pioenvs\atmega328pb\firmware.hex:
avrdude: input file .pioenvs\atmega328pb\firmware.hex contains 25572 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 8.59s

avrdude: verifying …
avrdude: 25572 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

1 Like

So, you set the jumper to 5V for upload?
Any other connections (than the mentioned DIO1)?

Jumper on the lora device leave on 3.3v, don’t touch - the serial connection carries a 5v to the ldo & charger, I just strapped up all 6 wires from the USB serial converter - the Atmega328 is then running on 3.3v as you want, but the tx/rx lines are/maybe at 5v but it seems happy.

Originally I got this sort of working with a lipo battery attached and connecting just dtr/tx/rx to the USB serial converter but whilst it worked I was getting read errors, but it did program ok.

I guess GND was missing, maybe that caused the interference?

If you say the 16MHZ work fine, i would suggest to switch in the sketch to 8MHZ and adopt the serial port to run on the originally defined speed…

I’ll try it with this when I get back later.

prescale_set(clock_div_2);

How is this different/better/worse than burning a new 8mhz bootloader with it coded in that?

Not better, the boot is overclocked but afterwards you are running in spec.
Non the less i will re-write the booloader to have the system clean and a default of clock_div_2

1 Like

Added prescale_set(clock_div_2); to start of setup(); and it added timing issues,

Changed board = pro8MHzatmega328 in platformio.ini and this settled things back down.

All good now at 8mhz, just wish I had the kit to test current when on the battery.

Just noticed that the battery voltage divider is attached to D6 as a battery check (I assume a yes/no its connected check), question, is it possible to collect D6 to A0 and then measure the voltage in the normal way. Not sure if having the voltage divider connected to both D6 and A0 is workable?

As long as D6 is an input pin, with no pull-up or pull-down enabled, it shouldn’t interfere with your plan to jumper the pin to the ADC pin. When I looked at the schematic, there seemed to be discrepancies with the pin labels on the diagram on AliExpress. In particular, the CS pin for the SPI flash. The schematic showed D8, but diagram showed something different.

1 Like

I just put the device first time as it was delivered to my PC.
Connected via CP2102, RXT/TXD/GND and 3V3, started the monitor, and i see nice messages comming over the serial port :sunglasses:

XisMKGxEc8zd4RE23TZL

Next step: upload my own sketch and get the LORA WAN running via LMIC - keep you updated!

I have a couple of these in my shopping cart, but haven’t ordered yet. Too bad Amazon doesn’t have them. It’ll take 3 weeks to get them here from AliExpress. Hurry up and post some sleep current measurements. :wink:

Can you tell me which lmic repository you are planning to use?

Just did my first check with
lib_deps_lora = MCCI LoRaWAN LMIC library@^2.3.1

It seems everything is running fine - THX to

everything seems to work out of the box!

1 Like

Thanks. Yes, gotta have DIO1 connected to something or you only transmit once.

I see now that the device wants to join via OTAA (in my gateway traffic view) but my device doesn’t really do it and retries again and again.
I think this is now the point to dig deeper in the LMIC stuff…