Made an attempt to write a messenger for Arduboy … used Lora e32 ttl transceivers. Messaging is working. Connecting modules via Serial1 to pins 0, 1. If someone uses a homemade arduboy, then this is the easiest way to connect the Lora_e32 module to Serial1. Everything should be intuitive. The messenger will eventually acquire additional functionality using the FX chip. This is the first working version of the AGLM messenger so far.
Start in this topic https://community.arduboy.com/t/improved-horizontal-version-of-arduboy-fx/10324/80
implemented the correct display of screens when entering and exiting windows, added input and scanning of nicknames when going to the BROscan window, you must press the right button and wait a bit to display accepted nicknames from other arduboys, then you can select the desired nickname and send him a message (this function is still in development )
everything else works and can be used. connection of lora_e32 433t20d module to arduboy is as follows:
LoRa_E32 Lora(1, 0, 9, 11, 10); //rx-tx, AUX and M0 M1
AGLM_TEST_11_02052023.hex (57.7 KB)
Hello everyone! I created two important functions that will set the default address and channel settings in Lora, as well as set the settings for transmitting/receiving over the address channel when creating a pair:
//function for restoring the initial configuration of the modes of transmission/reception of messages over a common channel
void setDefaultConfiguration() {
lora.resetModule(); //reset lore
//set the state of contacts M0 and M1 to MODE3
pinsLoraHAIG();
delay(500);
// After setting the configuration comment, set the values of M0 and M1 to low
// and reboot if you directly set the high values of M0 and M1 for programming
ResponseStructContainer c;
c = Lora.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
Serial1.println(c.status.getResponseDescription()); //if you need the output of the specified parameters in Serail
Serial1.println(c.status.code);
configuration.ADDL=0x01; //set default address values
configuration.ADDH=0x00; //set default address values
configuration.CHAN = 0x17; //0x17// frequency=23+410=433MHz
//data transmission will be carried out in fixed transmission mode, in which the main device is located
//commands and data are transmitted to the slave device, and the slave device simply listens and transmits data in response.
configuration.PARAMETER.Fixed transmission = T_TRANSPARENT_TRANSMISSION;
/*
configuration.PARAMETER.fec = FEC_0_OFF;
// transparent transmission mode, in which the slave device independently transmits data to the master device when possible
//configuration.PARAMETER.Fixed transmission = FT_TRANSPARENT_TRANSMISSION;
configuration.PARAMETER.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.Transmission power = POWER_17;
configuration.PARAMETER.Wireless wake-up time = WAKE_UP_1250;
configuration.SPEED.airDataRate = AIR_DATA_RATE_011_48;
configuration.speed.uartBaudRate = UART_BPS_115200;
configuration.SPED.uartParity = MODE_00_8N1;
*/
ResponseStatus rs = Lora.SetConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); //important, settings are saved when the power is turned off!!!
//ResponseStatus rs = Lora.SetConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE); //settings are lost when the power is turned off
Serial1.println(rs.getResponseDescription());
Serial1.println(rs.code);
//printParameters(configuration);
c.close();
while ( !digitalRead(pinAUX)); //wait until Lora is ready
//restore the state of contacts M0 and M1 to MODE0
pinsLoraLOW();
}
//setting the address mode for receiving messages
void setAddrConfiguration() {
lora.resetModule(); //reset lore
//set the state of contacts M0 M1 to MODE3 (sleep mode)
pinsLoraHAIG();
delay(500);
// After setting the configuration comment, set the values M0 and M1 to low
// and reboot if you directly set high values of M0 and M1 for programming
ResponseStructContainer c;
c = Lora.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
Serial1.println(c.status.getResponseDescription()); //if you need the status of the set parameters in Serail
configuration.ADDL = incomingADDH; //setting the addh address received from the interlocutor and passing it to the configuration variable
configuration.ADDH = incomingADDL; //setting the addl address received from the interlocutor and passing it to the configuration variable
configuration.CHAN = 0x17; // frequency=23+410=433MHz
configuration.PARAMETER.Fixed transmission = FT_FIXED_TRANSMISSION;
//Lora.SetConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); //important, when the power is turned off, the settings are saved!!!
Lora.SetConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE); //settings are lost when
the power is turned off //printParameters(configuration); //if you need the output of the specified parameters in Serail
c.close();
while ( !digitalRead(pinAUX)); //wait until Lora is ready
//restore the state of the contacts M0 M1 to the state MODE0 - receive/ transmit
pinsLoraLOW();
}
Now it looks like this:
…how i can pin pb5 forever make input? Since it is always an output in the arduboy2 library, and apparently it is reassigned somewhere, despite the fact that I set it in setup as an input. In the messenger, it will work as LoraAUX to initialize the module’s readiness to accept parameters. Thanks!
PB5 is Arduino digital pin 9 and is used by the Arduboy for the blue LED of the RGB LED. As long as you set it to an input after calling arduboy.begin() it should remain as an input as long as you don’t use any RGB LED related functions.
void setup() {
arduboy.boot();
//arduboy.begin();
//arduboy.setRGBled(0, 0, 0); // disable RGB LED
arduboy.clear();
arduboy.drawBitmap(0, 0, AGLM, 128, 64, WHITE);
arduboy.display();
delay(2000);
arduboy.clear();
//pinsLoraLOW();//set Lora pins 11-M0 and 10-M1 to LOW
DDRB &= ~(1 << 5); // set pin 9 as input (pin 9 corresponds to PB5)
beep.begin(); // Set up the hardware for playing tones
//PRR0 &= ~_BV(PRTWI); //Power Riduction Register...Power Riduction TWI
Serial.begin(9600); //This pipes to the serial monitor
power_usart1_enable();
arduboy.setFrameRate(60);
Serial1.begin(9600);
delay(500);
enterNickName(); // Entering a nickname from the virtual keyboard
LoraUART1.begin(9600);
Lora.begin();
delay(500);
//Serial1.write(Serial.read()); //to transfer data from Serial1 to Serial
setDefaultConfiguration(); //set default Lora values
//setDefaultLoraConfig();
//setLoraConfigViaATCommands();
pinsLoraHIGH(); //to receive settings information from the lora module, set the pins M0 M1 to HIGH according to the manual
ResponseStructContainer c;
c = Lora.getConfiguration();
// It's important to get configuration pointer before all other operation
Configuration configuration = *(Configuration*) c.data;
printParameters(configuration); //output set Lora parameters
//printParameters_(); //simplified output of confirmation of accepted parameters with Lora
//printLoRaConfiguration();
arduboy.setCursor(1, 50);
arduboy.print(c.status.getResponseDescription());
arduboy.print(c.status.code);
c.close();
pinsLoraLOW(); //according to the manual, we return pins M0 M1 to LOW
//Lora.resetModule(); //reset lore
// button A to continue
while (!arduboy.pressed(A_BUTTON)) {
arduboy.idle();
}
arduboy.clear();
//arduboy.display();
//Send message
ResponseStatus rs = Lora.sendMessage("Hello, world?");
arduboy.setCursor(1, 0);
arduboy.print("TestLora: ");
arduboy.setCursor(1, 10);
arduboy.print(rs.getResponseDescription());
// Check If there is some problem of succesfully send
Serial.println(rs.getResponseDescription());
arduboy.display();
delay(p);
arduboy.clear();
void printParameters(struct Configuration configuration) {
arduboy.clear();
arduboy.setCursor(1, 0);
// Выводим на экран значения из структуры Configuration
arduboy.print("HEAD: ");
arduboy.print(configuration.HEAD, BIN);
arduboy.setCursor(1, 10);
arduboy.print("ADDH: ");
arduboy.print(configuration.ADDH, BIN);
arduboy.setCursor(1, 20);
arduboy.print("ADDL: ");
arduboy.print(configuration.ADDL, BIN);
arduboy.setCursor(1, 30);
arduboy.print("CHAN: ");
arduboy.print(configuration.CHAN);
arduboy.setCursor(1, 40);
arduboy.print("TxPw: ");
arduboy.print(configuration.OPTION.transmissionPower, BIN);
arduboy.display();
}
Thank you. Yes, I understand, I would very much like to hope that this is so and that without any calls for the RGB LED, this pin pb5 would remain an input. how I installed it in Setup: DDRB &= ~(1 << 5); // set pin 9 as input (pin 9 corresponds to PB5). But for some reason unknown to me, the settings are not accepted by the module. I double-checked the functions, everything seems to work and according to the requirements of the EBYTE manual, but the zeros scare me a little in the photo above … Now I measured the voltage at the pb5 pin and there is 3.26v, and I don’t turn on the light anywhere in the code. On the arduino mini debug board, the settings with this module are read without errors in full, but with arduboy something is still incomprehensible.
there is a suspicion that you need to raise the power … although the specification says that the minimum voltage is 2.3v.
Tried different alternative ways to set module configuration:
void setLoraConfigViaATCommands() {
pinsLoraHIGH(); // state of the pins do HIGH for M0 M1
LoraUART1.begin(9600); // Initialize SoftwareSerial with desired baud rate
// Set module address
LoraUART1.print("AT+ADDRESS=0,0\r\n");
delay(50);
// Set frequency channel
LoraUART1.print("AT+CHANNEL=21\r\n"); // Here 17 is the frequency channel that corresponds to 433 MHz
delay(50);
//LoraUART1.print("AT+SAVE\r\n");
//delay(50);
LoraUART1.print("AT&W\r\n"); //temporarily saving the current configuration
delay(50);
// Set the baud rate
//LoraUART1.print("AT+UART=8,0,1,1\r\n"); // 8-bit data, no parity, 1 stop bit, 9600 bps
//delay(50);
// Set the data transfer mode
//LoraUART1.print("AT+TRANSMISSION=2\r\n"); // Fixed packet length
//delay(50);
// Set the output of signal levels to the output pin
//LoraUART1.print("AT+IOMODE=0\r\n");
//delay(50);
// Set transmit power level
//LoraUART1.print("AT+OUTPUT=7\r\n"); // Power at level 7 (max power)
//delay(50);
pinsLoraLOW(); //pin state is done LOW for MO M1
}
void setDefaultLoraConfig() {
pinsLoraHIGH(); // state of the pins do HIGH for M0 M1
LoraUART1.write(byte(0x0)); // ADDH module address top byte
LoraUART1.write(byte(0x0)); // ADDL lower byte of module address
LoraUART1.write(byte(0x21)); //CHAN setting 0x17+410=433MHz
LoraUART1.write(byte(0xC1)); // HEAD save settings on shutdown ( 0xC0) don't save settings on shutdown ( 0xC1)
pinsLoraLOW(); //pin state is done LOW for MO M1
//Lora.resetModule(); //reset lore
}
The Arduboy2 library sets PB5 as an output but also sets it HIGH to turn the LED off. If you only change it to an input, the HIGH setting will enable the internal pullup on the pin, thus causing it to read HIGH if there is no external input to pull it low.
If you don’t want the pullup to be enabled, you should set the PORTxn bit for the pin to 0.
I think it’s worth trying something like this:
PORTB &= ~(1 << 5); // Reset bit 5
DDRB &= ~(1 << 5); // Set input
PORTB |= (1 << 5); // Turn on the pull-down resistor
The ATmega32U4 doesn’t have pull-down resistor capability on its GPIO pins. You can either enable the pullup resistor or disable it, making the input high impedance.
do you mean leave it alone?
PORTB &= ~(1 << 5); // Reset bit 5
note:
LoRa E32-TTL-100
Get configuration.
https://www.mischianti.org/2019/10/29/lora-e32-device-for-arduino-esp32-or-esp8266-configuration-part-3/
E32-TTL-100----- Arduino UNO
M0 ----- 3.3v
M1 ----- 3.3v
TX ----- RX PIN 2 (PullUP)
RX ----- TX PIN 3 (PullUP & Voltage divider)
AUX ----- Not connected
VCC ----- 3.3v/5v
GND ----- GND
That will set the bit to a 1, which will enable the pullup resistor, which will pull the port up to VCC if the pin has no external input. If you want to disable the internal pullup, you should use:
PORTB &= ~(1 << 5); // Reset bit 5
thanks but that didn’t help. settings have not been set.
I made a measurement on pb5 without a connected module and there 1.6v will probably have to add a 4.7k pull-up to vcc with out any code (PORTB &= ~(1 << 5); // Reset bit 5 .)
That’s probably just stray voltage due to the input having such a high impedance.
Yes, if you want to guarantee that the input reads 0 when nothing is connected to or driving it, you will have to add a pull-down resistor and make sure the internal pullup is disabled. You shouldn’t need anything lower than 10K or even up to 50K or higher.
Then enable the pullup resistor with:
PORTB |= (1 << 5);
added a check before passing settings:
#define pinAUXin DDRB &= ~(1 << 5)
pinsLoraHIGH();
while ( !digitalRead(pinAUXin));
hung on this check … but must pass it…sadness
here used voltage divider on RX pin…hmm
I found information from the official forum of the developer of the Lora library. peoples have same problems :
the datasheet mentions when powering the module from 5V, pullup resistors in the range 4K to 10K are recommended. Try adding 10K pullup resistors.
The datasheet also mentions that the AUX pin can be configured push-pull (the default configuration) or open drain.
Try configuring the module to use open drain for AUX and TX and connect 10K pullups.
try issue a reset command before this loop. It could be that the normal power on reset procedure has already been finished before the Arduino executes this code.
the official EBYTE support did not offer anything intelligible and said only next week they could try to offer something …they are loaded