ESP8266 to RS485 example

2,850 views
Skip to first unread message

farbod Shajjarian

unread,
Nov 7, 2015, 12:01:38 PM11/7/15
to souliss
Hi everyone.
after creating a new topic about having problems with "range extender example", thanks to Dario and others i found out that it is better to use esp instead of nrf.
after waiting a few weeks i finally got my esp modules. i used the esp modules as standalone gateway and standalone peer and i am pretty sure that my hardware is okay and i know how to program the esp.
now i need to run the esp8266 to rs485 example.
there are 3 sketches there (gateway , bridge , peer) and none of them compiles in arduino ide because its incomplete

gateway:
// 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
#include "conf/IPBroadcast.h"               // Use IP Broadcast Communication

// Include framework code and libraries
#include <SPI.h>
#include "Souliss.h"

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

void setup()
{   
    Initialize();

    // Set network parameters
    Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway);
    SetAsGateway(myvNet_address);                                   // Set this node as gateway for SoulissApp  

    // Set IPBroadcast vNet Address    
    SetAddress(0xAB01, 0xFF00, 0x0000);

    // This node as gateway will get data from the Peer
    SetAsPeerNode(0xD002, 1);
    SetAsPeerNode(0xD102, 2);
}
error:


C:\Users\user\AppData\Local\Temp\build3536862247418848190.tmp/core.a(main.cpp.o): In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status
Error compiling.

bridge:
// Configure the framework
#include "bconf/MCU_ESP8266.h"              // Load the code directly on the ESP8266
#include "conf/SuperNode.h"                   // The main node is the Gateway, we have just one node
#include "conf/usart.h"                      // USART 
#include "conf/IPBroadcast.h"

// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID               "mywifi"
#define WiFi_Password           "mypassword"    

// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include "Souliss.h"

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);
}

void loop()
{
    ...

    FAST_BridgeComms();
}
error:

sketch_nov07b.ino: In function 'void loop()':
sketch_nov07b:33: error: expected primary-expression before '...' token
sketch_nov07b:33: error: expected ';' before '...' token
expected primary-expression before '...' token
peer:
// Configure the framework
#include "bconf/StandardArduino.h"          // Use a standard Arduino
#include "conf/usart.h"                     // USART 

// Include framework code and libraries
#include <SPI.h>
#include "Souliss.h"

void setup()
{   
    Initialize();

    // Set network parameters
    SetAddress(0xD002, 0xFF00, 0xD001);      
}

void loop()
{
    ...

    FAST_PeerComms();

    START_PeerJoin();
}
error:
sketch_nov07b.ino: In function 'void loop()':
sketch_nov07b:19: error: expected primary-expression before '...' token
sketch_nov07b:19: error: expected ';' before '...' token
expected primary-expression before '...' token


could you please help me complete these example sketches to run this example ?
 
sorry for the long post and thanks in advance.

Di Maio, Dario

unread,
Nov 7, 2015, 2:12:36 PM11/7/15
to sou...@googlegroups.com

There are dedicated examples here

https://github.com/souliss/souliss/tree/friariello/examples/WiFi

Dario.

From Mobile.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, 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/356c8fdb-20c2-4c2f-82a9-b3906bd1b42b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

farbod Shajjarian

unread,
Nov 10, 2015, 10:24:59 AM11/10/15
to souliss
Dear dario.
thanks for the link but i couldnt understand anything from it. so i read the wiki page by page and tried two write some sketch from begining. i am trying to connect to arduino
gateway is uno with ethernet shield. node is uno connected using crossed tx and rx.


gateway:

#include "bconf/StandardArduino.h"          
#include "conf/ethW5100.h"                 
#include "conf/Gateway.h"    
#include "conf/usart.h"  
#include <SPI.h>
#include "Souliss.h"

#define RED          0    
#define BLUE          1    

#define Gateway_address 50
#define myvNet_address  50       
#define myvNet_subnet   0xFF00
#define myvNet_supern   Gateway_address
uint8_t ip_address[4]  = {192, 168, 1, 50};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4]  = {192, 168, 1, 1};

void setup() {

Initialize();
Souliss_SetIPAddress(ip_address,subnet_mask,ip_gateway);
SetAsGateway(myvNet_address);
    SetAddress(0xCE01, 0xFF00, 0x0000);
    SetAsPeerNode(0xCE02, 1);

    Set_T11(RED);       
    
    Set_SimpleLight(BLUE);      
    
    // We connect a pushbutton between 5V and pin2 with a pulldown resistor 
    // between pin2 and GND, the LED is connected to pin9 with a resistor to
    // limit the current amount
    pinMode(2, INPUT);               
    pinMode(9, OUTPUT);                
    pinMode(3, INPUT);                 
    pinMode(7, OUTPUT);               


}

void loop() { 
    // Here we start to play
    EXECUTEFAST() {                     
        UPDATEFAST();   
        
        FAST_50ms() {   

            DigIn(2, Souliss_T1n_ToggleCmd, RED);        
            Logic_T11(RED);                         
            DigOut(9, Souliss_T1n_Coil, RED);               
            DigIn(3, Souliss_T1n_ToggleCmd, BLUE);           
            Logic_T11(BLUE);                         
            DigOut(7, Souliss_T1n_Coil, BLUE);                /
          
        } 
              
        // Here we handle here the communication with Android, commands and notification
        // are automatically assigned to MYLEDLOGIC
        FAST_GatewayComms();                                        
        
    }


and node:


#include "bconf/StandardArduino.h"
#include "conf/usart.h"
#include <SPI.h>
#include "Souliss.h"


#define RED 0
#define BLUE 1

void setup() {
 

Initialize();

 
SetAddress(0xCE02, 0xFF00, 0x0000);



 
Set_T11(RED);
 
 
Set_SimpleLight(BLUE);
 

 pinMode
(2, INPUT);
 pinMode
(9, OUTPUT);
 pinMode
(3, INPUT);
 pinMode
(7, OUTPUT);



}


void loop() {
 

 EXECUTEFAST
() {
 UPDATEFAST
();
 
 FAST_50ms
() {


 

 
Logic_T11(RED);
 
DigOut(9, Souliss_T1n_Coil, RED);



 
Logic_T11(BLUE);
 
DigOut(7, Souliss_T1n_Coil, BLUE);
 
 
}
 

 FAST_PeerComms
();
 START_PeerJoin
();
 
 
}
}





could you guys please tell me whats wrong ??

Di Maio, Dario

unread,
Nov 10, 2015, 11:18:40 AM11/10/15
to sou...@googlegroups.com

The connection looks ok, is the usb cable connected? If so, disconnect it.

Dario.

From Mobile.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
To post to this group, send email to sou...@googlegroups.com.

farbod Shajjarian

unread,
Nov 10, 2015, 11:33:05 AM11/10/15
to souliss
thanks for your quick response.
i disconnected the usb and powered both boards unig Vin and GND pins.
i still can not see or control the peer (only a zero health no typicall node in the app)
could you please take a look at my sketch? specially the peer ..

Di Maio, Dario

unread,
Nov 10, 2015, 1:40:01 PM11/10/15
to sou...@googlegroups.com

Change this
SetAddress(0xCE02, 0xFF00, 0x0000);

With

SetAddress(0xCE02, 0xFF00, 0xCE01);

From Mobile.

farbod Shajjarian

unread,
Nov 11, 2015, 2:24:52 AM11/11/15
to souliss
still not working :( 

Di Maio, Dario

unread,
Nov 11, 2015, 2:26:42 AM11/11/15
to sou...@googlegroups.com

There are example in the example folder, but looks like not a problem of your sketch but of your hardware.

Are you using official Arduino/Genuino boards or clones?

Dario.

From Mobile.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
To post to this group, send email to sou...@googlegroups.com.

farbod Shajjarian

unread,
Nov 13, 2015, 7:15:35 AM11/13/15
to souliss
well , i have access to only one supplier which sells arduino about 5 dollars when converted to USD which i think is not official comparing to 21$ arduino website.
but i have no other choice and i have to manage using it somehow because i have a lot of limit in buying hardware (even the other time i was told its better to use esp instead of nrf, i had to wait a few weeks to get the esp board) 

i have done these setups lately:
arduino ethernet gateway + esp peer = ok
esp gateway + esp peer = ok
arduino gateway + arduino peer (uart) = not ok ---> maybe ethernet shield interferes with uart??
esp gateway + arduino peer (uart) = not ok

so i think my addressing and headers are okay and there is a problem with my uart connection
in the last setup (esp gateway + arduino peer (uart)) when i opened soulissapp after some time it would load the peer node and its typical (simple led)
but it acts strange. the on off toggle is unresponsive or works really bad, and the node health (which i dont know how is calculated) is always less than half.

so i think i have to connect the nodes with another way than wifi or rf or ethernet, or i should use standalone esp nodes which i think i will have some limits using it..


Luca Calcaterra

unread,
Feb 15, 2018, 9:10:14 AM2/15/18
to souliss
Have you fixed it ? 

I'm trying to have the configuration esp gateway + arduino peer (uart)  but cannot get to work (i want to cut ethernet, it's possible? ? Thanks
Luca
Reply all
Reply to author
Forward
0 new messages