esp8266 for wired solutions



  • Hi,
    I am just wondering, if it would be possible to use the esp8266 chip for wired projects with RS485. My intention is to use the form factor as well as power and mem space for small projects. Furthermore it would be possible to start the ESP with wlan connection for possible OTA update.
    Because of the different softwareSerials tried to include the settings for ESP, but was not successful.
    Please have a look. Do you see any problem in the following sketch files?

    1. MyTransportRS485.cpp:
    #if defined(MY_RS485_SWSERIAL)
    SoftwareSerial& _dev = MY_RS485_SWSERIAL;
    #elif defined(MY_RS485_ESPSERIAL)
    SoftwareSerialESP& _dev = MY_RS485_ESPSERIAL;
    #elif defined(__linux__)
    SerialPort _dev = SerialPort(MY_RS485_HWSERIAL);
    #elif defined(MY_RS485_HWSERIAL)
    HardwareSerial& _dev = MY_RS485_HWSERIAL;
    #else
    AltSoftSerial _dev;
    #endif
    
    1. MotionSensorESP sample:
    // ESP Software Serial
    #include <SoftwareSerialESP.h>
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable RS485 transport layer
    #define MY_RS485
    
    // Define this to enables DE-pin management on defined pin
    #define MY_RS485_DE_PIN 2
    
    // Set RS485 baud rate to use
    #define MY_RS485_BAUD_RATE 9600
    
    // Enable this if RS485 is connected to a hardware serial port
    //#define MY_RS485_HWSERIAL Serial1
    //#define MY_RS485_ESPSERIAL
    #include <MySensors.h>
    SoftwareSerial swESP(14, 12, false, 256); 
    #define MY_RS485_ESPSERIAL swESP
    

    Now what is the output? The serial monitor tells me:

    In file included from /Documents/Arduino/libraries/MySensors-development/drivers/AltSoftSerial/AltSoftSerial.cpp:32:0,
                     from /Documents/Arduino/libraries/MySensors-development/MySensors.h:309,
                     from /Documents/Arduino/MotionSensorESP_RS485/MotionSensorESP_RS485.ino:74:
    /Documents/Arduino/libraries/MySensors-development/drivers/AltSoftSerial/config/AltSoftSerial_Boards.h:136:2: error: #error "Please define your board timer and pins"
     #error "Please define your board timer and pins"
      ^
    exit status 1
    

    Unfortunately I dont know where the AltSoftSerial is chosen. It is not included because of my definitions (as you can see above). So if it is not used, why I need to define boards? Any idea?
    Thanks for your help!


  • Mod

    @kduino the MY_RS485_ESPSERIAL define in your sketch needs to be before include MySensors.h



  • thank you for the important hint.
    Unfortunately it didn't solve the failure message. For my understanding the altsoftserial shouldn't be called since MY_RS485_ESPSERIAL is defined.

    My code looks like this:

    // ESP Software Serial
    #include <SoftwareSerialESP.h>
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    // Enable RS485 transport layer
    #define MY_RS485
    // Define this to enables DE-pin management on defined pin
    #define MY_RS485_DE_PIN 2
    // Set RS485 baud rate to use
    #define MY_RS485_BAUD_RATE 9600
    SoftwareSerial swESP(14, 12, false, 256); 
    #define MY_RS485_ESPSERIAL swESP
    #include <MySensors.h>
    

    My error message looks like this:

    In file included from /Documents/Arduino/libraries/MySensors-development/MySensors.h:311:0,
                     from /Users/macmuc/Documents/Arduino/MotionSensorESP_RS485/MotionSensorESP_RS485.ino:78:
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp:93:1: error: 'AltSoftSerial' does not name a type
     AltSoftSerial _dev;
     ^
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp: In function 'bool _serialProcess()':
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp:132:7: error: '_dev' was not declared in this scope
      if (!_dev.available()) {
           ^
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp:136:8: error: '_dev' was not declared in this scope
      while(_dev.available()) {
            ^
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp: In function 'bool transportSend(uint8_t, const void*, uint8_t, bool)':
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp:270:3: error: '_dev' was not declared in this scope
       _dev.write(SOH);
       ^
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp:272:2: error: '_dev' was not declared in this scope
      _dev.write(to);  // Destination address
      ^
    In file included from /Documents/Arduino/libraries/MySensors-development/MySensors.h:311:0,
                     from /Documents/Arduino/MotionSensorESP_RS485/MotionSensorESP_RS485.ino:78:
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp: In function 'bool transportInit()':
    /Documents/Arduino/libraries/MySensors-development/hal/transport/MyTransportRS485.cpp:320:2: error: '_dev' was not declared in this scope
      _dev.begin(MY_RS485_BAUD_RATE);
      ^
    exit status 1
    

    Thank you for your opinion!


  • Mod

    @kduino I think you need to define MY_RS485_SWSERIAL as well


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 1
  • 3
  • 1
  • 2

14
Online

11.4k
Users

11.1k
Topics

112.7k
Posts