AM02 Module Plus - Custom PCB - Minimal circuit arduino compatible

Hi to all,
I made a custom pcb for the AM02 module with recommended circuit. I want to make another PCB but not including Usb port/user reset button and circuitry and using an FT232 externally.

On my first PCB I put external header pins for GND CTS 5VTXD RXD DTR but when I try to upload code I got the “Initialising bootloader.
Unhandled error: Timed out waiting for Bootloader response.” error with any combination of Reset and User button.
Using the usb and CP2102 chip normaly, I am able to upload code without pressing any buttons.

What is the minimal configuration for flashing an AM02 with an USB UART FT232 based? Did someone make a PCB based on a AM0x module AND not using CP2102/User/Reset buttons ?

hi,
Cubecell download program needs to enter bootloader mode.

"Did someone make a PCB based on a AM0x module AND not using CP2102/User/Reset buttons ?"
The prerequisite for this is: use the AUTO-BOOT circuit shown below

Thank you @jasonXu,


I made this in my PCB and GND CTS 5VTXD RXD DTR on header pins.Capture%20d%E2%80%99%C3%A9cran%20du%202021-03-02%2016-19-17
Capture%20d%E2%80%99%C3%A9cran%20du%202021-03-02%2016-18-11
What wiring can I make to flash with this dongle ?
I suppose DTR-DTR / TX-RX on corresponding pins on AM02 / +5V from the dongle to my +5V rail on PCB and GND-GND ? Where do I need to plug CTS ?
Do I have to plug all the pins from my flashing FT232RL device to my PCB to flash?

You don’t need CTS connected to PCB. Indeed the CTS is useless for CubeCell.

Besides this connection, just need to connect the RTS to your PCB’s RTS.

My implementation is as follows (RST goes to ASR6502 pin #33, PRG to pin #14)
RstPrg

I wanted to keep the programming/reset circuit as simple as possible. In my case programming is normaly done only once while AM02 is used in the end device. Holding both reset and programming buttons down and releseasing reset first, then MCU goes to bootloader and you can upload your binary.

Many adapters have also 3V3 output, in my case I use 3V3 from adapter to power up the device during programming. If you want to make the circuit even more simple, the reset button can be left out. Then just hold down program button and switch power on when you want to enter programming mode.

For program development it is easier just use the Cubecell development board, it has built in USB-interface with automatic reset/programming feature.

I use this kind of CP2102 based USB-TTL serial adapter for programming AM02:
PrgBrd

Hi @arit, thanks for sharing you diagram. I will make my new shematic with your recommandation especially if you confirm to me that only these pins (RX/TX/3.3/GND/RST/PRG) are necessary for flashing. I thank you for sharing to the community your experience.

I order a new CP2102 based USB-TTL serial adapter, I think you propose a good solution for reducing component usage on custom PCB’s.

I also order +5V coils for testing induction charging. I will share my next schematic when orders will be shipped.
Thanks again

Works at least in my case. Here is a photo of the final product PCB:

I use mainly PlatformIO as a development platform but I have tested also that Arduino IDE works with program binary upload. Just bear in mind that you have to activate the bootloader manually holding RST and PRG buttons down, then release first RST then PRG and then start upload.

As I mentioned earlier you can even leave RST button away. Then you have to keep PRG down when device is powered on to enter bootloader mode. In this version of PCB I have also a header pin for reset (RST), it is there just to make it possible to leave reset button away but still make it possible to use hw reset if needed.

3 Likes

Hi @arit, your post inspire me to simplify my next PCB design. I need to flash one time my CubeCell module too, so externalize the flashing circuit and reduce components are good to me.
My project will be placed in a waterproof case and verry probably resin sealed.

As PCB design is not my domain, your picture are quite inspiring on design like ground planes, components position, vias positioning, circuit simplification.
I let you know advancement for my project if it can help community.
So for my next PCB I will use this external USB-TTL serial adapter, I order pogo pins and I will flash on probe points. To substitute the only button (RST) and to keep in mind that my project will be sealed, I order some reed switch normaly opened, wich close with a simple magnet. I have continuity with a small neodym magnet at 2cm.

Someone have an advice for designing an external SMA connector. 50ohms traces, method to inactivate the native µFL module connector ?

I’m also waiting for +5V coils for wireless induction charging.

Thanks!

Hi to all,
a little update for @arit and a question for @jasonXu.

I use the proposed circuit above and all works very well for flashing my custom pcb and adapt for enclosing my device and make it waterproof. So @arit thanks for your advice! This is the choices I made :slight_smile:

-Instead a button for Reset, I use a reed switch. When I want to reset my PCB without opening the case, I use a magnet.
-I design 4 tests points on my PCB and flash it with my 4xPogos pins on my last picture.
One of my mistake was to place a physical button for the PRG pin. On the next prototype I will use a simple jumper (reduce cost and increase ergonomy for flashing)

For power management I use the TP4054 for charging a 18650 battery. Instead of using a solar panel, I use a 5V induction charging coil wich permit to charge the device without opening the case.

For the next PCB (and I hope with a new module :slight_smile: from Heltec) I will try to make a good RF section, as I am not a specialist it’s like black magic to make an external SMA antenna connector. I desolder the 0ohm resistor near the µFL connector on the module and I design on Kicad an SMA board edge connector with 50ohm impedance trace. I simply solder a 868MHz helical antenna on the positive side.
I will also take more time to place the tests points for flashing.

For @jasonXu, I want to use another temperature sensor (actually SHT31) wich consume current for readind humidity that I don’t use. @ksckung proposed advice me for powering my sensors on http://community.heltec.cn/t/custom-pcb-htcc-am02-on-kicad/3376/12

What kind of temperature sensor (SMC component) could you propose for the lowest consumption and avalaible libraries (maybe some of Heltec boards have temperature sensor with low power consumption.

This is some picture of the PCB 4 layers (newbie here, if someone see obvious design mistakes please let me know because there is a lot of stuff to know about pcb design).

Capture%20d%E2%80%99%C3%A9cran%20du%202021-06-01%2022-48-07 Capture%20d%E2%80%99%C3%A9cran%20du%202021-06-01%2022-44-15

I hope it will help someone as you guys helped me for my first newbie PCB design!
Can’t wait to see next modules from Heltec!


HDC2080, Average at 1 measurement/second temperature only, just 0.3uA average current consumption while conversion is in progress.

It is expensive but much faster than HDC1080 and other sensors. That means your device can finish the sampling(conversion time) and back to sleep ASAP.

Configure the HDC2080 to sample temperature only and fewer digits (9-bit accuracy) will also decrease conversion time.

If the sampling period is much longer than 1min. I recommend power the sensor via Vext FET.
Use Wire.end() to terminate the I2C bus and Cutoff the Vext power between wakeup.

Hi @ksckung, I definitvely use this sensor for my new revision of my PCB. Thank you for the advice.

I actually doing test for battery autonomy. It seems that with or without Vext OFF & Wire.end in the code, my battery is drain at the same rate.
Same result when I send data every 15 seconds or every 30 minutes …

I use the AM02 arduino compatible reference design wich include TP4054 with a 18650 battery. I have a 555timer for pulse reading for an irrometer and an SHT31 both on Vext. The sampling time is verry quick, and I send Vbatt, the irrometer value, temperature, humidity on the payload.

I2C is also connected to Vext, I use the pins 24/25 of the module.
I place the sensors reading of the PrepareTx function based on the LoraWan example.
Do my module really enter in deep sleep or do I have a component that drain battery ?
It clearly needs more investigation…

In my case, using CubeCell – Dev-Board and HDC1080.

It is impossible to tell you module really enter in deep sleep or not without measurement.

Use a 1ohm or 0.1 ohm resistor in series with battery and connect it to CRO will help you a lot.
Like this:

First, start from normal LoraWan example with correct deepsleep. You should be able to get 3.5uA or close to 11uA like CubeCell – Dev-Board.

Next, Getbattery example
I may have issue too.


Next, connect the sensor, get the reading than sleep. Check the deepsleep current again. If the current is unexpect, check the current of sensor power, voltage of resistor( check current via that resistor) i.e.: I2C pullup. Vbat voltage divider.

Finally, send the value via Lora, same process.

Hi, I’m going to buy a small oscilloscope to mesure, it will take some days to come.
I only have a simple multimeter for now but maybe I could make some mesurements or changing some parts. (binocular&micropencil solder&hot air).

This is what I was able to make as circuit and handsoldering with the document based on HTCC-AM02_Reference_Design(Arduino).pdf
The circuit Heltec propose is different from the one on dev boards.

Real noob here, I try to understand electronics with this project by making a PCB and obviously some mistakes. Again thanks

2

To get Vbat on ADC, you need to pull low GPIO15 to turn on Q1 PMOS.

When the GPIO15 is low and Q1 turns on, the voltage on ADC will be equal to a voltage divider on a 220K+Ron+100k network.
When the GPIO15 is high and Q1 turns off, the voltage on ADC will be equal to a voltage divider on a 220K+ “ADC pin internal resistance” network.

Toggle GPIO15, measure and study it.
1)
Measure the voltage on the ADC pin by changing GPIO15.
2)
You can cut the ADC trace(copper) and measure the current drawn into the ADC pin.

Question: Is it match what you expect and calculation? Did the voltage within the ADC spec?

Please check the post I posted before and found the solution.

Hi there, I’m starting mesuring my PCB with the LoraWan simple example.
This is the code I put on the PrepareTxFrame function and on the setup.

/* Prepares the payload of the frame */
static void prepareTxFrame( uint8_t port )
{
digitalWrite(GPIO15, LOW);
delay(10000);
digitalWrite(GPIO15, HIGH);
delay(10000);
digitalWrite(GPIO15, LOW);
delay(10000);
digitalWrite(GPIO15, HIGH);
delay(10000);
digitalWrite(GPIO15, LOW);
delay(10000);
digitalWrite(GPIO15, HIGH);
delay(10000);
appDataSize = 4;
appData[0] = 0x00;
appData[1] = 0x01;
appData[2] = 0x02;
appData[3] = 0x03;
}
void setup() {
Serial.begin(115200);
pinMode(GPIO15, OUTPUT);
digitalWrite(GPIO15, HIGH);
#if(AT_SUPPORT)
enableAt();
#endif
deviceState = DEVICE_STATE_INIT;
LoRaWAN.ifskipjoin();
}

Results are for questions in 1 you propose :
GPIO15 HIGH : GPIO15=0V and ADC=3.7V (actually 3.9V at the battery)
GPIO15 LOW : GPIO15=1.6V and ADC=1.2V

For reading Battery I usaually use that I read on this forum.

uint16_t ADCvoltage = analogRead(ADC);
uint16_t BattV =0;
BattV = ADCvoltage*(220000+100000)/100000;

After reading the posts, it seems that resistor values was not adapted for deep sleep and you choose values to reduce consumption. Maybe I choose wrong values for the voltage divider (need to read electronics basics to!)
For the next step I will try to mesure current consumption in deep sleep with battery.
I need to cut the trace connected to ADC and mesure in Amp mode on the section?

Thank you!

Cutting the cooper trace between ADC pin from the module and Q1 and mesuring current indicate 1µA after the PrepareTXFrame (=in deep sleep).

Please make sure which condition is the ADC working by measure the voltage across the resistor(which means current flow through it).
It is no sense that you send digitalWrite(GPIO15, HIGH); but the output pin is 0V, right?

image
Also,Vth of PMOS is -1.3V max,Vbat 3.9V-1.3V=2.6V, GPIO15=1.6V is not high enough to turn off the PMOS, right?

In a normal voltage divider, 220K+100K, if the input voltage(battery voltage) is 3.9V, the output should be 3.9*100k/(220k+100k) =1.21V.
This means when the Q1 PMOS is on, ADC pin should be around 1.21V.

The 3.7V is over the ADC spec. , the current drive into the ADC pin should be much higher than 1uA.
https://heltec-automation-docs.readthedocs.io/en/latest/cubecell/frequently_asked_questions.html
image

Please check what happens when ADC pin following this connection.

For the program, maximum value of uint16_t is 2^16=65536. Did you think (220000+100000)/100000 is ok for this data type?

I retry mesurements and I was mesuring wrong pin ^^

When GPIO15 is low (0V), Fet is off and I have 1.2V on the source and drain pin. Battery reading seems good.
When GPIO15 is high(3.3V), Fet is on and I mesure 3.7V on the source and drain pin. Vext is off.

As you can see real noob here but all your adivces help me a lot.
For the program, maybe using float will be good.

The diagram you propose present ADC connected to D1 but on the one I’m using, ADC is connected to the source.

What’s the difference between both diagrams ?
I’m going to try to mesure total current consumption tonight and redo the code.
Why do I get 3.7V on ADC pin with a recommended design? Can it cause damage to the input Pin ?
Thanks again!

PMOS control logic is inverted.
When GPIO15 is low (0V), Vgs is 0V-Vbat=-3.9V, PMOS is ON
When GPIO15 is high(3.3V), Vgs is 3.3V-Vbat = 3.3-3.9=-0.6V, PMOS is OFF
By measuring the voltage on the 100k resistor to see is there any current flow through PMOS.

What’s the difference between both diagrams ?

The difference is ADC connects to different PMOS pin, S or D.

Why do I get 3.7V on ADC pin

ADC pin has an internal resistor to GND and protection diode to Vcc

with a recommended design? Can it cause damage to the input Pin ?

@jasonXu
As the Frequently Asked Questions said, ADC input voltage can NOT higher than 2.4V. It may cause damage.
I don’t know why they didn’t correct it, but you can see the recommendation on the same page**How to use the ADC pin for AnalogRead (ASR6501) **.