Forum Replies Created

Viewing 15 posts - 946 through 960 (of 979 total)
  • Author
    Posts
  • Renzo Mischianti
    Keymaster

      Hi Ludophot,

      for

      LoRa_E32 e32ttl100(2, 3,5,6,7); and LoRa_E32 e32ttl(2, 3,5,6,7)

      change only the variable name e32ttl100 in e32ttl.

       

      I think you mean difference from

      LoRa_E32 e32ttl100(2, 3,5,6,7); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1


      and

      #include <SoftwareSerial.h>
      SoftwareSerial mySerial(2, 3); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
      LoRa_E22 e22ttl(&mySerial, 5, 6, 7); // AUX M0 M1


      and

      LoRa_E22 e22ttl(&Serial1, 5, 6, 7); // AUX M0 M1

      the first and the second is the samething the difference is that in the first case I instantiate SoftwareSerial internally.

      The last one you pass a reference of the HardwareSerial.

       

      The better solution is to use HardwareSerial, because SoftwareSerial is an emulation of Hardware one, so to do the emulation need more processors time respect an hardware implementation of the Serial, and can be more fast.

      But not all Arduino like have multiple Serial, so for Arduino UNO, if you want use debug and other you need to do Software one.

      Bye Renzo

      Renzo Mischianti
      Keymaster

        Hi Ludopot,

        I found this implementation

         

        
        #include <ArduinoHttpClient.h>
        #include <MD5.h>
        HttpClient client = HttpClient(wifiConnection, adress, port);
        ...
        bool HttpSendDigest(String uri, String user, String password, String data)
        {
        
          //Serial.println("HttpSendDigest::POST request");
          client.beginRequest();
          client.post(uri,"application/x-www-form-urlencoded",data);
          client.endRequest();
        
        
          String header ="";
          // read the status code and body of the response
          int statusCode = client.responseStatusCode();
          if (client.headerAvailable()){
            while(!client.endOfHeadersReached()){
              header = header + char(client.readHeader());
            }
          }
          String headerName = client.readHeaderName();
          String headerValue = client.readHeaderValue();
          String response = client.responseBody();
          /*
          Serial.println("HttpSendDigest::Headername: "+ headerName);
          Serial.println("HttpSendDigest::Headervalue: "+ headerValue);
          Serial.println("HttpSendDigest::header: ");
          Serial.println(header);
          Serial.print("HttpSendDigest::statuscode: ");
          Serial.println(statusCode);
          Serial.println("HttpSendDigest::response: ");
          Serial.println(response);
          */
        
          if (statusCode == 401 && headerName.equalsIgnoreCase("WWW-Authenticate"))
          {
              //Serial.println("HttpSendDigest::401+WWW-Authenticate detected");  
              String AuthMethod = headerValue.substring(0,headerValue.indexOf(' '));
              String realm = strGetValue(headerValue,"realm=\"","\"");
              String nonce = strGetValue(headerValue,"nonce=\"","\"");
              String qop = strGetValue(headerValue,"qop=\"","\"");
              /*
              Serial.println("HttpSendDigest::AuthMethod: "+AuthMethod);  
              Serial.println("HttpSendDigest::realm: "+realm);  
              Serial.println("HttpSendDigest::nonce: "+nonce);  
              Serial.println("HttpSendDigest::qop: "+qop);  
              */
              //Serial.print("HttpSendDigest::Calculate HA1...");  
              String HA1 = calcMD5(user+":"+realm+":"+password);
              //Serial.println(HA1);  
        
              //Serial.print("HttpSendDigest::Calculate HA2...");  
              String HA2 = calcMD5("POST:"+uri);
              //Serial.println(HA2);  
        
              String cnonce = String(random(8556822323));
              //Serial.println("HttpSendDigest::cnonce: "+cnonce);  
              //Serial.println("HttpSendDigest::Calculate authResponse...");  
              String authResponse =calcMD5(HA1+":"+nonce+":"+"00000001"+":"+cnonce+":"+qop+":"+HA2); //MD5(HA1:nonce:nonceCount:cnonce:qop:HA2)
              //Serial.println("HttpSendDigest::authResponse: "+authResponse);      
        
              String authHeaderString = "Authorization: Digest username=\"" + user +
                                "\",realm=\"" + realm +
                                "\",nonce=\"" + nonce +
                                "\",uri=\"" + uri +
                                "\",cnonce=\"" + cnonce +
                                "\",qop=auth, nc=00000001, response=\"" + authResponse + "\"";//\r\n";
              //Serial.println("HttpSendDigest::authHeaderString: "+authHeaderString);  
              
              //Serial.println("HttpSendDigest::---auth post---");
              client.beginRequest();
              client.post(uri);
              client.sendHeader(authHeaderString);
              client.sendHeader(HTTP_HEADER_CONTENT_TYPE, "application/x-www-form-urlencoded");
              client.sendHeader(HTTP_HEADER_CONTENT_LENGTH, data.length());
              client.beginBody();
              client.print(data);
              client.endRequest();
              
              //Serial.println("HttpSendDigest::---authresponse---");
              header ="";
              // read the status code and body of the response
              statusCode = client.responseStatusCode();
              if (client.headerAvailable()){
                while(!client.endOfHeadersReached()){
                  header = header + char(client.readHeader());
                }
              }
        
              headerName = client.readHeaderName();
              headerValue = client.readHeaderValue();
              response = client.responseBody();
              /*
              Serial.println("HttpSendDigest::Headername: "+ headerName);
              Serial.println("HttpSendDigest::Headervalue: "+ headerValue);
              Serial.println("HttpSendDigest::header: ");
              Serial.println(header);
              Serial.print("HttpSendDigest::statuscode: ");
              Serial.println(statusCode);
              Serial.println("HttpSendDigest::response: ");
              Serial.println(response);
              */
          }
          if (statusCode==200)
          {
            return true;  
          }
          else
          {
            return false;
          }
          
        }
        

        than you must call like this

        HttpSendDigest("/command.cgi",user,password,dataString)

        But you must check if the software need HTTPS because Arduino not support that protocol.

         

        Bye Renzo

        in reply to: More than one pcf8574 expander #5528
        Renzo Mischianti
        Keymaster

          Hi hmronline,
          It’s true, the sketch not working on Arduino, only in esp8266 core, try this

          
          #include "Arduino.h"
          #include "PCF8574.h"
          
          PCF8574 pcf8574_1(0x38);
          PCF8574 pcf8574_2(0x39);
          
          PCF8574* arrayOfPCF[2];
          //The setup function is called once at startup of the sketch
          void setup()
          {
          	Serial.begin(115200);
          
          	pcf8574_1.pinMode(P0, OUTPUT);
          	pcf8574_1.pinMode(P1, OUTPUT);
          	pcf8574_1.pinMode(P2, OUTPUT);
          
          	pcf8574_2.pinMode(P1, OUTPUT);
          	pcf8574_2.pinMode(P2, OUTPUT);
          	pcf8574_2.pinMode(P3, OUTPUT);
          
          	pcf8574_1.begin();
          	pcf8574_2.begin();
          
          	arrayOfPCF[0] = &pcf8574_1;
          	arrayOfPCF[1] = &pcf8574_2;
          
          }
          
          void loop()
          {
          	arrayOfPCF[0]->digitalWrite(P1, HIGH);
          	arrayOfPCF[1]->digitalWrite(P1, HIGH);
          	delay(2000);
          	arrayOfPCF[0]->digitalWrite(P1, HIGH);
          	arrayOfPCF[1]->digitalWrite(P1, HIGH);
          	delay(2000);
          
          }
          

          or

          #include "Arduino.h"
          #include "PCF8574.h"
          
          PCF8574 pcf8574_1(0x38);
          PCF8574 pcf8574_2(0x39);
          
          PCF8574 arrayOfPCF[2] = {pcf8574_1, pcf8574_2};
          //The setup function is called once at startup of the sketch
          void setup()
          {
          	Serial.begin(115200);
          
          	pcf8574_1.pinMode(P0, OUTPUT);
          	pcf8574_1.pinMode(P1, OUTPUT);
          	pcf8574_1.pinMode(P2, OUTPUT);
          
          	pcf8574_2.pinMode(P1, OUTPUT);
          	pcf8574_2.pinMode(P2, OUTPUT);
          	pcf8574_2.pinMode(P3, OUTPUT);
          
          	pcf8574_1.begin();
          	pcf8574_2.begin();
          
          }
          
          void loop()
          {
          	arrayOfPCF[0].digitalWrite(P1, HIGH);
          	arrayOfPCF[1].digitalWrite(P1, HIGH);
          	delay(2000);
          	arrayOfPCF[0].digitalWrite(P1, HIGH);
          	arrayOfPCF[1].digitalWrite(P1, HIGH);
          	delay(2000);
          
          }
          

          Bye Renzo
           

          in reply to: More than one pcf8574 expander #5525
          Renzo Mischianti
          Keymaster

            I try to compile my sketch and no error, can you post your code??

            in reply to: More than one pcf8574 expander #5523
            Renzo Mischianti
            Keymaster

              Hi hmronline,
              I think something like this can work

               

              #include "Arduino.h"
              #include "PCF8574.h"
              
              PCF8574 pcf8574_1(0x38);
              PCF8574 pcf8574_2(0x39);
              
              
              PCF8574 arrayOfPCF[2];
              //The setup function is called once at startup of the sketch
              void setup()
              {
              	Serial.begin(115200);
              
              	pcf8574_1.pinMode(P0, OUTPUT);
              	pcf8574_1.pinMode(P1, OUTPUT);
              	pcf8574_1.pinMode(P2, OUTPUT);
              
              	pcf8574_2.pinMode(P1, OUTPUT);
              	pcf8574_2.pinMode(P2, OUTPUT);
              	pcf8574_2.pinMode(P3, OUTPUT);
              
              
              	pcf8574_1.begin();
              	pcf8574_2.begin();
              
              	arrayOfPCF[0] = pcf8574_1;
              	arrayOfPCF[1] = pcf8574_1;
              
              }
              
              
              void loop()
              {
              	arrayOfPCF[0].digitalWrite(P1, HIGH);
              	arrayOfPCF[1].digitalWrite(P1, HIGH);
              	delay(2000);
              	arrayOfPCF[0].digitalWrite(P1, HIGH);
              	arrayOfPCF[1].digitalWrite(P1, HIGH);
              	delay(2000);
              
              }
              

              Give me a feedback.
              Bye Renzo

              Renzo Mischianti
              Keymaster

                Hi Dan-Åke Asp,

                sorry for the problem, but the thingiverse account is not updated (no time to do that), I update only this site at this link

                http://mischianti.org/improved-z-axis-for-cyclone-pcb-factory/

                there you can find all the updated parts.

                Bye Renzo

                Renzo Mischianti
                Keymaster

                  Hi Alejandro,

                  yes, can be an usefully features, but not so simple to develop, the message in the buffer can be not in sequence, and the order in a long transmission can change with the enviroenment condition.

                  But when I have more time I think how to do that.

                  Bye Renzo

                  Renzo Mischianti
                  Keymaster

                    Hi Alejandro,

                    EByte response me

                    Hi Renzo,
                    The single packet limit is 58 bytes. It means one transmission can only send 58 bytes. it will cut your data into serveral 58-byte packet to send.
                    The buffer is 512 bytes, it means you can input maximum 512 bytes of data by UART, and the module will cut the 512-byte of data into several packet to send all those 512 byte data in serveral times.
                    ---------------------------------
                    Best Regards,
                    

                    The packet size is 58Bytes if you put a stream of packet the device send they one to one not like a single package.

                    Bye Renzo

                    Renzo Mischianti
                    Keymaster

                      Hi Alejandro,
                      then, on this point it is not very clear,

                      initially I left the possibility of sending packets of any size, but they are truncated at 58byte,

                      and on the specifications page they write “TX length 58byte Maximun capacity of singlepackage”,

                      so I interpreted what they have written later as if you can send packet in series (even if not yet transmitted) until the buffer is filled,

                      and I add new receive message method this days

                      ResponseContainer rs = e32ttl.receiveMessageUntil();

                      that if you receive more than one String message at the same time can read single message instead all message in the buffer.

                      but if you had the same doubt you too, I can try to send 58 bytes and then the rest.

                      But if the size is not relevant the upgraded version e22 (I’m doing the library now) have packet size variable (max 240byte) but if there are no limit why to manage packet size?

                      But as soon as I find time I do another test.

                      Keep in touch.

                      Bye Renzo

                      Renzo Mischianti
                      Keymaster

                        Hi,

                        for the power, if It isn’t too big a panel like this


                        AliExpress.com Product – 10Pcs/Lot DIY Toy 5V 30mA 53X30mm Micro Mini Small Power Solar Cells Panel Wholesale DIY Sun Panel

                        without a resin they are flexible and can cover all the pakage, probably can be sufficient to recharge the device quite fast.

                        There are some type of battery for bracelet or similar very small but about 50mha


                        AliExpress.com Product – Liter energy battery Good Qulity 3.7v polymer lithium battery 50mah 501012 is suitable for I7 bluetooth headset MP3 MP4

                        The drone battery can be quite small,


                        AliExpress.com Product – 051230 501230 150mah BT150 Bluetooth Headset 3.7V lithium polymer battery

                         

                        For LoRa I finish first release of Ebyte E22 LoRa devices that have a repeater function, and If we must track a small area like 60km with some device as repeater put in the area can cover with RF the transmission.

                        Ebyte LoRa E22 device repeater relay function ultra long distance

                         

                        But We need more detail to do an evaluation.

                         

                        Bye Renzo

                         

                        Renzo Mischianti
                        Keymaster

                          Hi Joaquin,

                          to start you can try with

                          SIM900A

                          BN220

                          For microcontroller the smt32 have a good power and consume, but you can check of the are library for module.

                          Renzo

                           

                          Renzo Mischianti
                          Keymaster

                            I’m happy you have find the solution.. If you need more help or you have some idea to add to the library write on Forum without problem.

                            Bye Renzo

                            Renzo Mischianti
                            Keymaster

                              Hi JoaquinC,

                              I think It’s better to limit the spec to only what you really need, but for fisrt we must select some GPS small like one for drone, like this

                              GPS Module compass

                              GSM Module

                              or a radio with 8km range like

                              LoRa E32 device for Arduino, esp32 or esp8266: specs and basic usage – Part 1

                              Thank It’s important to select a rechargeable battery powerfull and light, this is a choiche that you can find when you have a base to test, but you can select a big 18650 with 3400mha

                              3400mha 18650 battery

                              or a 523450 fot about 1000mha

                              1000mha 503450 Battery

                              If you must have less weight you can choiche a drone battery with low capacity but very small

                              250mAh 402035 battery

                              Chan you can use a system like this to recharge

                              Emergency power bank homemade

                               

                              I think the microcontroller is not so important because for a lot of time It’s become in sleep mode, some SMT series have a very low power consmuption, other like PIC one or ATMega.

                              I think you can use also a WeMos D1, but when you are going to create a board you must use the IC not the board.

                              WeMos D1 mini (esp8266), pinout, specs and IDE configuration – Part 1

                               

                              But you must specify more information about you want to do, like

                              • form factor
                              • weight
                              • distance
                              • frequences

                              and all other spec you want raised.

                               

                              Bye Renzo

                              Renzo Mischianti
                              Keymaster

                                Hehehehehhe… Keep calmp….

                                The sketch I send you is fully working and tested (I do it with an esp32 devkit v1 and WeMos, I try It with an Arduino also and 2 e32 433, that you can see on photo).

                                Pay attention I comment the first 2 define anche change power to adapt to my devices.

                                We can go by step, send me your connection schema, I’m going to do the same connection, and tell me what kind of pull-up resistor you have used.

                                than if It’s ok I ask you to resend all the code.

                                Hold on, we’ll find the problem: P.

                                Bye Renzo

                                Attachments:
                                You must be logged in to view attached files.
                                Renzo Mischianti
                                Keymaster

                                  Hi Alejandro,

                                  I check your code, and there are some issue, first is the type of communication setted to TRANSPARENT

                                  But I have found an issue/problem in the library and I change It, two constructor of esp32 is ambiguous, so I change the disposition of the constructor that have specifies setting of HardwareSerial,

                                  To undestand

                                  LoRa_E32(HardwareSerial* serial, byte txE32pin, byte rxE32pin, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600, uint32_t serialConfig = SERIAL_8N1);

                                  now is

                                  LoRa_E32(byte txE32pin, byte rxE32pin, HardwareSerial* serial, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600, uint32_t serialConfig = SERIAL_8N1);

                                  but in your case the code become more simpliest with the direct usage of Serial2

                                  Here the sending code for esp32

                                  
                                  #include "Arduino.h"
                                  //#define E32_TTL_1W
                                  //#define FREQUENCY_915
                                  #include "LoRa_E32.h"
                                  
                                  // Not needed Serial2 have already this pins
                                  //#define RX 16
                                  //#define TX 17
                                  
                                  #define AUX 18
                                  #define M0 21
                                  #define M1 19
                                  
                                  //HardwareSerial serial1(2);
                                  
                                  //LoRa_E32 e32ttl1w(&serial1,RX,TX, 18, UART_BPS_RATE_9600,SERIAL_8N1);
                                  LoRa_E32 e32ttl1w(&Serial2, AUX, M0, M1);
                                  void printParameters(struct Configuration configuration);
                                  void printModuleInformation(struct ModuleInformation moduleInformation);
                                  
                                  // Variables globales
                                  unsigned long interval = 15000;          // interval between sends
                                  unsigned long lastSendTime = 0;        // last send time
                                  byte msgCount = 0;            // count of outgoing messages
                                  long randNumber;
                                  void setup() {
                                    //Inicio comunicacion serie con monitor
                                    Serial.begin(9600);
                                    delay(500);
                                  
                                    Serial.println();
                                  
                                    e32ttl1w.begin();
                                  
                                    //Configuro el nodo LoRa
                                    nodeConfig();
                                  }
                                  
                                  void loop() {
                                    // Wait a few seconds between measurements.
                                  
                                    if (millis() - lastSendTime > interval) {
                                      // print a random number from 10 to 19
                                      randNumber = random(10, 20);
                                      String trama = String(randNumber);
                                      ResponseStatus rs = e32ttl1w.sendFixedMessage(0, 3, 0x10,trama);
                                      Serial.println("Sending " + trama);
                                      Serial.println(rs.getResponseDescription());
                                      lastSendTime = millis();            // timestamp the message
                                      msgCount++;
                                    }
                                    delay(100);
                                  }
                                  
                                  void nodeConfig(){
                                  
                                    ResponseStructContainer c;
                                    c = e32ttl1w.getConfiguration();
                                    Configuration configuration = *(Configuration*) c.data;
                                  
                                    configuration.ADDH        = 0x0;
                                    configuration.ADDL        = 0x1;
                                    configuration.CHAN        = 0x10;
                                  
                                    configuration.SPED.airDataRate           = AIR_DATA_RATE_010_24;
                                    configuration.SPED.uartBaudRate          = UART_BPS_9600;
                                    configuration.SPED.uartParity            = MODE_00_8N1;
                                    configuration.OPTION.fec                 = FEC_1_ON;
                                    configuration.OPTION.fixedTransmission   = FT_FIXED_TRANSMISSION;
                                    configuration.OPTION.ioDriveMode         = IO_D_MODE_PUSH_PULLS_PULL_UPS;
                                    configuration.OPTION.transmissionPower   = POWER_20;
                                    configuration.OPTION.wirelessWakeupTime  = WAKE_UP_1250;
                                    //printParameters(configuration);
                                  
                                  // Set configuration changed and set to not hold the configuration
                                    ResponseStatus rs = e32ttl1w.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
                                    Serial.print("Config: ");
                                    Serial.println(rs.getResponseDescription());
                                  }
                                  
                                   Here the receiving code for WeMos
                                  
                                  #include "Arduino.h"
                                  //#define E32_TTL_1W
                                  //#define FREQUENCY_915
                                  #include "LoRa_e32.h"
                                  
                                  #define RX 4
                                  #define TX 5
                                  #define M0 7
                                  #define M1 6
                                  
                                  LoRa_E32 e32ttl1w(D3, D4, D5, D7, D6);
                                  
                                  void setup() {
                                    //Inicio comunicacion serie con monitor
                                    Serial.begin(9600);
                                    delay(500);
                                  // Startup all pins and UART
                                  	e32ttl1w.begin();
                                    //Configuro el nodo LoRa
                                    nodeConfig();
                                  }
                                  
                                  void loop() {
                                  
                                    if (e32ttl1w.available() > 0) {
                                      Serial.println("----------");
                                      ResponseContainer rc = e32ttl1w.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);
                                      }
                                    }
                                    delay(500);
                                  }
                                  
                                  void nodeConfig(){
                                  
                                    ResponseStructContainer c;
                                    c = e32ttl1w.getConfiguration();
                                    Configuration configuration = *(Configuration*) c.data;
                                  
                                      configuration.ADDH        = 0x0;
                                      configuration.ADDL        = 0x3;
                                      configuration.CHAN        = 0x10;
                                  
                                      configuration.SPED.airDataRate           = AIR_DATA_RATE_010_24;
                                      configuration.SPED.uartBaudRate          = UART_BPS_9600;
                                      configuration.SPED.uartParity            = MODE_00_8N1;
                                      configuration.OPTION.fec                 = FEC_1_ON;
                                      configuration.OPTION.fixedTransmission   = FT_FIXED_TRANSMISSION;
                                      configuration.OPTION.ioDriveMode         = IO_D_MODE_PUSH_PULLS_PULL_UPS;
                                      configuration.OPTION.transmissionPower   = POWER_20;
                                      configuration.OPTION.wirelessWakeupTime  = WAKE_UP_1250;
                                  
                                    //printParameters(configuration);
                                  
                                  // Set configuration changed and set to not hold the configuration
                                    ResponseStatus rs = e32ttl1w.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
                                  
                                    Serial.print("Config: ");
                                    Serial.println(rs.getResponseDescription());
                                  
                                  }
                                  
                                  

                                  Download also the new versione of LoRa e32 library that have some fix and additional function to manage multiple string receiving.

                                  If you need more help ask without problems.

                                   

                                  Bye and thanks Renzo

                                Viewing 15 posts - 946 through 960 (of 979 total)