Forum Replies Created

Viewing 15 posts - 976 through 990 (of 1,020 total)
  • Author
    Posts
  • Renzo Mischianti
    Keymaster

      Hi Ricardo,

      first of all, I forgot to advise you to use a device with 3.3v logic, even if the e32s still need to be powered at 5v, but the communication logic is at 3.3v, and your connection scheme will be simpler.

      Than, here some pieces of code of one of my project:

      Here I put my esp8266 and the E32 in sleep mode:

      
      
      	if (e32ttl.available()){
      		SERIAL_DEBUG.println("Start reading!");
      
      		ResponseContainer rs = e32ttl.receiveMessage();
      		String message = rs.data;
      
      		SERIAL_DEBUG.println(rs.status.getResponseDescription());
      
      		SERIAL_DEBUG.println(message);
      		deserializeJson(doc, message);
      
      		String type = doc["type"];
      		SERIAL_DEBUG.print("type --> ");
      		SERIAL_DEBUG.println(type);
      
      		operationalSelected = static_cast((int)doc["mode"]);
      
      		ResponseStatus rsW;
      
      		if (type=="start"){
      			pumpIsActive = true;
      
      			SERIAL_DEBUG.print(rsW.getResponseDescription());
      			SERIAL_DEBUG.println("Operation complete!!");
      
      			if (batteryLevel>1){
      				batteryTimePassed = 0;
      				btSended = false;
      			}
      
      		}else if(type=="stopp"){
      			batteryTimePassed = 0;
      
      			pumpIsActive = false;
      			ResponseStatus rsUpdate = sendUpdate(PACKET_PUMP_LEVEL);
      			SERIAL_DEBUG.println(rsUpdate.getResponseDescription());
      			rsW = setModeSleep();
      			SERIAL_DEBUG.print(rsW.getResponseDescription());
      			SERIAL_DEBUG.println("Operation complete, go to sleep!!");
      		}else if (type=="ackpa"){
      			needAck = false;
      		}
      
      		ResponseStatus rsUpdate = sendUpdate(PACKET_PUMP_LEVEL);
      		SERIAL_DEBUG.println(rsUpdate.getResponseDescription());
      
      		SERIAL_DEBUG.println("Update complete!!");
      
      		timePassed = millis();
      	}
      
      
      

      To send the update message sendUpdate you must set mode normal

       ResponseStatus rs;
      rs.code = e32ttl.setMode(MODE_0_NORMAL);

      than start to send message

      
      	ResponseStatus rsSend = e32ttl.sendFixedMessage(SERVER_ADDH, SERVER_ADDL, SERVER_CHANNEL, buf, size);
      	SERIAL_DEBUG.println(rsSend.getResponseDescription());
      
      	if (rsSend.code==SUCCESS && needAckParam){
      		ackStartTime = millis();
      		needAck = true;
      	}
      
      	return rsSend;
      
      

      I think It’s what you want to know.

      Bye Renzo

       

       

      Renzo Mischianti
      Keymaster

        Hi Ricardo,

        EByte E32 are suitable for your pourpuse.

        I create a little project with WeMos D1 mini (esp8266) and LoRa E32 to control and fill water tank that have similar behaivor:

        • a master with relay to activate pump, a simple oled display to show status an encoder to manage menù;
        • a client that is powered by battery that are in sleep mode and have 2 water sensor level.

        This devices communicate in this manner

        • master send a wake message to a remote E32 that wake up;
        • client check water level sensors;
        • send current level to the master and go to sleep;
        • master receive message and if te tank is not full start pump;
        • when client is waked up by max level sensor send a new message to master with the new status and wait for ACK message;
        • master receive message stop pump and send ACK.

        To manage wake of an Arduino up you can refer to this article Ebyte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and new Arduino shield

         

        For Raspberry I don’t have a library, and you have 2 way:

        • implement base serial command in Raspberry and use a EByte USB TTLlike so (code is not functional example)
          #!/usr/bin/env python
          import time
          import serial
          ser = serial.Serial(
          port='/dev/ttyS0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
          baudrate = 9600,
          parity=serial.PARITY_NONE,
          stopbits=serial.STOPBITS_ONE,
          bytesize=serial.EIGHTBITS,
          timeout=1
          )
          ser.write('')
        • but I’m going to release a REST server implemented in an esp8266 or esp32 that you can control via GET and POST in this way, and receive messages in realtime via WebSocket
          REST server on esp8266 and esp32: introduction
          with this base I create this web interfaceEByte LoRa E32 Manager Custom Home Page

        I think the second way simplify your work a lot, but you must have patience, because I need more time to publish that.

        But I’m here if you need more information.

        Bye Renzo

        in reply to: Can’t use the NeoSWSerial library #6127
        Renzo Mischianti
        Keymaster

          Hi ddv_adm,

          no sorry, the support for that library is not implemented, I don’t use original Stream because I need more method to put on work the device.

          When I’m more free I take a look to the integration.

          Bye Renzo

          Renzo Mischianti
          Keymaster

            Hi Kemran,

            It’s strange I repeat test with my WeMos D1 mini and works correctly

            AP IP address: 192.168.4.1
            SPIFFS opened!
            Ftp server waiting for connection on port 21
            Client connected!
            USER esp8266
            PASS esp8266
            OK. Waiting for commands.
            CWD /
            PWD
            TYPE I
            PASV
            Connection management set to passive
            Data port set to 50009
            MLSD
            ftpdataserver client....
            TYPE A
            PASV
            Connection management set to passive
            Data port set to 50009
            STOR wp-signup.php
            ftpdataserver client....
            Receiving wp-signup.php
            

            Check if you are doing all steps to configure FileZilla..
            and try to give better power supply..

            Bye Renzo

            Renzo Mischianti
            Keymaster

              No no don’t worry the sketch is ready, but I check and I post an esp32 version, here the esp8266 version

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

                Download attached file, there is the complete sketch.

                Bye Renzo

                Renzo Mischianti
                Keymaster

                  Hi Kemran,

                  yes, It’s possible, I attach a simple sketch that do this work.

                  Respect the code from the article

                  FTP server on esp8266 and esp32

                  I add this part

                  // Connect to Wi-Fi network with SSID and password
                  Serial.print("Setting AP (Access Point)…");
                  // Remove the password parameter, if you want the AP (Access Point) to be open
                  WiFi.softAP(ssid, password);
                  
                  IPAddress IP = WiFi.softAPIP();
                  Serial.print("AP IP address: ");
                  Serial.println(IP);
                  
                  
                  Attachments:
                  You must be logged in to view attached files.
                  Renzo Mischianti
                  Keymaster

                    I think there Is no way tuo check that the buffer retrieved Is correct.

                    I only check if there are data to buffer but It isn’t a solution maybe.

                    Bye Renzo

                    in reply to: Arduino OTA upload remotely? Or via LoRa? #6061
                    Renzo Mischianti
                    Keymaster

                      Hi Ludopot,

                      your idea is intesting, basically if you attach a serial device to a serial microcontroller Is possible to manage OTA.

                      I write a simple article to update Arduino via Bluetooth configured as serial pass through.

                      Arduino Remote/wireless Programming

                      the solution can be similar, but more simple with a secondary device.

                      If I find some time I’m going in deep.

                      Bye Renzo

                       

                      Renzo Mischianti
                      Keymaster

                        No E32 doesn’t have RSSI and repeater function.

                        E22 can reach a greater distance with less power:
                        from 3Km of E32 to 4/5Km of E22
                        from 8Km of E32 1W to 10/12Km of E22

                        The packet size of E22 is configurable from 32Kb to 240Kb.

                        It’s also more difficult to find module versione, so for the first test I use a PCB as adapter

                        Ebyte LoRa E22 device for Arduino, esp32 or esp8266 3 devices module SMD
                        Ebyte LoRa E22 device for Arduino, esp32 or esp8266 3 devices module SMD

                        Bye Renzo

                        Renzo Mischianti
                        Keymaster

                          Hehehehhe… you discover me…

                          yes the library is ready and tested,

                          the base commands is the same of library for E32 but there are addictions of the new features like RSSI, configuration for repeater mode packet size increased etc. etc.

                          I start writing documentation, a library without documentation is half work..

                          But probably first I release the “EByte E32 Web Manager“,  a web manager to configure and test E32..

                          EByte LoRa E32 Manager Custom Home Page
                          EByte LoRa E32 Manager Custom Home Page

                           

                          Bye Renzo

                          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??

                                Viewing 15 posts - 976 through 990 (of 1,020 total)