Still no luck with wifi to RS485 bridge

63 views
Skip to first unread message

stef mertens

unread,
Apr 22, 2018, 8:08:02 AM4/22/18
to souliss
Hi,

I still have problems with a simple wifi to rs485 supernode. Tried different scenario's, tried different ESP8266 modules (ESP-01, ESP-201 and a thumbnail ESP8266 module). I even went this fas as to think it might be my Wifi-router, but then i bought another one and still the communication between openhab / soulissapp and the node is terrible (only 1/8 of sent commands fire the logics on the node)

right now i have a gateway on an Arduino Mega (with a T31) - the mega also has connectivity with an RS485 module for future expansion

In my kitchen i have installed an ESP201 module with RS485 module, and an arduino nano node running a simplelight and a switch.

Openhab discovers the node and the typical, but its health is nearly zero and when i send commands to it, it hardly works. Als, when i change the state by physically pushing the button, it's status doesn't change in  openhab.

Soulissapp does not find the typical at all...

Ping times to the ESP module fluctuate between 1ms to sometimes 125ms.

RS485 bus is connected as it should, with TX_enable pin. Previous tests with direct connection to a gateway with RS485 did work.

Here's the code :

Gateway: 

// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"

// Configure the framework
#include "bconf/StandardArduino.h"          // Use a standard Arduino
#include "conf/ethW5100.h"                  // Ethernet through Wiznet W5100
#include "conf/Gateway.h"                   // The main node is the Gateway, we have just one node
#include "conf/usart.h"                      // USART / RS485 transceiver
#include "conf/IPBroadcast.h"               // Use IP Broadcast Communication

#include <OneWire.h> 
#include <DallasTemperature.h>

// Include framework code and libraries
#include <SPI.h>
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE          1
#define USART_TXENPIN           5
#define USARTDRIVER             Serial


/*** All configuration includes should be above this line ***/ 
#include "Souliss.h"

#define TEMPERATURE               0           // This is the memory slot used for the execution of the logic in network_address1
#define DEADBAND                0.05        // Deadband value 5%  

// Define the network configuration according to your router settings
uint8_t ip_address[4]  = {192, 168, 80, 190};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4]  = {192, 168, 80, 1};
#define myvNet_address  ip_address[3]       // The last byte of the IP address (77) is also the vNet address

#define ONE_WIRE_BUS  6

OneWire oneWire(ONE_WIRE_BUS); 
DallasTemperature sensors(&oneWire);
float Temp1;

void setup()
{   
    Initialize();

    // Get the IP address from DHCP
    SetIPAddress(ip_address, subnet_mask, ip_gateway);
    SetAsGateway(myvNet_address); 
    // Define the architecture
    SetAddress(0xAB01, 0xFF00, 0x0000); // set this node as IP supernode
    SetAddress(0xCE01, 0xFF00, 0x0000); // set this node as USART supernode.
    SetAsPeerNode(0xD002,1);
    
    Set_Thermostat(TEMPERATURE);          // Set a logic for the thermostat
    
    // Define output pins
    pinMode(2, OUTPUT);     // Heater (ON/OFF)
    //pinMode(3, OUTPUT);     // Fan 1
    //pinMode(4, OUTPUT);     // Fan 2
    //pinMode(5, OUTPUT);     // Fan 3
}

void loop()
    // Here we start to play
sensors.requestTemperatures();
Temp1 = sensors.getTempCByIndex(0);
    
    EXECUTEFAST() {                     
        UPDATEFAST();   
        
        // Execute the code every 11 time_base_fast       
        FAST_110ms() {  
            // The logic is executed faster than the data acquisition just to have a 
            // prompt answer to the user commands, but the real rate is defined by
            // the temperature measure rate.
        
            // Compare the setpoint from the user interface with the measured temperature
            Logic_Thermostat(TEMPERATURE);
            
            // Start the heater and the fans
            nDigOut(2, Souliss_T3n_HeatingOn, TEMPERATURE);   // Heater
            //nDigOut(3, Souliss_T3n_FanOn1   , TEMPERATURE);   // Fan1
            //nDigOut(4, Souliss_T3n_FanOn2   , TEMPERATURE);   // Fan2
            //nDigOut(5, Souliss_T3n_FanOn3   , TEMPERATURE);   // Fan3
            
            // We are not handling the cooling mode, if enabled by the user, force it back
            // to disable
            if(mOutput(TEMPERATURE) & Souliss_T3n_CoolingOn)
                mOutput(TEMPERATURE) &= ~Souliss_T3n_CoolingOn;
        }
        
        // Execute the code every 101 time_base_fast          
        FAST_910ms()    {
        
            // Acquire temperature from the microcontroller ADC
            ImportAnalog(TEMPERATURE+1,&Temp1);
            //AnalogIn(A0, ANALOGDAQ+1, 0.04, -10); // The raw data is 0-1024, scaled as -10 to +30 Celsius
        }       
        
        // Process data communication
        FAST_GatewayComms();
    }       


ESP bridge: 

/**************************************************************************
    Souliss - Bridge WiFi to RS485
    
    This is the basic example, create a software push-button on Android
    using SoulissApp (get it from Play Store) and bridge to an RS485 peer. 
    
    Load this code on ESP8266 board using the porting of the Arduino core
    for this platform.
        
***************************************************************************/

// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"

// Configure the framework
#include "bconf/MCU_ESP8266.h"              // Load the code directly on the ESP8266
#include "conf/SuperNode.h"
#include "conf/usart.h"                      // USART / RS485 transceiver
#include "conf/IPBroadcast.h"

// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID               "ZOOOOOM2"
#define WiFi_Password           "xxxxxxx"    

// Include framework code and libraries
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE          1
#define USART_TXENPIN           0
#define USARTDRIVER             Serial



#include <ESP8266WiFi.h>
#include <EEPROM.h>

/*** All configuration includes should be above this line ***/ 
#include "Souliss.h"
/*
uint8_t ip_address[4]  = {192, 168, 80, 181};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4]  = {192, 168, 80, 1};
#define myvNet_address  ip_address[3]       
*/

// This identify the number of the LED logic
//#define LL1               0   
//#define LL1bright         1

// **** Define here the right pin for your ESP module **** 
//#define LL1OUT            4


void setup()
{   
    Initialize();
      
 // Connect to the WiFi network and get an address from DHCP
    GetIPAddress();                           
    SetAsGateway(myvNet_dhcp);       // Set this node as gateway for SoulissApp  

    // This is the vNet address for this node, used to communicate with other
    // nodes in your Souliss network
    SetAddress(0xAB02, 0xFF00, 0xAB01);
    SetAddress(0xD001, 0xFF00, 0x0000);
        
    
   // Set_DimmableLight(LL1);        // Define a simple LED light logic
            
    //pinMode(LL1OUT, OUTPUT);         // Use pin as output 
   }

void loop()
    // Here we start to play
                  
        // Here we handle here the communication with Android
        FAST_BridgeComms();    
        //FAST_PeerComms();                                    
    


And finally the node:

// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"

// Configure the framework
#include "bconf/StandardArduino.h"          // Use a standard Arduino
#include "conf/usart.h"                     // USART 

// Include framework code and libraries
#define USARTDRIVER_INSKETCH
#define USART_TXENABLE          1
#define USART_TXENPIN           13
#define USARTDRIVER             Serial

#include "Souliss.h"

// This identify the number of the LED logic
#define LL1               0
#define LL1OUT            7
#define LL1BTN            8



void setup()
{   
    Initialize();
    
    // Set network parameters
    SetAddress(0xD002, 0xFF00, 0xD001);      


Set_SimpleLight(LL1);        // Define a simple LED light logic
            
pinMode(LL1OUT, OUTPUT);         // Use pin as output 
}
void loop()
{
    EXECUTEFAST() {                     
        UPDATEFAST();   
        
        FAST_50ms() {   // We process the logic and relevant input and output every 50 milliseconds
           DigIn(LL1BTN, Souliss_T1n_ToggleCmd, LL1);
           Logic_SimpleLight(LL1);
           DigOut(LL1OUT, Souliss_T1n_Coil, LL1);
                                } 
    }

    FAST_PeerComms();

    START_PeerJoin();
}


Any ideas what could be wrong? I'm pulling my hair out on this one. I made a lot of different arduino's with all different functionality (trv, outdoor sensors, rfid alarm system, ...) and would like to integrate them step by step into my Souliss and openhab system, but then i really need rs485 on my different floors, and it's impossible to draw cabling to all these locations.

Thanks in advance,

Stef

Luca Calcaterra

unread,
Apr 26, 2018, 5:53:23 PM4/26/18
to souliss
I cannot get bridge working too.. My idea is that is requiring a rs485 3.3v tranceiver and not 5v tranceiver. I haven't tried it out because i've only 5v rs485 tranceiver .. have you checked this thing ?

Luca

stef mertens

unread,
Apr 27, 2018, 2:05:31 AM4/27/18
to sou...@googlegroups.com
Hi Luca,

I have done multiple tests, based on 'barebone' ESP, a ESP201 and an ESP12 modules. On 2 of the pcb's i created i have used level shifters to go from the 3.3 to 5v logic. No luck on them eighter.

Grtz, 

Stef

Op do 26 apr. 2018 23:53 schreef Luca Calcaterra <calcate...@gmail.com>:
I cannot get bridge working too.. My idea is that is requiring a rs485 3.3v tranceiver  and not 5v tranceiver. I haven't tried it out because i've only 5v rs485 tranceiver .. have you checked  this thing ?

Luca

--
You received this message because you are subscribed to a topic in the Google Groups "souliss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/souliss/bdY8gjADi8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to souliss+u...@googlegroups.com.
To post to this group, send email to sou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/souliss/7ee67e36-3cca-4a62-b54b-44387ae0f98d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

stef mertens

unread,
May 5, 2018, 3:39:10 AM5/5/18
to souliss
I finally got it somehow to work, with following tweaks:

Started somewhat all over again, built a new PCB with an ESP12, an RS485 module with MAX485 chip, and a new (bidirectional) level shifter. At firts, i saw the health from the node going upwards, and Soulissapp discovering the typical (FINALLY!!!)

BUT! i still had issues with the stability, lots of commands did were not received by the node. For this i set up my extra router, and let the ESP connect to that, so now i have another dedicated wifi network just for Souliss. That works. I think with all the devices on my network, the ESP was flooding. (smartphones, tablets, 2 ESXi servers with multiple virtual machines, ...) 

Allthough sometimes a command still loses, i think it has to do with the low ping times on the ESP, and this issue has nothing to do with souliss. Will get further in to it lateron...

I you need clear schematics on how i built the bridge, let me know. I will draw them and post them, then.

Op vrijdag 27 april 2018 08:05:31 UTC+2 schreef stef mertens:
Hi Luca,

I have done multiple tests, based on 'barebone' ESP, a ESP201 and an ESP12 modules. On 2 of the pcb's i created i have used level shifters to go from the 3.3 to 5v logic. No luck on them eighter.

Grtz, 

Stef

Op do 26 apr. 2018 23:53 schreef Luca Calcaterra <calcate...@gmail.com>:
I cannot get bridge working too.. My idea is that is requiring a rs485 3.3v tranceiver  and not 5v tranceiver. I haven't tried it out because i've only 5v rs485 tranceiver .. have you checked  this thing ?

Luca

--
You received this message because you are subscribed to a topic in the Google Groups "souliss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/souliss/bdY8gjADi8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to souliss+unsubscribe@googlegroups.com.

Di Maio, Dario

unread,
May 5, 2018, 3:45:41 AM5/5/18
to sou...@googlegroups.com

Hi Stef,

if you have a flooding you can try using M1 instead of M3 for the WiFi communication. M3 is broadcast based rather M1 is unicast based.

Dario.

stef mertens

unread,
May 9, 2018, 7:53:03 AM5/9/18
to souliss
Hi Dario, thanks for the hint - i'll look into that!

Op zaterdag 5 mei 2018 09:45:41 UTC+2 schreef Dario Di Maio:
Reply all
Reply to author
Forward
0 new messages