Hello I got problem with my project. Got arduino mega with E32 module and esp01 module connected, after startup program is connecting to wifi and to blynk server and after that should connect to lora e32 and receive data. Without esp and blynk in code e32 is receiving data without problem. Is there problem with multiple software serial? Any ideas? Thanks!
#include <string.h>
#include "Arduino.h"
#include "LoRa_E32.h"
#define FREQUENCY_868
LoRa_E32 e32ttl100(52, 53); //TX ,RX
//Activates communication between the Blynk App and Serial Monitor:
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
//Authentication of account in the Blynk app.
char auth[] = "auth"; //Enter the device's auth token code.
//Enter the WiFi credentials.
char ssid[] = "ssid";//Name of the Wi-Fi network.
char pass[] = "pass"; //Wi-Fi network password.
char hostid[] = "ip";
int port = 8080;
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(50, 51); // RX, TX
// ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
WidgetLCD lcd0(V0);
WidgetLCD lcd1(V1);
void setup() {
Serial.begin(9600);
delay(500);
Serial.println("Receiving!");
// Startup all pins and UART
e32ttl100.begin();
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass, hostid, port);
lcd0.clear();
lcd1.clear();
}
void loop() {
Blynk.run();
// If something available
if (e32ttl100.available() > 1) {
// read the String message
ResponseContainer rc = e32ttl100.receiveMessage();
// Is something goes wrong print error
if (rc.status.code != 1) {
rc.status.getResponseDescription();
} else {
// Print the data received
char str_array[rc.data.length()];
rc.data.toCharArray(str_array, rc.data.length());
char * token = strtok(str_array, " ");
Serial.print("Weight = ");
Serial.print(token);
Serial.println(" kg");
lcd0.print(0,0, token);
token = strtok(NULL, " ");
Serial.print("Voltage= ");
Serial.print(token);
Serial.println(" V");
lcd1.print(0,0, token);
}
}
if (Serial.available()) {
String input = Serial.readString();
e32ttl100.sendMessage(input);
}
}
