Skip to content

Example code and description how to use ESP32 low noise amplifier (LNA), including Arduino library and ESP-IDF component

License

Notifications You must be signed in to change notification settings

krzychb/esp32-lna

Repository files navigation

ESP32 LNA

One of features of ESP32 that has been intriguing me since its release back in September 2016 was low noise amplifier (LNA).

Together with other analog components like Hall sensor, temperature sensor, capacitive touch sensor, cosine waveform generator, as well as ordinary ADC and DAC, they offer interesting functionality options right on a bare chip, without additional components.

The Story

When I learned about the LNA for the first time I immediately recalled a workshop by Cypress where I got familiar with programmable system-on-chip (PSoC) microcontrollers that provide similar functionality, but on far larger scale. Is Espressif going to offer a marriage of digital and programmable analog functionality on a single chip? That would be awesome!

Some time later, in May 2017, the LNA has been officially documented in ESP32 Technical Reference Manual.

Then one year later, in June 2018, description of the LNA (and temperature sensor) has been removed from the reference manual and other official documentation. Performance of these components was not satisfactory and Espressif decided to remove LNA from specification rather than keep it and risk having disappointed customers.

Is it end of the story? Hopefully not. The LNA still sits inside the ESP32 chip and it is up to us to bring it back to existence and check how bad (or good) it is.

What do we do next?

The purpose of this repository is to show how to characterize LNA for a ESP32 chip. Anybody interested can then check LNA on their own and decide if it may be useful for a specific application.

But mind your step

If you are planning to develop a product, then you may need to check a larger batch of chips if LNA performance is repeatable and adequate for your product. Please also note that since LNA does not exist in Espressif documentation, there is no any guarantee it will perform the same on a next batch of chips you procure. There is even no guarantee that LNA will be there at all. We can only assume that Espressif will not bother disabling LNA during next tapeout. I would also not count on getting a PCN on such change.

Now let's get started

After this rough introduction we are ready to get started. Stay with me. It should be fun like trying a forbidden fruit :)

Contents

What is this LNA?

According to original technical reference manual, ESP32 integrates an analog amplifier designed to amplify a small DC signal that is then passed on to SAR ADC1 for sampling. The amplification gain is adjustable with two off-chip capacitors.

alt text

For more details on how LNA works, please refer to Section LNA Operation.

Get Started with LNA

You are a step ahead to get started with ESP32 and LNA and this section will show you how.

What your need?

  • ESP32 development board with sampling capacitors.
  • Computer configured and tested to work with ESP-IDF.
  • A thermocouple or another source of a small DC signal (in mV range).
  • LNA example code from esp32-lna repository.

Please see a separate section with list and description of components that will be useful testing the LNA.

Connect the components

alt text

Check how LNA works

Two example applications are provided. One for Arduino and the other one for ESP-IDF platform. Both examples provide identical functionality showing temperature measured by a thermocouple connected to the LNA inputs of ESP32.

Next two examples are quite similar but provide measurement of ambient temperature using additional temperature sensor and perform cold junction temperature compensation.

Example output:

...
I (0) cpu_start: Starting scheduler on APP CPU.
ADC: 10 bit, Attenuation: (0)
Initializing LNA...done
Thermocouple: -1.217 mV, -1 oC, Cold junction temperature: 29 oC, ADC raw count: 393
Thermocouple: -1.174 mV, 0 oC, Cold junction temperature: 29 oC, ADC raw count: 399
Thermocouple: -1.196 mV, -0 oC, Cold junction temperature: 29 oC, ADC raw count: 396
Thermocouple: -1.203 mV, -0 oC, Cold junction temperature: 29 oC, ADC raw count: 395
...

Get more out of LNA

You may want to use LNA with a voltage source other that a thermocuple. To do so, first characterize the LNA with this particular voltage source. There are two examples provided specifically for this purpose, one for Arduino and one for ESP-IDF. They provide identical functionality showing LNA output in function of Stage 1 and Stage 3 cycles (discussed in LNA Operation).

Check Section Characterize LNA for specific instructions.

Libraries

All examples in this repository use the same library code:

Compatibility

Code provided in this repository has been developed using master branch of arduino-esp32 and ESP-IDF framework as of August 2019.

If you are not familiar with these frameworks, before starting with LNA, please follow some guides:

Contribute

Feel free to contribute to the project in any way you like!

If you find any issues with code or description please report them using Issues tab above.

Credits

This repository has been prepared thanks to great work of the following teams and individuals:

  • John Lee who designed LNA. Let's hope an updated version of the LNA will be carried over to the next ESP32-SX chip.
  • Michael who developed and tested original code to operate LNA and then was kind and brave enough to write it down on a back of envelope, and pass to me, so we have some fun testing this nice peripheral.
  • Espressif team that develops and maintains esp-idf repository
  • UncleRus who provides well maintained collections of driver components for ESP32 under https://github.com/UncleRus/esp-idf-lib. I took DHT library from there. Sure enough it worked out of box.
  • winlin who provides simple and trouble-free SimpleDHT Arduino library to read DHT temperature sensors (including AMS2302) connected to ESP32. Some other libraries I tried just did not work or had too complicated or sophisticated examples as for a demo code.

License

Apache License Version 2.0, January 2004

About

Example code and description how to use ESP32 low noise amplifier (LNA), including Arduino library and ESP-IDF component

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published