Introduction: Introduction to ESP32 WiFi LoRa
Let's go to the second video of our "Introduction" playlist. This time, we’ll talk about the "ESP32 WiFi LoRa." This one is very special because it has 3 wireless features: Bluetooth 4.2, WiFi 802.11, and the LoRa, which is a type of network with the reach of 3.6 km through a simple antenna. All of this can be used at the same time, which makes it magnificent. We will then introduce the Heltec WiFi LoRa 32, using the Arduino IDE, and then we’ll present a practical example to perform a digital reading and digital performance.
Step 1: Resources Used
1 Heltec WiFi LoRa 32
1 push-button type switch
1 10k ohm resistor
1 relay module
1 Protoboard
Step 2: What Exactly Is the Heltec WiFi LoRa 32?
It is a development board that integrates a SoC ESP32-D0WDQ6.
It has a W25Q32FV Serial Flash Memory (SPI / QPI) chip with approximately 32 megabits (4 megabytes) of storage.
A SX1278 LoRa chip is controlled by ESP32.
The USB-Serial interface uses a CP2102 from Silicon Labs.
In addition to an MCP73831 / 2, it comes with a Lithium Ion (Li-Ion) or Lithium Polymer (Li-Po) battery charge controller.
And it features a regulator AP2112-3.3 to provide 3.3V and a minimum of 600mA.
The board has two crystals, one from 26MHz to the ESP32, and another from 32MHz to the SX1278.
It has a 0.96" OLED display, also controlled by the ESP32.
Step 3: Wiring Diagram of the Heltec WiFi LoRa 32
This same wiring diagram serves both the Heltec chip and the TTGO.
Step 4: Pinout of Heltec WiFi LoRa 32 Card
I point out that if you take the traditional ESP32, unlike this image, it will not have the display and the SX1278, which is the Semtech chip.
Step 5: TTGO X Heltec
Step 6: Circuit
In this circuit, we will detect the push of a button through the GPIO34 (pin 34 of the board), and we will drive the relays of the module through the GPIO22 and 23 (pins 22 and 23), respectively.
Step 7: Plate Installation
To install the board, we can follow the instructions of the Heltec itself in its GIT.
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/InstallGuide/windows.md
Step 8: Source Code
Statements
When you're referring to the ESP32 pin, what matters is the GPIO. In this step, therefore, we point out that the pin that is connected to the button, as well as the ones that are connected in the relay module. We also have the variable to store the state of the second relay.
//Pino ligado no botão
int btn1 = 34; //Pinos que são ligados no módulo de relés int rele1 = 22; int rele2 = 23; //variável para guardar o estado do segundo relé boolean rele2_Ativo = false;
Setup ()
The setup () function must be run once before the loop. We set the pins of the buttons as input, relays as output, and we open the serial port, setting the data rate to 9600 bps.
//A função setup() é executada uma vez antes do loop
void setup() { //Seta os pinos dos botões como entrada pinMode(btn1, INPUT); //Seta os pinos dos relés como saída pinMode(rele1, OUTPUT); pinMode(rele2, OUTPUT); //Abre a porta serial, definindo a taxa de dados para 9600 bps Serial.begin(9600); }
Loop ()
As for the loop () function, it executes after setup and is repeated continuously. Check if the button was pressed and, if so, we will print this status on the screen. We then turn on relay 1, invert the state of variable relay2_Active, and then we change the state of relay 2. We wait for 1 second and turn off relay 1.
//A função loop() é executada após o setup e é repetida continuamente
void loop() { if (digitalRead(btn1) == HIGH) //Caso o botão 1 foi pressionado { //Exibe no monitor serial a mensagem entre aspas Serial.println("Botão pressionado"); //Ligamos o relé 1 digitalWrite(rele1, HIGH); //Invertemos o estado da variável rele2_Ativo rele2_Ativo = !rele2_Ativo; //Mudamos o estado do relé 2 digitalWrite(rele2, rele2_Ativo ); //Aguardamos 1 segundo (1000 ms) delay(1000); //Desligamos o relé 1 digitalWrite(rele1, LOW); } }
Step 9: Doing the UpLoad of Code
With the IDE open, open the file with the source code by double-clicking the .ino file or through the File menu.
With Heltec connected to USB, select the menu Tools => Card: "Heltec_WIFI_LoRa_32"
Still in the Tools menu, select the COM port on which the Heltec is connected.
Click the UPLOAD button...
... And wait for the conclusion:
Step 10: Verifying Execution
After recording, we check the execution, click the button to open the Serial Monitor, and then we set the baud rate to 9600.
Press the button, in addition to activating the relays. The following message should appear on the Serial Monitor.
6 Comments
Question 1 year ago
Hi, Fernando
Is it possible to work simultaneously WiFi and LoRa on HELTEC esp32 LoRa?
The idea is to receive data from the weather station via LoRa and load it into a My WEB-page via WiFi ?!
Thanks in advance!
Answer 4 months ago
He says at the top of this article that it can support Bluetooth, wifi, and LoRa at the same time. But he doesn't seem to be responding here, and I'm looking for the same thing. Would love to know if you found the answer.
Reply 4 months ago
Hi,
I haven't found it yet, but that's on the back burner for now!
7 months ago
Hello
I
am very interested but my first tests showed me that I could not go
down less than 10mA in deep-sleep, do you have this type of problem
please?
Question 2 years ago on Step 3
Is there a better resolution photo of the Charging circuit -- wonder what the supply voltage limits are?
-- Can I use a 9V Alkaline battery?
-- Does the charge circuit accept a 3.4-3.7 V Lithium single cell?
-- Can I use a 3.6 V Lithium Primary cell that only has a maximum discharge of 0.020 Amps?
Answer 2 years ago
1) All of the schematics and files are in Github in the link above
2) To use a 9V battery you will need to regulate it down to 5V. Although the on board regulator TP4054 can handle 9V, the CP2102 is connected to the 5V bus and will be fried with a direct 9V connection.
3) The charging circuit will work with any standard 3.7V lithium battery.
4) No, the board needs up to 130 mA while transmitting. That puny 20 mA battery will not work.