Site icon Renzo Mischianti

Arduino iot 33 & AS32-TTL-100

Hello. I would like to connect an Arduino IoT with AS32-TTL-100 but there are no drivers. It works partially with driver for LORA E32 on this page. I really don’t know if this driver can be used or I connected the hw incorrectly. The manual does not describe the use of PullUP & Voltage divider resistors, but it doesn’t matter if they are there or not, it does not work. IoT does not have SoftwareSerial or HardwareSerial I used Serial1. Can anyone advise me how to do this? well thank you

Exit the program:

Sleep mode
Reset= OK
Info= AS32-TTL100-V2.0
Soft v.= 32T20-O32M-V4.01
Handsh= OK
Napatie= 3.19Volts
Konf= 0xC0 ,0xFF ,0xFF ,0x1A ,0x8 ,0xC0 ,
RSSI a= ERROR
RSSI g= ERROR
******* OK ********
RSSI aktu= ERROR
RSSI glob= ERROR
RSSI aktu= ERROR
RSSI glob= ERROR
RSSI aktu= ERROR
RSSI glob= ERROR
RSSI aktu= ERROR
Program :

/* Test na RSSI */

byte AUX_PIN = 2;
byte M0_PIN = 3;
byte M1_PIN = 4;
enum MODE_TYPE {
	MODE_0_NORMAL = 0, MODE_1_WAKE_UP, MODE_2_POWER_SAVIN, MODE_3_SLEEP = 0xFF
};

void setup() {
	Serial.begin(9600);
	Serial1.begin(9600);
	while (!Serial) {
	}
	delay(100);
	pinMode(7, OUTPUT);
	pinMode(6, OUTPUT);
	SwitchMode(MODE_3_SLEEP);
	triple_cmd(0xC3); // nazov, verzia
	Serial.print("Info= ");
	Module_info(1);
	triple_cmd(0xF3); // nazov, verzia
	Serial.print("Soft v.= ");
	Module_info(1);
	triple_cmd(0xE1); // nazov, verzia
	Serial.print("Handsh= ");
	Module_info(1);
	triple_cmd(0xC5); //VH a VL sú údaje o napätí. Napríklad modul vráti C5 0C 1C, prevedie 0C 1C na desatinné miesto a získa hodnotu 3100, čo naznačuje, žeprúdové napätie modulu je 3,1V.
	Serial.print("Napatie= ");
	Module_info(2);
	triple_cmd(0xC1); // Modul vráti súčasné konfiguračné parametre vhexadecimálny formát
	Serial.print("Konf= ");
	Module_info(3);
	sixple_cmd(0xAF, 0xAF, 0x73, 0x00, 0xAF, 0xF3); //aktualny
	Serial.print("RSSI a= ");
	Module_info(1);
	sixple_cmd(0xAF, 0xAF, 0x74, 0x00, 0xAF, 0xF4); //global
	Serial.print("RSSI g= ");
	Module_info(1);
//SwitchMode(MODE_0_NORMAL);
	Serial.println("******* OK ********");
}

void loop() {
	sixple_cmd(0xAF, 0xAF, 0x74, 0x00, 0xAF, 0xF4); //global
	Serial.print("RSSI g= ");
	Module_info(1);
	delay(500);
}
//—————————————————-
void triple_cmd(byte Tcmd) {
	uint8_t CMD[3] = { Tcmd, Tcmd, Tcmd };
	Serial1.write(CMD, 3);
	delay(50); //need ti check
}
void sixple_cmd(byte a, byte b, byte c, byte d, byte e, byte f) {
	uint8_t CMD[6] = { }; //globalny
	Serial1.write(CMD, 6);
	delay(50); //need ti check
}

void cleanUARTBuf() {
	bool IsNull = true;
	while (Serial1.available()) {
		Serial1.read();
	}
}
void Module_info(int typeStr) {
	uint8_t Readcnt, idx;
	Readcnt = Serial1.available();
	if (Readcnt > 0) {
		if (typeStr == 1) {
			String input = Serial1.readString();
			Serial.print(input);
		} else if (typeStr == 2) {
			int inx = 0;
			byte incomingByte[2];
			while (Serial1.available()) {
				incomingByte[inx++] = Serial1.read();
//Serial.print(", 0x");Serial.print(incomingByte[inx-1],HEX);
			}
			Serial.print(
					(float) ((incomingByte[1] << 8) | incomingByte[2]) / 1000);
			Serial.print("Volts");
			Serial.println();
		} else {
			while (Serial1.available()) {
				byte incoming = Serial1.read();
				Serial.print("0x");
				Serial.print(incoming, HEX);
				Serial.print(" ,");
			}
			Serial.println("");
		}
	} else {
		Serial.print(" nemam data ");
		cleanUARTBuf();
	}
}
void SwitchMode(MODE_TYPE mode) {
	WaitAUX_H();

	switch (mode) {
	case MODE_0_NORMAL:
// Mode 0 | normal operation
		digitalWrite(M0_PIN, LOW);
		digitalWrite(M1_PIN, LOW);
		Serial.println("General working mode");
		break;
	case MODE_1_WAKE_UP:
		digitalWrite(M0_PIN, HIGH);
		digitalWrite(M1_PIN, LOW);
		Serial.println("Wake up mode");
		break;
	case MODE_2_POWER_SAVIN:
		digitalWrite(M0_PIN, LOW);
		digitalWrite(M1_PIN, HIGH);
		Serial.println("Power saving mode");
		break;
	case MODE_3_SLEEP:
// Mode 3 | Setting operation
		digitalWrite(M0_PIN, HIGH);
		digitalWrite(M1_PIN, HIGH);
		Serial.println("Sleep mode");
		break;
	default:
		return;
	}

	WaitAUX_H();
	delay(10);
}

void WaitAUX_H() {
	while ((digitalRead(AUX_PIN) == LOW)) {
		Serial.print(".");
		delay(100);
	}
}
Exit mobile version