AM02 Module Plus - Custom PCB - Minimal circuit arduino compatible

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) **.

Thank you for your response.
So by design, when GPIO15 is LOW, V(ADC)= with my battery 3.7V to 4.2V. I don’t understand with a circuit is propose knowing that ADC can’t support more than 2.4V. What kind of damages can it cause? Maybe more power consumption?

I really want to be sure for my next PCB design and be sure that any mistake is done with the recommended manufacturer design.
I also need to use one capacitive sensor with GPIO as output and ADC and on the Arduino example the simplest way to wire the sensor is to use GPIO as output and ADC for reading. With the 2.4V limitation, how can I use this one? http://community.heltec.cn/t/cubecell-and-second-serial-port/693/9
Thank you to both of you
@ksckung @jasonXu

What kind of damages can it cause? Maybe more power consumption?

No one knows. In my test, it shows 17uA more(153%) when the battery voltage at 4.2V.
I recommend modify the circuit, measure, and share the result before next PCB design.

The IO voltage of AM02 is 3.3V but Arduino is 5V.
The ADC input voltage is limited to 2.4V with 1.2V reference but Arduino is both 5V.

First, you need to test it work/not under AM02 3.3V GPIO output.
Then check the voltage range of sensor analog output.
If it is out of range, use opamp to buffer and attenuate the signal.

At least, I know how a voltage divider is used! I am disappointed to use the HTCC-AM02 wich is pretty sexy for low power and 3xADC pins.
I’ll try to test my sensor with GPIO as input, maybe it will be a success.


For now, I made a circuit with another circuit with a 555timer. It seems that reading the sensor resistance is more reliable instad the frequency reading and need less conversion to get the value. Too bad … Opamp is also a new domain for me, hard to start from scratch.
I hope that Heltec can improve the ADC input voltage to a more usable one >2.4V (like Arduino’s) on the next modules they produce. Maybe they will tease a date or specifications !
Again @ksckung @jasonXu thank for your help!

@ksckung
I mesure yesterday, it seems that I have 17µA consumption with a 3.8V battery.
Maybe I should try to replace resistors on ADC channels with 10K as you propose here and mesure again.
http://community.heltec.cn/t/power-consumption-in-sleep-mode-vbat-battery-powered/2889/5?u=alexfr

For my sensor, I find a device that I want to design on the PCB. No idead what’s in the black box!
https://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf
https://www.irrometer.com/pdf/sensors/405%20Voltage%20Adapter%20&%20Isolator-WEB.pdf
https://www.emesystems.com/smx/documents/SMX_2018.pdf
They said in the doc

ELECTRICAL:3.2 - 30 volt, 1.5 mA input, polarity protected / 0 - 2.8 volt output, linear / 0 - 239 cb (kPa) = 0 to 2.8 volts linear. "

I will post news if my power consumption goes to 17µA to less.
Take care.

I didn’t have AM02, please check and test the Voltage vs raw reading first.
In CubeCell – Dev-Board ,I use 100k +NMOS+100k and connect ADC pin to the Drain of NMOS
image

The Sleep current is around 6.322uA with 3.7V power supply.
SCREEN_111

Here is the voltage on ADC pin when the program turn on the PMOS, Battery voltage is ~4.16V

Hello Sir,
based on your last schematic, I replace R16 & R17 with 100K resistor.
I disconnect ADC from source to connect it to the drain’s Fet. Still getting around 16µA in deepsleep but getting 1.96V in the ADC with a 3.9V battery. :slight_smile:
I don’t try to reach the 3.5µA on 3.3V power because my device only runs on battery.
I think it’s a good confirguration for my next PCB!

Before (based on the Heltec recommanded design):

After (based on @ksckung design):

@AlexFR
6.322uA with 3.7V is power via battery port.

Hello @ksckung,
I am using the HDC2080 but I encounter problem to running the example test of the library
HDC2080 lib

  • In fact I am using the second I²C on the HTCC-AM02 (pins 24&25)
  • Vext is controlling the HDC2080 as you recommand.
    This is the example Arduino example
    I think the example use the first I²C bus by defaut.

How can I simply declare to use Wire.begin(1000000,1); and Wire.end ?

Thank you
Alex

I succesfully find the adress of the HDC2080 with this example based on the “I2C_scan” from Heltec. =0x40

#include “Arduino.h”
#include “Wire.h”
void setup()
{
Serial.begin(115200);
Wire.begin(1000000,1);
pinMode(GPIO5,OUTPUT);
digitalWrite(GPIO5,LOW);//set GPIO5 to high
}
void loop()
{
byte error, address;
int nDevices;
Serial.println(“Scanning…”);
nDevices = 0;
for(address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print(“I2C device found at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print(“Unknown error at address 0x”);
if (address<16)
Serial.print(“0”);
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println(“No I2C devices found\n”);
else
Serial.println(“done\n”);
delay(5000);
}

And response in the console

Scanning…
I2C device found at address 0x40 !
done

The pins 24 and 25 of AM02 are the second group of IIC. You can use Wire.begin(GPIO9,GPIO8) or Wire1.begin() to enable the second group of IIC.

Hello @shaffer, I just solved my problem.
I edited the library for the sensor HDC2080 https://github.com/tinkeringtech/HDC2080_breakout
I just edited the hdc2080.cpp file at line 44.

void HDC2080::begin(void)
{
Wire.begin();
}

became

void HDC2080::begin(void)
{
Wire.begin(SDA1,SCL1,500000);
}

It use now the pins GPIO8,GPIO9 as you know.
Thanks for your help!