Site icon Renzo Mischianti

Issues with E22 Transmitters Reception

Dear Renzo, I am experiencing issues with my E22 communication network. The transmitters send encrypted structures to an E22 receiver every 10 seconds. Despite a distance of only 10 to 20 meters between the transmitters and the receiver, there seems to be a significant loss of data. Additionally, after 4 to 5 hours, the receiver stops receiving data, requiring unplugging and replugging for reset, as the reset button alone is inadequate. Could you help me identify the cause of these reception and data loss issues? Do you have any suggestions for improving the stability and reliability of the communication between the E22 transmitters and the receiver? Thank you in advance for your assistance. Best regards,

#define BLYNK_TEMPLATE_ID "xxxxx"
#define BLYNK_TEMPLATE_NAME "xxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxx"
#define DESTINATION_ADDH 0
#define DESTINATION_ADDL 3
#define DESTINATION_CHAN 40
#define DESTINATION_CRYPT_H xxx
#define DESTINATION_CRYPT_L xxx

#define BLYNK_PRINT Serial

#include "Arduino.h"
#include "LoRa_E22.h"
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <BlynkSimpleEsp32_SSL.h>

char ssid[] = "xxxx";
char pass[] = "xxxxx";

// ———- esp32 pins ————–
LoRa_E22 e22ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1

void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);

// definition de la task
/*void Task1code( void * parameter) {//task sur core 0
 for(;;) { }}*/

void setup() {
	Serial.begin(9600);
	delay(500);
	Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
	delay(2000);
// Startup all pins and UART
	e22ttl.begin();
//———————————————————————–Configuration de l’emetteur—————————-
	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
// It’s important get configuration pointer before all other operation
	Configuration configuration = *(Configuration*) c.data;
	Serial.println(c.status.getResponseDescription());
	Serial.println(c.status.code);

	printParameters(configuration);
	configuration.ADDL = 0x05;
	configuration.ADDH = 0x00;
	configuration.NETID = 0x00;

	configuration.CHAN = 40;

	configuration.SPED.uartBaudRate = UART_BPS_9600;
	configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
	configuration.SPED.uartParity = MODE_00_8N1;

	configuration.OPTION.subPacketSetting = SPS_240_00;
	configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED;
	configuration.OPTION.transmissionPower = POWER_10;

	configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
	configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
	configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED;
	configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
	configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_TRANSMITTER;
	configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	configuration.CRYPT.CRYPT_H = DESTINATION_CRYPT_H;
	configuration.CRYPT.CRYPT_L = DESTINATION_CRYPT_L;

	ResponseStatus rs = e22ttl.setConfiguration(configuration,
			WRITE_CFG_PWR_DWN_LOSE);
	Serial.println(rs.getResponseDescription());
	Serial.println(rs.code);

	c = e22ttl.getConfiguration();
	configuration = *(Configuration*) c.data;
	Serial.println(c.status.getResponseDescription());
	Serial.println(c.status.code);
	printParameters(configuration);

	c.close();

}

void loop() {
	Blynk.run();
// If something available
	if (e22ttl.available() > 1) {
// read the String message
		char type[8];

		ResponseContainer rs = e22ttl.receiveInitialMessage(sizeof(type));

		String typeStr = rs.data;
// Is something goes wrong print error
		if (rs.status.code != 1) {
			Serial.println(rs.status.getResponseDescription());
		} else {
			Serial.println(typeStr);
			if (typeStr == "CAPTEXT") {
				struct Message_Capt_EXT {
					char message[10] = "";
					byte temperature[8];
					byte pression[8];
				};

				ResponseStructContainer rsc = e22ttl.receiveMessage(
						sizeof(Message_Capt_EXT));
				struct Message_Capt_EXT message_capt_ext =
						*(Message_Capt_EXT*) rsc.data;
				Serial.println(message_capt_ext.message);
				Serial.print("temperature: ");
				Serial.println(*(float*) (message_capt_ext.temperature));
				Serial.print("Pression athmospherique: ");
				Serial.println(*(float*) (message_capt_ext.pression));
				rsc.close();
			} else if (typeStr == "CAPTINT") {
				struct Message_Capt_INT {
					char message[10] = "";
					byte temperature[8];
					byte humidity[8];
				};

				ResponseStructContainer rsc = e22ttl.receiveMessage(
						sizeof(Message_Capt_INT));
				struct Message_Capt_INT message_capt_int =
						*(Message_Capt_INT*) rsc.data;
				Serial.println(message_capt_int.message);
				Serial.print("temperature: ");
				Serial.println(*(float*) (message_capt_int.temperature));
				Serial.print("Humidite: ");
				Serial.println(*(float*) (message_capt_int.humidity));
				Blynk.virtualWrite(V2,
						*(float*) (message_capt_int.temperature));
				Blynk.virtualWrite(V3, *(float*) (message_capt_int.humidity));
				rsc.close();
			} else if (typeStr == "CAPTIN1") {
				struct Message_Capt_INT1 {
					char message[10] = "";
					byte temperature[8];
				};

				ResponseStructContainer rsc = e22ttl.receiveMessage(
						sizeof(Message_Capt_INT1));
				struct Message_Capt_INT1 message_capt_int1 =
						*(Message_Capt_INT1*) rsc.data;
				Serial.println(message_capt_int1.message);
				Serial.print("temperature: ");
				Serial.println(*(float*) (message_capt_int1.temperature));
				Blynk.virtualWrite(V1,
						*(float*) (message_capt_int1.temperature));
				rsc.close();
			} else if (typeStr == "CAPTIN2") {
				struct Message_Capt_INT {
					char message[10] = "";
					byte temperature[8];
					byte humidity[8];
				};

				ResponseStructContainer rsc = e22ttl.receiveMessage(
						sizeof(Message_Capt_INT));
				struct Message_Capt_INT message_capt_int =
						*(Message_Capt_INT*) rsc.data;
				Serial.println(message_capt_int.message);
				Serial.print("temperature: ");
				Serial.println(*(float*) (message_capt_int.temperature));
				Serial.print("Humidite: ");
				Serial.println(*(float*) (message_capt_int.humidity));
				Blynk.virtualWrite(V4,
						*(float*) (message_capt_int.temperature));
				Blynk.virtualWrite(V5, *(float*) (message_capt_int.humidity));
				rsc.close();
			}

			else {
				Serial.println("Something goes wrong!!");
			}
		}
	}
}

void printParameters(struct Configuration configuration) {
	Serial.println("—————————————-");

	Serial.print(F("HEAD : "));
	Serial.print(configuration.COMMAND, HEX);
	Serial.print(" ");
	Serial.print(configuration.STARTING_ADDRESS, HEX);
	Serial.print(" ");
	Serial.println(configuration.LENGHT, HEX);
	Serial.println(F(" "));
	Serial.print(F("AddH : "));
	Serial.println(configuration.ADDH, HEX);
	Serial.print(F("AddL : "));
	Serial.println(configuration.ADDL, HEX);
	Serial.print(F("NetID : "));
	Serial.println(configuration.NETID, HEX);
	Serial.print(F("CRYPT_H : "));
	Serial.println(configuration.CRYPT.CRYPT_H, HEX);
	Serial.print(F("CRYPT_L : "));
	Serial.println(configuration.CRYPT.CRYPT_H, HEX);
	Serial.println(F(" "));
	Serial.print(F("Chan : "));
	Serial.print(configuration.CHAN, DEC);
	Serial.print(" -> ");
	Serial.println(configuration.getChannelDescription());
	Serial.println(F(" "));
	Serial.print(F("SpeedParityBit : "));
	Serial.print(configuration.SPED.uartParity, BIN);
	Serial.print(" -> ");
	Serial.println(configuration.SPED.getUARTParityDescription());
	Serial.print(F("SpeedUARTDatte : "));
	Serial.print(configuration.SPED.uartBaudRate, BIN);
	Serial.print(" -> ");
	Serial.println(configuration.SPED.getUARTBaudRateDescription());
	Serial.print(F("SpeedAirDataRate : "));
	Serial.print(configuration.SPED.airDataRate, BIN);
	Serial.print(" -> ");
	Serial.println(configuration.SPED.getAirDataRateDescription());
	Serial.println(F(" "));
	Serial.print(F("OptionSubPacketSett: "));
	Serial.print(configuration.OPTION.subPacketSetting, BIN);
	Serial.print(" -> ");
	Serial.println(configuration.OPTION.getSubPacketSetting());
	Serial.print(F("OptionTranPower : "));
	Serial.print(configuration.OPTION.transmissionPower, BIN);
	Serial.print(" -> ");
	Serial.println(configuration.OPTION.getTransmissionPowerDescription());
	Serial.print(F("OptionRSSIAmbientNo: "));
	Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);
	Serial.print(" -> ");
	Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
	Serial.println(F(" "));
	Serial.print(F("TransModeWORPeriod : "));
	Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);
	Serial.print(" -> ");
	Serial.println(
			configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
	Serial.print(F("TransModeTransContr: "));
	Serial.print(configuration.TRANSMISSION_MODE.WORTransceiverControl, BIN);
	Serial.print(" -> ");
	Serial.println(
			configuration.TRANSMISSION_MODE.getWORTransceiverControlDescription());
	Serial.print(F("TransModeEnableLBT : "));
	Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);
	Serial.print(" -> ");
	Serial.println(
			configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
	Serial.print(F("TransModeEnableRSSI: "));
	Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);
	Serial.print(" -> ");
	Serial.println(
			configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
	Serial.print(F("TransModeEnabRepeat: "));
	Serial.print(configuration.TRANSMISSION_MODE.enableRepeater, BIN);
	Serial.print(" -> ");
	Serial.println(
			configuration.TRANSMISSION_MODE.getRepeaterModeEnableByteDescription());
	Serial.print(F("TransModeFixedTrans: "));
	Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);
	Serial.print(" -> ");
	Serial.println(
			configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());

	Serial.println("—————————————-");
}
Exit mobile version