So I was trying to make a souliss network using :
- arduino mega and ethernet shield w5100 as gateway
- Esp8266 Wemos shield as peer node
- arduino mega and ethernet shield w5100 as peer node
the idea was i wanna make a wireless lamp switch using esp 8266 wemos as a remote switch, so i can switch the lamp on/off ( for example using LED in a breadboard) from either the gateway arduino and peer arduino, the result was great, i can switch the led on and off wirelessly using the esp8266 wemos, but the main problem was when using the souliss apps on android i can only switch on and off the led on the gateway arduino side, but not on the peer arduino side, i dont know why and the health bar ont the peer node was also low, can anyone check what's wrong on my codes or if there's something missing, thanks a lot
/**************************************************************************
Souliss - Dynamic Arduino Gateway
It handle two lights located on two different boards and act them together
if receive a command from the push button. Control from Android is also
available.
Run this code on one of the following boards:
- Arduino Ethernet (W5100)
- Arduino with Ethernet Shield (W5100)
As option you can run the same code on the following, just changing the
relevant configuration file at begin of the sketch
- Arduino with ENC28J60 Ethernet Shield
- Arduino with W5200 Ethernet Shield
- Arduino with W5500 Ethernet Shield
***************************************************************************/
// 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/Webhook.h" // Enable DHCP and DNS
#include "conf/IPBroadcast.h" //NEW ADD
// Include framework code and libraries
#include <SPI.h>
#include <EEPROM.h> //NEW ADD
#include "Souliss.h"
// This identify the number of the LED logic
#define FLAMP 0 // This identify the number of the logic on this node
#define PEERLAMP 0 // This identify the number of the logic on peer node
#define Souliss_T1n_ToggleCmd 0x01
#define Souliss_T1n_Coil 0x01
void setup()
{
Initialize();
// Get the IP 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
// Set IPBroadcast vNet Address
SetAddress(0xAB01, 0xFF00, 0x0000);
// This node as gateway will get data from the Peer
SetAsPeerNode(0xAB02, 1);
SetAsPeerNode(0xAB03, 2);
Set_SimpleLight(FLAMP); // Define a simple LED light logic
// 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); // Hardware pulldown required
pinMode(4, OUTPUT); // Power the LED
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_50ms() { // We process the logic and relevant input and output every 50 milliseconds
if(DigIn(2, Souliss_T1n_ToggleCmd, FLAMP)) // Use the pin2 as ON/OFF toggle command
Send(0xAB02, PEERLAMP, Souliss_T1n_ToggleCmd); // and replicate the command on the peer node
Logic_SimpleLight(FLAMP); // Drive the LED as per command
DigOut(4, Souliss_T1n_Coil, FLAMP); // Use the pin9 to give power to the LED according to the logic
}
// Here we handle here the communication with Android, commands and notification
// are automatically assigned to FLAMP
FAST_GatewayComms();
}
}
/**************************************************************************
Souliss - DynmicArduinoPeer
It handle two lights located on two different boards and act them together
if receive a command from the push button. Control from Android is also
available.
Run this code on one of the following boards:
- Arduino Ethernet (W5100)
- Arduino with Ethernet Shield (W5100)
As option you can run the same code on the following, just changing the
relevant configuration file at begin of the sketch
- Arduino with ENC28J60 Ethernet Shield
- Arduino with W5200 Ethernet Shield
- Arduino with W5500 Ethernet Shield
***************************************************************************/
// 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/Webhook.h" // Enable DHCP and DNS
#include "conf/IPBroadcast.h" //NEW ADD
// Include framework code and libraries
#include <SPI.h>
#include <EEPROM.h> //NEW ADD
#include "Souliss.h"
// This identify the number of the LED logic
#define FLAMP_1 0 // This ident-ify the number of the logic on this node
#define PEERLAMP_1 0 // This identify the number of the logic on peer node
#define Souliss_T1n_ToggleCmd 0x01
#define Souliss_T1n_Coil 0x01
void setup()
{
Initialize();
// Get the IP address from DHCP
GetIPAddress();
// This is the vNet address for this node, used to communicate with other
// nodes in your Souliss network
SetAddress(0xAB03, 0xFF00, 0x0000);
Set_SimpleLight(FLAMP_1); // Define a simple LED light logic
// 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(0, INPUT); // Hardware pulldown required
pinMode(5, OUTPUT); // Power the LED
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_50ms() { // We process the logic and relevant input and output every 50 milliseconds
if(DigIn(0, Souliss_T1n_ToggleCmd, FLAMP_1)) // Use the pin2 as ON/OFF toggle command
Send(0xAB02, PEERLAMP_1, Souliss_T1n_ToggleCmd); // and replicate the command on the peer node
Logic_SimpleLight(FLAMP_1); // Drive the LED as per command
DigOut(5, Souliss_T1n_Coil, FLAMP_1); // Use the pin9 to give power to the LED according to the logic
}
// Here we handle here the communication with Android, commands and notification
// are automatically assigned to FLAMP
FAST_PeerComms();
START_PeerJoin();
}
}
/**************************************************************************
Souliss - Dynamic ESP Peer
It handle two lights located on two different boards and act them together
if receive a command from the push button. Control from Android is also
available.
Run this code on one of the following boards:
- Arduino Ethernet (W5100)
- Arduino with Ethernet Shield (W5100)
As option you can run the same code on the following, just changing the
relevant configuration file at begin of the sketch
- Arduino with ENC28J60 Ethernet Shield
- Arduino with W5200 Ethernet Shield
- Arduino with W5500 Ethernet Shield
***************************************************************************/
// 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/DynamicAddressing.h" // NEW ADD
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "TP-LINK_96ED10"
#define WiFi_Password "81299430"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h> // NEW ADD
#include "Souliss.h"
// This identify the number of the LED logic
#define FLAMP 0 // This ident-ify the number of the logic on this node
#define PEERLAMP 0 // This identify the number of the logic on peer node
#define FLAMP_1 0 // This ident-ify the number of the logic on this node
#define PEERLAMP_1 0 // This identify the number of the logic on peer node
#define Souliss_T1n_ToggleCmd 0x01
#define Souliss_T1n_Coil 0x01
void setup()
{
Initialize();
// Connect to the WiFi network and get an address from DHCP
GetIPAddress();
// This is the vNet address for this node, used to communicate with other
// nodes in your Souliss network
SetAddress(0xAB02, 0xFF00, 0xAB01);
Set_SimpleLight(FLAMP); // Define a simple LED light logic
pinMode(2, INPUT);
pinMode(4, OUTPUT); // Use pin as output
// This is the vNet address for this node, used to communicate with other
// nodes in your Souliss network
SetAddress(0xAB02, 0xFF00, 0xAB03);
Set_SimpleLight(FLAMP_1); // Define a simple LED light logic
pinMode(0, INPUT);
pinMode(5, OUTPUT); // Use pin as output
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_50ms() { // We process the logic and relevant input and output every 50 milliseconds
if(DigIn(2,Souliss_T1n_ToggleCmd, FLAMP))
Send(0xAB01, PEERLAMP, Souliss_T1n_ToggleCmd); // and replicate the command on the peer node
Logic_SimpleLight(FLAMP);
DigOut(4, Souliss_T1n_Coil,FLAMP);
if(DigIn(0,Souliss_T1n_ToggleCmd, FLAMP_1))
Send(0xAB03, PEERLAMP_1, Souliss_T1n_ToggleCmd); // and replicate the command on the peer node
Logic_SimpleLight(FLAMP_1);
DigOut(5, Souliss_T1n_Coil,FLAMP_1);
}
}
// Here we handle here the communication with Android
FAST_PeerComms();
}