/*This code is rund on a mega2560 with a wiznet5100 ethenet interface. It is talking to openhab with the native binding. It connects to mulitiple other nodes over ethernet.*/// Define the type of board, available values and their meaning are listed in QuickCfg.h#include "bconf/inSketch.h"#define QC_BOARDTYPE 0x04 // Arduino with Ethernet Shield (W5100)#define QC_GATEWAYTYPE 0x02 // Gateway and Data Persistance
#include "Souliss.h"#include "SpeakEasy.h" // Is a library to code easy Souliss examples#include <SPI.h>
// Define the network configurationuint8_t ip_address[4] = {192, 168, 178, 17};uint8_t subnet_mask[4] = {255, 255, 255, 0};uint8_t ip_gateway[4] = {192, 168, 178, 1}; //this is the ip network gateway not the vnet gateway//define vnet address here. used later to set the node number#define Gateway_vNetAddress 17 // The vNet address for an Ethernet IP node is the last // number of the IP address#define kidsroom 13 //need an entry here for each peer on the entire network
// Define logics to run on the node#define LIGHT 0#define TEMPERATURE 2#define HUMIDITY 4
// Setup the DHT sensor#define DHT_id1 1#define DEADBAND 0.05ssDHT11_Init(2, DHT_id1);
void setup(){ // Setup the network configuration Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway); SetAsGateway(Gateway_vNetAddress); //make this a gateway // Last byte of the IP address is the vNet address SetAsPeerNode(kidsroom,1); //this is the node number // Define the logics for this node(gateway node) Souliss_SetT11(memory_map, LIGHT); Souliss_SetT52(memory_map, TEMPERATURE); Souliss_SetT53(memory_map, HUMIDITY); // Define inputs, outputs pins // Pushbutton to power ON and the OFF the LIGHT (pulldown required) pinMode(13, OUTPUT); // Output to control the LIGHT (relay)
// Init the DHT sensor ssDHT_Begin(DHT_id1); //Serial.begin(9600);}
void loop(){ // Here we start to play EXECUTEFAST() { UPDATEFAST(); FAST_GatewayComms();
FAST_110ms() { } FAST_510ms() { // We check incoming communication data every 510 milliseconds
Logic_SimpleLight(LIGHT); // Execute the logic for LIGHT ssDigOut(13, Souliss_T1n_Coil, LIGHT); // Control the pin as per LIGHT logic
}
FAST_1110ms() { Souliss_Logic_T52(memory_map, TEMPERATURE, DEADBAND, &data_changed); Souliss_Logic_T53(memory_map, HUMIDITY, DEADBAND, &data_changed); } } EXECUTESLOW() { UPDATESLOW();
SLOW_70s(){ // Read temperature value from DHT sensor and convert from single-precision to half-precision float temperature = ssDHT_readTemperature(DHT_id1); Souliss_ImportAnalog(memory_map, TEMPERATURE, &temperature); } SLOW_90s() { // Read humidity value from DHT sensor and convert from single-precision to half-precision float humidity = ssDHT_readHumidity(DHT_id1); Souliss_ImportAnalog(memory_map, HUMIDITY, &humidity); } } }
/* This code is placed on a promini with 328p controller. It uses a enc28j.. ethernet card on SPI. It talks to openhab through the gateway Interface on a mega2560*/
// Define the type of board, available values and their meaning are listed in QuickCfg.h#include "bconf/inSketch.h"#include "bconf/SmallNetwork.h"#define QC_BOARDTYPE 0x05 // Arduino with enc
#include "Souliss.h"#include "SpeakEasy.h" // Is a library to code easy Souliss examples#include <SPI.h>
// Define the network configurationuint8_t ip_address[4] = {192, 168, 178, 13};uint8_t subnet_mask[4] = {255, 255, 255, 0};uint8_t ip_gateway[4] = {192, 168, 178, 1};
#define Gateway_vNetAddress 17 // The vNet address for an Ethernet IP node is the last // number of the IP address#define Peer_vNetAddress 13
// Define logics to run on the node#define LIGHT 0 //these are typeicals. You need to allow of the number of slots used for each typical#define TEMPERATURE 2#define HUMIDITY 4#define PIR 6 //this is a bit based typical#define Reed1 7#define Reed2 8#define In1 16#define In2 17#define PWMout 9#define Relay1 11 //this is a bit based typical#define Relay2 12#define Relay3 13#define Relay4 14#define Relay5 15
// Setup the DHT sensor#define DHT_id1 1 //reference not pin number#define DEADBAND 0.05ssDHT11_Init(3, DHT_id1); //pin and a name// define the shared memory map
void setup(){ // Setup the network configuration // // The vNet address will be equal to the last byte of the IP address // with the most significant one at zero, so in this case 0x0011. // Board reply to pings at 192.168.178.17 Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway); //SetAsGateway(Gateway_vNetAddress); // Last byte of the IP address is the vNet address //SetAsPeerNode(Peer_vNetAddress,1); // Define the logics for this node Souliss_SetT51(memory_map, LIGHT); Souliss_SetT52(memory_map, TEMPERATURE); Souliss_SetT53(memory_map, HUMIDITY); Souliss_SetT13(memory_map, PIR); Souliss_SetT13(memory_map, Reed1); Souliss_SetT13(memory_map, Reed2); Souliss_SetT13(memory_map, In1); Souliss_SetT13(memory_map, In2); Souliss_SetT12(memory_map, Relay1); Souliss_SetT12(memory_map, Relay2); Souliss_SetT12(memory_map, Relay3); Souliss_SetT12(memory_map, Relay4); Souliss_SetT12(memory_map, Relay5); Souliss_SetT19(memory_map, PWMout); // Define inputs, outputs pins pinMode(4, INPUT); //pir INPUT pinMode(1, INPUT); //REED SWITCH pinMode(2, INPUT); //REED SWITCH pinMode(16, INPUT); //AC INPUT pinMode(17, INPUT); //AC INPUT pinMode(9, OUTPUT); //PWM pinMode(6, OUTPUT); //RELAY1 pinMode(7, OUTPUT); //RELAY2 pinMode(8, OUTPUT); //RELAY3 pinMode(5, OUTPUT); //RELAY4 pinMode(15, OUTPUT); //RELAY5
// Init the openHAB HTTP/XML Interface// openHABInit(mymap); // Init the DHT sensor ssDHT_Begin(DHT_id1); //Serial.begin(9600);}
void loop(){ // Here we start to play EXECUTEFAST() { UPDATEFAST(); FAST_PeerComms();
FAST_110ms() { // We check the openHAB HTTP/XML interface every 70 milliseconds Souliss_Logic_T19(memory_map, PWMout, &data_changed); analogWrite(9, Souliss_Output(memory_map, PWMout)); } FAST_510ms() { // We check incoming communication data every 510 milliseconds // Control the LIGHT ssDigIn(16, Souliss_T1n_OnCmd, Relay1); // Use the in1 as ON/OFF command for light on first relay..fast ssDigIn(16, Souliss_T1n_OnCmd, In1); // to make visible on input ssDigIn(17, Souliss_T1n_OnCmd, In2); // Use the in1 as ON/OFF command for light on first relay..fast ssDigIn(1, Souliss_T1n_OnCmd, Reed1); // ssDigIn(2, Souliss_T1n_OnCmd, Reed2); // ssDigIn(4, Souliss_T1n_OnCmd, PIR); //
// execute the logic Souliss_Logic_T12(memory_map, Relay1, &data_changed); // Execute the logic for relay Souliss_Logic_T12(memory_map, Relay2, &data_changed); // Execute the logic for relay Souliss_Logic_T12(memory_map, Relay3, &data_changed); // Execute the logic for relay Souliss_Logic_T12(memory_map, Relay4, &data_changed); // Execute the logic for relay Souliss_Logic_T12(memory_map, Relay5, &data_changed); // Execute the logic for relay //make the pins move Souliss_DigOut(6, Souliss_T1n_Coil, memory_map, Relay1); // Control the pin as per logic Souliss_DigOut(7, Souliss_T1n_Coil, memory_map, Relay2); // Control the pin as per logic Souliss_DigOut(8, Souliss_T1n_Coil, memory_map, Relay3); // Control the pin as per logic Souliss_DigOut(5, Souliss_T1n_Coil, memory_map, Relay4); // Control the pin as per logic Souliss_DigOut(15, Souliss_T1n_Coil, memory_map, Relay5); // Control the pin as per logic
}
FAST_1110ms() { Souliss_Logic_T52(memory_map, TEMPERATURE, DEADBAND, &data_changed); Souliss_Logic_T53(memory_map, HUMIDITY, DEADBAND, &data_changed); Souliss_Logic_T51(memory_map, LIGHT, DEADBAND, &data_changed); } } EXECUTESLOW() { UPDATESLOW();
Souliss_T16_Timer(memory_map, PWMout);
SLOW_70s(){ // Read temperature value from DHT sensor and convert from single-precision to half-precision float temperature = ssDHT_readTemperature(DHT_id1); Souliss_ImportAnalog(memory_map, TEMPERATURE, &temperature); //read ldr and map Souliss_AnalogIn(A0, memory_map, LIGHT, 0.09, 0); // The raw data is 0-1024, scaled as 0-100% without bias (100/1024 = 0.09) } SLOW_90s() { // Read humidity value from DHT sensor and convert from single-precision to half-precision float humidity = ssDHT_readHumidity(DHT_id1); Souliss_ImportAnalog(memory_map, HUMIDITY, &humidity); } } }
Hi Jason,
Your code looks ok, does all the typicals are shown as unknown? Could you please attach a screenshot from SoulissApp.
Don't use SmallNetwork, you have more than 10 typicals.
Regards,
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/1ca34b9a-f504-4741-8b05-8b71dda02b75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Dario
Here is a screenshot...
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/Agr9j_fIzI0/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/CAKGhMPKBvZasy2rgMBry4SZs24vAX8hDz7hPjo2nkk0u8JL1zw%40mail.gmail.com.
As Antonino said likely your problem is that you are using SmallNetwork on one node only, this option if used, shall be applied in all nodes.
If you don't need it, just remove it.
Dario.
P.S.: It would be great if you can update the Configuration page of the wiki, adding a note for the use of Small Network. I'm from mobile.
From Mobile.