Hi everyone
Please i want to connect Heltec wifi LoRa 32 v2 sx1276 with Arduino Mega to transfer MQ5 gas sensor data via LoRa to another mega board with LoRa connected.
what pin connections should i use?
what code should i use?
since i tried many codes and connections but no one operate correctly, i don't know where is the mistake, the pin connections or the code.
Best Regards
ditch the mega and connect you gas sensor directly to the Heltec32 then you have no communication to deal with...
if not you need to decide:
- what communication link you want to use (Serial, I2C, SPI for example)
- how to adjust voltage between a 3.3V and 5V MCU
- what's the protocol to exchange data
MQ5 gas sensor uses an analogue output - interface it directly to the ESP32?
Edit: the MQ5 requires 5V power so its ADC output will require a potential divider for input to the ESP32
But can I connect (MQ5 gas sensor + flame sensor + neo-6M GPS module + SD card + Ethernet Shield) to one Heltec wifi LoRa 32 v2 sx1276?
Since I am tending to design a system containing two nodes that transmit data to third base station node, all with Heltec wifi LoRa 32 v2 sx1276 .
can the Heltec wifi LoRa 32 v2 sx1276 accept large program?
you have a lot of IO connected to the Mega - porting it to Heltec may be a problem
to connect the Mega to the Heltec I suggest using serial
the Mega has three spare hardware serial ports (unless you are already using them) and the ESP32 supports hardware serial
the Mega uses 5V logic and the ESP32 3.3V therefore you will require a potential divider on the Mega Tx to ESP32 Rx signal
looking at the Heltec pinout I think GPIO12 and GPIO13 are free (Serial2 works OK on my Node32 board using pins 12 and 13), e.g.
// ESP32 serial2 hardware loop back test - jumper GPIO12 (Rx) and GPIO13 (Tx)
// see https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/
/* There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD.
*
* U0UXD is used to communicate with the ESP32 for programming and during reset/boot.
* U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though
* U2UXD is unused and can be used for your projects.
*/
#define RXD2 12
#define TXD2 13
void setup() {
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
Serial.begin(115200);
delay(1000);
Serial.println();
//Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.println("Serial Txd is on pin: "+String(TX));
Serial.println("Serial Rxd is on pin: "+String(RX));
Serial.println("Serial Txd is on pin: "+String(TXD2));
Serial.println("Serial Rxd is on pin: "+String(RXD2));
}
void loop() { //Choose Serial1 or Serial2 as required
while (Serial2.available()) {
Serial.print(char(Serial2.read()));
}
while (Serial.available()) {
Serial2.print(char(Serial.read()));
}
}
if I jumper 12 and 13 I get
Serial Txd is on pin: 1
Serial Rxd is on pin: 3
Serial Txd is on pin: 13
Serial Rxd is on pin: 12
⸮testing sending data
test2
test 3
I suggest trying the above program and linking GPIO 12 and 13 - what you enter should be echoed back
Have you compared the specs of both boards?
Mega:
FLASH MEMORY 256 KB
SRAM 8 KB
CLOCK SPEED 16 MHz
Heltec wifi LoRa 32:
CPU: ESP32. 240 MHz dual core
Flash: 4MB
520 KB of SRAM
Pretty close-run thing? No.
I would also recommend removing the Mega and connecting everything to the Heltec board. Please post links to all devices you want to connect for further advice.
Why would you want to connect Ethernet to a board with built-in WiFi?
I think we require a specification of what devices are to be connected, interfaces used, power requirements, etc
is this the device used and this WIFI_LoRa_32_V2.pdf the pinout?
Yes Dear, it is the same device, but now I'm going to replace it with:
LoRa Long-Distance 433MHz Communication SX1278 with Antenna
wishing that it works.
can you give a web page link to the device? there are many Lora boards which fit that description
SX1278 based Lora device interface protocol SPI - if you do a web search for arduino SX1278 you will get plenty of links
so you think that it will work correctly Sir?
you could connect your Lora module to the SPI bus of your MEGA and use one of the Lora SPI library to drive it
for example here is a first google hit when looking for one
Compatible Hardware
- Semtech SX1276/77/78/79 based boards including:
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.