Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. esp8266 for wired solutions

esp8266 for wired solutions

Scheduled Pinned Locked Moved Development
4 Posts 2 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kduinoK Offline
    kduinoK Offline
    kduino
    wrote on last edited by
    #1

    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!

    mfalkviddM 1 Reply Last reply
    0
    • kduinoK kduino

      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!

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • kduinoK Offline
        kduinoK Offline
        kduino
        wrote on last edited by
        #3

        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!

        mfalkviddM 1 Reply Last reply
        0
        • kduinoK kduino

          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!

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @kduino I think you need to define MY_RS485_SWSERIAL as well

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          10

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular