Forum Replies Created
-
AuthorPosts
-
5 June 2020 at 07:43 in reply to: Mega 2560 e32 EByte frozen in example sendReceiveTransparentTransmissionMessage #4430
I check with my Arduino Mega, and my error is that I don’t use a correct RX pin as Arduino guide describe.
https://www.arduino.cc/en/Reference/softwareSerial
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
Now I can send without problem and receive without problem on my Mega without any freeze.
I use this configuration
SoftwareSerial mySerial(11, 5); LoRa_E32 e32ttl100(&mySerial, 3, 7, 6);
Now work correctly.
Please update the libray, uncomment
#define LoRa_E32_DEBUG
And send me your log, I try to understand.
If you want to use HardwareSerial you must do like so
LoRa_E32 e32ttl100(&Serial2, 3, 7, 6);
Bye Renzo
5 June 2020 at 07:42 in reply to: Mega 2560 e32 EByte frozen in example sendReceiveTransparentTransmissionMessage #4429I’m doing some test with mega and there is a problem, I’m going to discover in the next week.
Bye Renzo5 June 2020 at 07:42 in reply to: Mega 2560 e32 EByte frozen in example sendReceiveTransparentTransmissionMessage #4428I tested the example with a1 case but work for me and my Arduino UNO, I’m going to try with Mega.
Thanks for your patience Renzo5 June 2020 at 07:40 in reply to: Mega 2560 e32 EByte frozen in example sendReceiveTransparentTransmissionMessage #4426Hi fransolomon,
I tested your sketch with 2 Arduino UNO, and It’s work correctly, I only add the correct configuration, please try It.#include "Arduino.h" #include "LoRa_E32.h" // SoftwareSerial mySerial(11, 10); // LoRa_E32 e32ttl100(&mySerial,5, 7, 6); SoftwareSerial mySerial(4, 5); LoRa_E32 e32ttl100(&mySerial, 3, 7, 6); //LoRa_E32 e32ttl100(4, 5, 3, 7, 6); void printParameters(struct Configuration configuration) ; void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e32ttl100.begin(); ResponseStructContainer c; c = e32ttl100.getConfiguration(); Configuration configuration = *(Configuration*) c.data; configuration.ADDL = 3; configuration.ADDH = 0; configuration.CHAN = 0x04; configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; configuration.OPTION.wirelessWakeupTime = WAKE_UP_250; configuration.OPTION.fec = FEC_1_ON; configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS; configuration.OPTION.transmissionPower = POWER_20; configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; configuration.SPED.uartBaudRate = UART_BPS_9600; configuration.SPED.uartParity = MODE_00_8N1; e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); printParameters(configuration); Serial.println("Hi, I'm going to send message!"); // Send message ResponseStatus rs = e32ttl100.sendMessage("Hello, world?"); // OK The message is received on the other device // Check If there is some problem of succesfully send Serial.println(rs.getResponseDescription()); } void loop() { // If something available // Serial.println("continuity test point"); //This instruction is not executed unless you comment on the previous line "Serial.println(rs.getResponseDescription());" if (e32ttl100.available() > 1) { ResponseContainer rc = e32ttl100.receiveMessage(); Serial.println(rc.data); // Is something goes wrong print error if (rc.status.code != 1) { rc.status.getResponseDescription(); } else { // Print the data received Serial.println(rc.data); } } if (Serial.available()) { String input = Serial.readString(); e32ttl100.sendMessage(input); } } void printParameters(struct Configuration configuration) { Serial.println("----------------------------------------"); Serial.print(F("HEAD : ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX); Serial.println(F(" ")); Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, DEC); Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, DEC); 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.getUARTBaudRate()); Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate()); Serial.print(F("OptionTrans : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription()); Serial.print(F("OptionPullup : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription()); Serial.print(F("OptionWakeup : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription()); Serial.print(F("OptionFEC : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription()); Serial.print(F("OptionPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription()); Serial.println("----------------------------------------"); }
And please recheck your connection schema with the schema on the article not on Github library, and check that you have the last version of the library, I fix sometings 2 days ago.
Bye Renzo
5 June 2020 at 07:39 in reply to: Mega 2560 e32 EByte frozen in example sendReceiveTransparentTransmissionMessage #4424Hi, I can’t check the sketch now, but please refer to my site, i update all the schema.
In the next few days I check all with my Arduino mega.
Thanks to write, and please wait.
Bye RenzoHi I check your sketch and seems quite ok.
But I think you must add AUX pin or put a pull up resistor on It, with no AUX not work for me, but with aux I have a correct send.
And Arduino Json have some problem on serialize on String
#include "Arduino.h" #include "LoRa_E32.h" #include <DHT.h> #include <ArduinoJson.h> #define DHTPIN 4 #define DHTTYPE DHT11 int freeRame () { #ifdef ESP8266 return Esp.getFreeHeap(); #else extern int __heap_start, *__brkval; int v; return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); #endif // ESP8266 } DHT dht(DHTPIN, DHTTYPE); DynamicJsonDocument doc(512); // ---------- esp8266 pins -------------- //LoRa_E32 e32ttl(D2, D3, D5, D7, D6); //LoRa_E32 e32ttl(D2, D3); // Config without connect AUX and M0 M1 //#include <SoftwareSerial.h> //SoftwareSerial mySerial(D2, D3); // RX, TX //LoRa_E32 e32ttl(&mySerial, D5, D7, D6); // ------------------------------------- // ---------- Arduino pins -------------- //LoRa_E32 e32ttl(2, 3, 5, 7, 6); LoRa_E32 e32ttl100(4, 5, 3); // Config without connect AUX and M0 M1 //#include <SoftwareSerial.h> //SoftwareSerial mySerial(2, 3); // RX, TX //LoRa_E32 e32ttl(&mySerial, 5, 7, 6); // ------------------------------------- void printParameters(struct Configuration configuration) { Serial.println("----------------------------------------"); Serial.print(F("HEAD BIN: ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX); Serial.println(F(" ")); Serial.print(F("AddH BIN: ")); Serial.println(configuration.ADDH, BIN); Serial.print(F("AddL BIN: ")); Serial.println(configuration.ADDL, BIN); Serial.print(F("Chan BIN: ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription()); Serial.println(F(" ")); Serial.print(F("SpeedParityBit BIN : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription()); Serial.print(F("SpeedUARTDataRate BIN : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRate()); Serial.print(F("SpeedAirDataRate BIN : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate()); Serial.print(F("OptionTrans BIN : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription()); Serial.print(F("OptionPullup BIN : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription()); Serial.print(F("OptionWakeup BIN : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription()); Serial.print(F("OptionFEC BIN : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription()); Serial.print(F("OptionPower BIN : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription()); Serial.println("----------------------------------------"); } void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e32ttl100.begin(); dht.begin(); // ResponseStructContainer c; // c = e32ttl100.getConfiguration(); // struct Configuration configuration = *(Configuration*) c.data; // printParameters(configuration); // // configuration.ADDL = 0x01; // configuration.ADDH = 0x00; // configuration.CHAN = 0x04; // // configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; // configuration.OPTION.wirelessWakeupTime = WAKE_UP_750; // // configuration.OPTION.fec = FEC_1_ON; // configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS; // configuration.OPTION.transmissionPower = POWER_20; // // configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; // configuration.SPED.uartBaudRate = UART_BPS_9600; // configuration.SPED.uartParity = MODE_00_8N1; // // // e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); // printParameters(configuration); Serial.println("Hi, I'm going to send message!"); Serial.println(freeRame()); // Send message ResponseStatus rs = e32ttl100.sendMessage("Hello, Taurus!"); Serial.println(freeRame()); // Check If there is some problem of succesfully send Serial.println(rs.getResponseDescription()); } int i = 0; void loop() { Serial.println(freeRame()); float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println(F("Failed to read from DHT sensor!")); // return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); Serial.println(freeRame()); h = random(90); t = random(40); f = 1.0; hif = 2.0; hic = 2.0; Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F("% Temperature: ")); Serial.print(t); Serial.print(F("°C ")); Serial.print(f); Serial.print(F("°F Heat index: ")); Serial.print(hic); Serial.print(F("°C ")); Serial.print(hif); Serial.println(F("°F")); Serial.println(freeRame()); delay(1000); doc["temperature"] = t; doc["humidity"] = h; Serial.println(freeRame()); int size = measureJson(doc)+1; char buf[size]; serializeJson(doc, buf, size); Serial.println(buf); Serial.println(measureJson(doc)); ResponseStatus rs = e32ttl100.sendMessage(buf, size); // String buf; // serializeJson(doc, buf); // Serial.println(buf); // Serial.println(buf.length()); // ResponseStatus rs = e32ttl100.sendMessage(buf); Serial.println(freeRame()); Serial.println(rs.getResponseDescription()); Serial.println(freeRame()); delay(2000); }
#include "Arduino.h" #include "LoRa_E32.h" #include <ArduinoJson.h> #define E32_TTL_100 LoRa_E32 e32ttl(4, 5, 3); // Config without connect AUX and M0 M1 //#include <SoftwareSerial.h> //SoftwareSerial mySerial(D2, D3); // RX, TX //E32_TTL e32ttl(&mySerial, D5, D7, D6); void printParameters(struct Configuration configuration); void printModuleInformation(struct ModuleInformation moduleInformation); //The setup function is called once at startup of the sketch void setup() { Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } delay(400); e32ttl.begin(); // ResponseStructContainer c; // c = e32ttl.getConfiguration(); // struct Configuration configuration = *(Configuration*) c.data; // printParameters(configuration); // // configuration.ADDL = 0x01; // configuration.ADDH = 0x00; // configuration.CHAN = 0x04; // // configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; // configuration.OPTION.wirelessWakeupTime = WAKE_UP_750; // // configuration.OPTION.fec = FEC_1_ON; // configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS; // configuration.OPTION.transmissionPower = POWER_20; // // configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; // configuration.SPED.uartBaudRate = UART_BPS_9600; // configuration.SPED.uartParity = MODE_00_8N1; // // // e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); // printParameters(configuration); // ResponseContainer c; // c = e32ttl.getConfiguration(); // Configuration configuration = *(Configuration*) c.data; // Serial.println(configuration.SPED.getUARTBaudRate()); // Serial.println(c.status.getResponseDescription()); // // printParameters(configuration); // // ResponseContainer cMi; // cMi = e32ttl.getModuleInformation(); // ModuleInformation mi = *(ModuleInformation*)cMi.data; // // Serial.println(cMi.status.getResponseDescription()); // Serial.println(cMi.status.code); // // printModuleInformation(mi ); // // configuration.CHAN = configuration.CHAN-1; // e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); // // ResponseContainer cNext; // cNext = e32ttl.getConfiguration(); // Configuration configurationNext = *(Configuration*) cNext.data; // Serial.println(configurationNext.SPED.getUARTBaudRate()); // Serial.println(cNext.status.getResponseDescription()); // printParameters(configurationNext); } DynamicJsonDocument doc(512); // The loop function is called in an endless loop void loop() { if (e32ttl.available() > 1){ // struct Messaggione { // char message[8]; // bool mitico; // }; // // char type[5]; // ResponseContainer rs = e32ttl.receiveInitialMessage(sizeof(type)); // memcpy ( type, rs.data.c_str(), sizeof(type) ); //// ResponseContainer rs = e32ttl.receiveInitialMessage(5); //// char type[5] = {rs.data.c_str()}; // // Serial.println("READ TYPE: "); // Serial.println(rs.status.getResponseDescription()); // Serial.println(type); // // ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Messaggione)); // struct Messaggione messaggione = *(Messaggione*) rsc.data; ResponseContainer rs = e32ttl.receiveMessage(); String message = rs.data; Serial.println(rs.status.getResponseDescription()); Serial.println(message); deserializeJson(doc, message); Serial.print("humidity --> "); Serial.println((float)doc["humidity"]); // Serial.println(messaggione.message); // Serial.println(messaggione.mitico); } } //void printParameters(struct Configuration configuration) { // Serial.println("----------------------------------------"); // // Serial.print(F("HEAD BIN: ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX); // Serial.println(F(" ")); // Serial.print(F("AddH BIN: ")); Serial.println(configuration.ADDH, BIN); // Serial.print(F("AddL BIN: ")); Serial.println(configuration.ADDL, BIN); // Serial.print(F("Chan BIN: ")); Serial.print(configuration.CHAN, HEX); Serial.print(" -> "); Serial.println(); // Serial.println(F(" ")); // Serial.print(F("SpeedParityBit BIN : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(); // Serial.print(F("SpeedUARTDataRate BIN : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(); // Serial.print(F("SpeedAirDataRate BIN : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(); // // Serial.print(F("OptionTrans BIN : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(); // Serial.print(F("OptionPullup BIN : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(); // Serial.print(F("OptionWakeup BIN : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(); // Serial.print(F("OptionFEC BIN : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(); // Serial.print(F("OptionPower BIN : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(); // // Serial.println("----------------------------------------"); // //} void printParameters(struct Configuration configuration) { Serial.println("----------------------------------------"); Serial.print(F("HEAD BIN: ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX); Serial.println(F(" ")); Serial.print(F("AddH BIN: ")); Serial.println(configuration.ADDH, BIN); Serial.print(F("AddL BIN: ")); Serial.println(configuration.ADDL, BIN); Serial.print(F("Chan BIN: ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription()); Serial.println(F(" ")); Serial.print(F("SpeedParityBit BIN : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription()); Serial.print(F("SpeedUARTDataRate BIN : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRate()); Serial.print(F("SpeedAirDataRate BIN : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate()); Serial.print(F("OptionTrans BIN : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription()); Serial.print(F("OptionPullup BIN : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription()); Serial.print(F("OptionWakeup BIN : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription()); Serial.print(F("OptionFEC BIN : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription()); Serial.print(F("OptionPower BIN : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription()); Serial.println("----------------------------------------"); } void printModuleInformation(struct ModuleInformation moduleInformation) { Serial.println("----------------------------------------"); Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX); Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX); Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX); Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX); Serial.println("----------------------------------------"); }
Hi taurushappy,
you can use ArduinoJSON library, (I’m going to publish a post on how to use It).You can
DynamicJsonDocument doc(512); // Set the values in the document doc["energyLifetime"] = 21698620; doc["energyYearly"] = 1363005; String buf; serializeJson(doc, buf); ResponseStatus rs = e32ttl.sendMessage(buf);
Remember you have a size limit on message size of the lora E32.
The code is untested, but I think It can be usefully to understand.
Tell me if It’s ok.
Bye Renzo
Hi Michiel
now It’s possible to check the status with
if (pcf8574.begin()){ Serial.println("pcf8574 started!"); }else{ Serial.println("pcf8574 not started!"); }
or
if (pcf8574.digitalWrite(P7, startVal)){ Serial.println("Write ok"); }else{ Serial.println("Write not ok"); }
It’s also possible to get last writeStatus with
uint8_t getTransmissionStatusCode() const { return transmissionStatus; }
bool isLastTransmissionSuccess(){ return transmissionStatus==0; }
Bye Renzo
-
AuthorPosts