Souliss/OpenHab examples

545 views
Skip to first unread message

Glenn Meyer

unread,
Sep 11, 2015, 6:18:29 AM9/11/15
to souliss
I am succesfully controlling LED's connected to an ESP8266-12E from my OpenHab.
I did this by using the OpenHAB example on the Souliss Github.

I want to add both DHT11 temperatur sensor and light sensor to the ESP, but i just cannot get it to work together with OpenHab using the documentation available.

Can somebody provide me with working examples of both sketch and OpenHab items, where you send data from the sensors to OpenHab?

Thanks in advance.

/Glenn

Di Maio, Dario

unread,
Sep 11, 2015, 6:57:33 AM9/11/15
to sou...@googlegroups.com
Hi,

please paste here your sketch and openHAB configuration, we will fix it together.

Regards,
Dario.

--
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/78bc4dff-c1e7-4ad6-8802-3fe6b49a62bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Glenn Meyer

unread,
Sep 11, 2015, 9:22:37 AM9/11/15
to souliss
Thanks Dario, i appriciate it.

Below is my sketch.

When i leave out the lower section (between the stars) i can control the two LED's attached to my ESP with my OpenHAB remote. But when i include that section the IP is not binded to the ESP.

I use the following .items:
Switch LED1  "LED1" (TestLys) {souliss="T11:0:1", autoupdate="false"}
Switch LED2  "LED2" (TestLys) {souliss="T11:0:2", autoupdate="false"}
Number TestTemp "Temperature [%.1f °C]" <temperature> (TestLys) {souliss="T52:0:0", autoupdate=false} 

In openhab.cfg i use:
souliss:IP_LAN=192.168.0.226
souliss:USER_INDEX=72
souliss:NODE_INDEX=133

Regards
Glenn


// Configure the framework
#include "bconf/MCU_ESP8266.h"          
#include "conf/Gateway.h"                  
#include "conf/IPBroadcast.h"

// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID               "xxx"
#define WiFi_Password           "yyy"  

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

// This identify the number of the LED logic
#define LED1logic          1              
#define LED2logic          2              
#define TEMPERATURE        0

// Define the network configuration according
// to your router settings
uint8_t ip_address
[4]  = {192, 168, 0, 226};
uint8_t subnet_mask
[4] = {255, 255, 255, 0};
uint8_t ip_gateway
[4]  = {192, 168, 0, 1};
#define Gateway_address 77
#define myvNet_address  ip_address[3]  
#define myvNet_subnet   0xFF00
#define myvNet_supern   Gateway_address

// **** Define here the right pin for your ESP module ****
#define    LED1outputPin    5
#define    LED2outputPin    4
#define ANALOG_SENSOR_PIN  A0

void setup()
{  
   
Initialize();

     
// Set network parameters
   
Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway);
   
SetAsGateway(myvNet_address);  
   
   
// Define a simple LED light logic
   
Set_SimpleLight(LED1logic);        
   
Set_SimpleLight(LED2logic);        
   
    pinMode
(LED1outputPin, OUTPUT);  // Power the LED
    pinMode
(LED2outputPin, OUTPUT);  // Power the LED
}

void loop()
{
   
// Here we start to play
    EXECUTEFAST
() {                    
        UPDATEFAST
();  
       
// We process the logic and relevant input
       
// and output every 50 milliseconds
        FAST_50ms
() {  
           
// Drive the LED as per command
           
Logic_SimpleLight(LED1logic);    
           
DigOut(LED1outputPin, Souliss_T1n_Coil, LED1logic);                
           
Logic_SimpleLight(LED2logic);    
           
DigOut(LED2outputPin, Souliss_T1n_Coil, LED2logic);                
       
}
       
// Here we handle here the communication
        FAST_GatewayComms
();                                        
   
}
   
   
// *********************************************
   
// When i put in this section, no TCP/IP address is binded!
    EXECUTESPEEDY
()
   
{
        UPDATESPEEDY
();
       
// Execute the code every 3 times of free MCU      
        SPEEDY_x
(3)
       
{
           
// Acquire data from the microcontroller ADC
           
AnalogIn(ANALOG_SENSOR_PIN, analogRead(ANALOG_SENSOR_PIN), 0.09, 0);   // The raw data is 0-1024, scaled as 0-100% without bias (100 / 1024 = 0.09)
       
}
   
}      
   
// *********************************************
}



Juan Pinto

unread,
Sep 11, 2015, 12:12:28 PM9/11/15
to souliss
T5n use 2 SLOTS, so you need to define:
 
#define LED1logic          2              
#define LED2logic          3              
#define TEMPERATURE        0
 
Regards

Di Maio, Dario

unread,
Sep 11, 2015, 1:47:49 PM9/11/15
to sou...@googlegroups.com
Hi Gleen,

as Juan suggested, not all Logics/Typical use the same number of slots. You can have a reference at the below link,

The EXECUTESPEEDY isn't much used and cannot be used for ESP8266 in that way, that because while your loop() is sleeping the TCP/IP stack of ESP8266 is executed. So you need to have a code that is lazy enough to give time for the stack. Using EXECUTESPEEDY keeps all available resources to sample analog data.

So, there are two ways to proceed:
1) Add in your EXECUTESPEEDY yield(); this explicitly runs the TCP/IP stack. You code will look like this,

    // When i put in this section, no TCP/IP address is binded!
    EXECUTESPEEDY
()
    
{
        yield();
        UPDATESPEEDY
();

        
// Execute the code every 3 times of free MCU       
        SPEEDY_x
(3)
        
{
            
// Acquire data from the microcontroller ADC
            
AnalogIn(ANALOG_SENSOR_PIN, analogRead(ANALOG_SENSOR_PIN), 0.09, 0);   // The raw data is 0-1024, scaled as 0-100% without bias (100 / 1024 = 0.09)
        
} 
    
}   

Don't forget the fix on the typical slots

2) Even if the solution above will work, it doesn't do what you really need. Temperature change slowly and doesn't need to be sampled at such high rate, so you should instead use UPDATESLOW(), here some references:


Let me know if you get it working and please contribute back your sketch, so that we will include a working example for ESP8266 and analog values.

Thanks,
Dario.

--
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.

Glenn Meyer

unread,
Sep 13, 2015, 5:32:05 AM9/13/15
to souliss
Thanks guys. Still struggling with the code, but in the meantime i see issues in OpenHAB that should be addressed:

Souliss is creating an error within OpenHAB as you can see below.
When OpenHAB are reading Souliss parameters, it only reads LED1 and LED2. I would expect TestTemp to be read as well, should'nt it?

My items file:
Switch LED1  "LED1" (TestLys) {souliss="T11:0:2", autoupdate="false"}
Switch LED2  "LED2" (TestLys) {souliss="T11:0:3", autoupdate="false"}
Number TestTemp "Temperature" <temperature> (TestLys) {souliss="T51:0:0", autoupdate=false}

NOTE: LED1 and LED2 WORKS FINE!

2015-09-13 11:15:39.234 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.7.0).
2015-09-13 11:15:44.122 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2015-09-13 11:15:44.558 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2015-09-13 11:15:52.674 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'main.sitemap'
2015-09-13 11:15:53.642 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'main.items'
2015-09-13 11:15:53.752 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2015-09-13 11:15:59.310 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /openhab.app
2015-09-13 11:16:04.212 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'main.rules'
2015-09-13 11:16:05.801 [INFO ] [.b.s.internal.SoulissActivator] - souliss binding has been started.
2015-09-13 11:16:05.803 [INFO ] [.b.s.internal.SoulissActivator] - Load parameter from file: /properties/typicals_value_bytes.properties
2015-09-13 11:16:05.808 [INFO ] [.b.s.internal.SoulissActivator] - Load parameter from file: /properties/commands_OHtoSOULISS.properties
2015-09-13 11:16:05.813 [INFO ] [.s.i.n.typicals.StateTraslator] - ok
2015-09-13 11:16:05.815 [INFO ] [.b.s.internal.SoulissActivator] - Load parameter from file: /properties/states_SOULISStoOH.properties
2015-09-13 11:16:05.816 [INFO ] [.s.i.n.typicals.StateTraslator] - ok
2015-09-13 11:16:05.818 [INFO ] [.b.s.internal.SoulissActivator] - Load parameter from file: /properties/itemsType_SOULISS.properties
2015-09-13 11:16:05.819 [INFO ] [.s.i.n.typicals.StateTraslator] - ok
2015-09-13 11:16:05.820 [INFO ] [.b.s.internal.SoulissActivator] - Load parameter from file: /properties/commands_to_states.properties
2015-09-13 11:16:05.822 [INFO ] [.s.i.n.typicals.StateTraslator] - ok
2015-09-13 11:16:05.875 [INFO ] [s.i.n.typicals.SoulissTypicals] - Add Item: LED1 - Typ: 11, Node: 0, Slot: 2
2015-09-13 11:16:05.876 [INFO ] [s.i.n.typicals.SoulissTypicals] - hashTableItemToAddress <-- [key: LED1 - value: 0 - iBit 2]
2015-09-13 11:16:05.878 [INFO ] [s.i.n.typicals.SoulissTypicals] - hashTableAddressToTypicals <-- [key: 020 - value: org.openhab.binding.souliss.internal.network.typicals.SoulissT11@638808]
2015-09-13 11:16:05.880 [INFO ] [s.i.n.typicals.SoulissTypicals] - Add Item: LED2 - Typ: 11, Node: 0, Slot: 3
2015-09-13 11:16:05.881 [INFO ] [s.i.n.typicals.SoulissTypicals] - hashTableItemToAddress <-- [key: LED2 - value: 0 - iBit 3]
2015-09-13 11:16:05.882 [INFO ] [s.i.n.typicals.SoulissTypicals] - hashTableAddressToTypicals <-- [key: 030 - value: org.openhab.binding.souliss.internal.network.typicals.SoulissT11@18c9964]
2015-09-13 11:16:05.899 [INFO ] [.service.AbstractActiveService] - Souliss Refresh Service has been started
2015-09-13 11:16:05.901 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: IP_LAN = 192.168.0.226
2015-09-13 11:16:05.903 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: NODE_INDEX = 133
2015-09-13 11:16:05.905 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: REFRESH_DBSTRUCT_TIME = 600000
2015-09-13 11:16:05.906 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: REFRESH_HEALTY_TIME = 60000
2015-09-13 11:16:05.907 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: REFRESH_MONITOR_TIME = 500
2015-09-13 11:16:05.909 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: REFRESH_SUBSCRIPTION_TIME = 120000
2015-09-13 11:16:05.910 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: SECURE_SEND_TIMEOUT_TO_REMOVE_PACKET = 30000
2015-09-13 11:16:05.912 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: SECURE_SEND_TIMEOUT_TO_REQUEUE = 5000
2015-09-13 11:16:05.920 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: SEND_DELAY = 1500
2015-09-13 11:16:05.921 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: SEND_MIN_DELAY = 100
2015-09-13 11:16:05.922 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: SERVERPORT =
2015-09-13 11:16:05.924 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: service.pid = org.openhab.souliss
2015-09-13 11:16:05.925 [INFO ] [.o.b.s.internal.SoulissBinding] - PARAMETER: USER_INDEX = 72
2015-09-13 11:16:05.927 [INFO ] [.o.b.s.internal.SoulissBinding] - START
2015-09-13 11:16:05.941 [INFO ] [.o.b.s.i.n.udp.UDPServerThread] - Start UDPServerThread - Server in ascolto sulla porta 59224
2015-09-13 11:16:05.947 [INFO ] [b.s.i.network.typicals.Monitor] - Start MonitorThread
2015-09-13 11:16:05.954 [INFO ] [s.i.network.udp.SendDispatcher] - Start SendDispatcherThread
2015-09-13 11:16:05.958 [INFO ] [.b.s.i.n.t.RefreshSUBSCRIPTION] - Start RefreshSUBSCRIPTIONThread
2015-09-13 11:16:05.960 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Souliss Refresh Service
java.lang.NullPointerException: null
        at org.openhab.binding.souliss.internal.SoulissBinding.execute(SoulissBinding.java:343) ~[na:na]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
2015-09-13 11:16:05.961 [INFO ] [b.s.i.n.typicals.RefreshHEALTY] - Start RefreshDBSTRUCTThread
2015-09-13 11:16:06.035 [INFO ] [b.s.i.n.typicals.RefreshHEALTY] - sendHEALTY_REQUESTframe
2015-09-13 11:16:06.353 [INFO ] [.service.AbstractActiveService] - HTTP Refresh Service has been started
2015-09-13 11:16:07.694 [INFO ] [.b.s.i.n.udp.UDPSoulissDecoder] - function_health_resp
2015-09-13 11:17:06.046 [INFO ] [b.s.i.n.typicals.RefreshHEALTY] - sendHEALTY_REQUESTframe
2015-09-13 11:17:06.174 [INFO ] [.b.s.i.n.udp.UDPSoulissDecoder] - function_health_resp

Di Maio, Dario

unread,
Sep 13, 2015, 11:41:53 AM9/13/15
to sou...@googlegroups.com
I cannot help on the binding side and I will ask Antonino to join the discussion and help on this topic, in the while, if you publish your corrected sketch we can have a look and be sure that your nodes are working in the proper way.

I assume that you haven't an Android device, otherwise a good way is to use SoulissApp (that doesn't need configuration) and have a cross-check on the node side.

Dario.

Antonino Fazio

unread,
Sep 13, 2015, 12:46:17 PM9/13/15
to souliss
For temperature try with T52.

Let me know
Tonino

Antonino Fazio

unread,
Sep 13, 2015, 12:48:13 PM9/13/15
to souliss

Glenn Meyer

unread,
Sep 14, 2015, 2:25:29 AM9/14/15
to souliss
Tonino, the change worked, the item is now obtained:
2015-09-14 08:18:43.491 [INFO ] [s.i.n.typicals.SoulissTypicals] - Add Item: TestTemp - Typ: 52, Node: 0, Slot: 0
2015-09-14 08:18:43.492 [INFO ] [s.i.n.typicals.SoulissTypicals] - hashTableItemToAddress <-- [key: TestTemp - value: 0 - iBit 0]
2015-09-14 08:18:43.493 [INFO ] [s.i.n.typicals.SoulissTypicals] - hashTableAddressToTypicals <-- [key: 000 - value: org.openhab.binding.souliss.internal.network.typicals.SoulissT52@5c6a64]

But i still get an error from the Souliss service:

2015-09-14 08:18:43.510 [INFO ] [.service.AbstractActiveService] - Souliss Refresh Service has been started
2015-09-14 08:18:43.546 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Souliss Refresh Service

java.lang.NullPointerException: null
        at org.openhab.binding.souliss.internal.SoulissBinding.execute(SoulissBinding.java:343) ~[na:na]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
2015-09-14 08:18:43.605 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Souliss Refresh Service

java.lang.NullPointerException: null
        at org.openhab.binding.souliss.internal.SoulissBinding.execute(SoulissBinding.java:343) ~[na:na]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
2015-09-14 08:18:43.664 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Souliss Refresh Service

java.lang.NullPointerException: null
        at org.openhab.binding.souliss.internal.SoulissBinding.execute(SoulissBinding.java:343) ~[na:na]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
2015-09-14 08:18:43.767 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Souliss Refresh Service

java.lang.NullPointerException: null
        at org.openhab.binding.souliss.internal.SoulissBinding.execute(SoulissBinding.java:343) ~[na:na]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

Regards
Glenn

Glenn Meyer

unread,
Sep 14, 2015, 3:29:24 AM9/14/15
to souliss
Dario, unfortunately i don't have an Android phone.

I tried to simplify the code, so this is what i have:

void loop()
{
  EXECUTEFAST
() {                    
    UPDATESLOW
();
    SPEEDY_x
(3) {
      delay
(1000);

     
Logic_SimpleLight(LED1logic);    
     
DigOut(LED1outputPin, Souliss_T1n_Coil, LED1logic);                
     
Logic_SimpleLight(LED2logic);    
     
DigOut(LED2outputPin, Souliss_T1n_Coil, LED2logic);
               
     
Serial.print("Analog value: ");
     
Serial.println(analogRead(ANALOG_SENSOR_PIN));
     
AnalogIn(ANALOG_SENSOR_PIN, analogRead(ANALOG_SENSOR_PIN), 1, 0);
   
}
    FAST_GatewayComms
();                                        
 
}
}


If i use Yield(), the unit will freeze at some points, i can only get it to work all times if i use delay().

As you can see i do readouts, and i get correct values from the sensor.

In OpenHAB i get this:
- TestTemp state updated to 0.0
- LED2 state updated to OFF
- LED1 state updated to OFF
So i looks like it recieves zero from the node.

I will try to get a hold of an Android phone tomorrow to do some further tests.

Thanks.

/Glenn

Flavio P.

unread,
Sep 14, 2015, 3:33:48 AM9/14/15
to sou...@googlegroups.com
Hi Glenn,
you can try bluestacks  to play Android in your PC and use SoulissApp.

Regards

--
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.

For more options, visit https://groups.google.com/d/optout.



--
P ********* Consideriamo l'ambiente prima di stampare questa e-mail *** Think about environment before printing *********
Il contenuto di questo messaggio e-mail è privato e riservato al solo destinatario. L'utilizzo non autorizzato può costituire reato. Se ricevuto erroneamente siete pregati di cancellarlo e comunicarci via e-mail l'errata ricezione.

Di Maio, Dario

unread,
Sep 14, 2015, 8:48:10 AM9/14/15
to sou...@googlegroups.com
May I suggest you to don't run the ADC so fast? 

Dario.

--

Glenn Meyer

unread,
Sep 18, 2015, 1:59:35 AM9/18/15
to souliss
Dario,

I installed Souliss app. Maybe i am missing something, but cannot see how this is functioning. I Googled about the app, trying to find a guide, and also read the Github. The app doesnt even look the same as pictures i find on blogs, etc. (yes, its the correct one :-) ), maybe it was recently updated.
Anyway, Souliss status is green, and if i go into "manual" node0 says it can see 23 typicals. If i click node0 all typicals says "unknown" and "TOIMPLEMENT".
I do have connection to the node, cause i can control it from OpenHAB.
I tried to find documentation on how to use the app to control the different typicals, but failed to do so.

Regards

Glenn


Den søndag den 13. september 2015 kl. 17.41.53 UTC+2 skrev Dario Di Maio:

Di Maio, Dario

unread,
Sep 18, 2015, 6:25:29 AM9/18/15
to sou...@googlegroups.com
Too strange, this means that your sketches has a wrong assingment of the Typicals.

Please paste again your sketch.

Dario.

--
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.

Antonino Fazio

unread,
Sep 18, 2015, 5:44:20 PM9/18/15
to souliss
Have you originale openhab.cfg?
Reply all
Reply to author
Forward
0 new messages