Intanto usa esp-12 ...
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "souliss-it" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a souliss-it+...@googlegroups.com.
Per postare messaggi in questo gruppo, invia un'email a souli...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/ccfdc230-d5a8-464a-bdd2-f4a4813cbdb8%40googlegroups.com.
Per ulteriori opzioni, visita https://groups.google.com/d/optout.
Saverio grazie per la tua risposta. Ma forse mi sono spiegato male io. In sostanza oltre ad avere nel nodo master il T41 dove so già che posso collegare tutti i sensori che voglio, vorrei che in quel nodo si vedano tutti i sensori collegati, per questo chiedevo se ogni sensore potevo gestirlo si collegato al nodo master ma con un tipico dedicato per vederli appunto su souliss app nel solo nodo allarme.. Ci ho provato ad inserire il tipico insieme al T41 ma non mi ha funzionato.
Souliss_DigIn(pirSensorPin, Souliss_T4n_Alarm, memory_map, ANTITHEFT); if(mInput(ANTITHEFT) == Souliss_T4n_Alarm)RemoteInput(rs485Antifurto,PIRCUCINA,Souliss_T1n_OnCmd)Ciao Saverio,
puoi usare if(DigIn...) per settare il T11, puoi poi usare il reset del T41 per resettare i T11 o creare un pulsante dedicato di reset.
Introdurre gestioni piú integrate diventa complesso perché le esigenze sono varie.
Io ad esempio localizzerei il T11 sullo stesso nodo dove hai il T42 per esser sicuri di catturare lo scatto del sensore. Però al contrario farei un broadcast dello stato dell'antifurto (armato/non armato) per fare registrare nel T11 solo lo scatto con antifurto inserito.
Alternativa per chi ha tutti nodi Ethernet o WiFi é quella di inviare una notifica smnp verso il server di openhab e non usare il T11.
Dario.
From Mobile.
Il T13 va bene, basta passargli in ingresso gli stati OnOff e si sposterà di conseguenza al pari di un T11, ma senza i comandi utente per ON e OFF.
Dario.
From Mobile.
Ottimo Saverio, grazie per la dritta, buona l'idea del T11 perché io avevo pensato ad un T13 ma non sapevo come gestirlo dato che lo stato da OFF ad ON passa solo quando c'è l'input del sensore, e di conseguenza non avrei avuto l'ultimo stato memorizzato e cioè quale sensore abbia rilevato la presenza
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "souliss-it" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a souliss-it+...@googlegroups.com.
Per postare messaggi in questo gruppo, invia un'email a souli...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/a8d87e6c-762a-4e33-af9d-b9f181671293%40googlegroups.com.
Poi il T13 va bene si, ma per mantenere in memoria lo stato ON quando il pir rileva la presenza come dovrei fare? Potrei utilizzare una condizione if?
Quindi se il PIR sente una seconda presenza cosa accade passa su OFF oppure resta su ON
Per comandi utente cosa intendi?
OK Grazie Saverio.Mi rivolgo agli altri utenti....... avete utilizzato il RemoteInput ?A me sembra non funzionare.-
uint8_t ip_address[4] = {192, 168, 10, 77};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4] = {192, 168, 10, 1};
#define myvNet_address ip_address[3] uint8_t ip_address[4] = {192, 168, 10, 78}; //indirizzo peer corrente
uint8_t subnet_mask[4] = {255, 255, 255, 0}; //subnet
uint8_t ip_gateway[4] = {192, 168, 10, 1}; // indirizzo gateway internet
uint8_t gatewaysouliss[4] = {192, 168, 0, 77}; // indirizzo gateway Souliss
#define myvNet_gateway gatewaysouliss[3]gatewaysouliss[4] = {192, 168, 0, 77}; // indirizzo gateway Souliss
all'interno del peer , forse ha senso nello sketch del GW, ma visto che con gli esp wifi non c'ho mai messo mano potrei pure sbagliarmi
e cmq non vedo come possano comnicare un nodo su 192.168.0.77 con un 192.168.10.1 ... con quella netmask
prova a trasformare su entrambi ( sia sul gateway che sul peer )
la riga
uint8_t subnet_mask[4] = {255, 255, 255, 0};
la fai diventare
uint8_t subnet_mask[4] = {255, 255, 0 , 0};
Tony con mOutput ira funziona.....
if(mOutput(ANTITHEFT) == Souliss_T4n_InAlarm){
mInput(PIR_locale) = Souliss_T1n_OnCmd;
}
else{
mInput(PIR_locale) = Souliss_T1n_OffCmd;
}
Logic_T13(PIR_locale);
Logic_T13(PIR1_remoto);
/**************************************************************************
Souliss - Hello World for Expressif ESP8266
This is the basic example, create a software push-button on Android
using SoulissApp (get it from Play Store).
Load this code on ESP8266 board using the porting of the Arduino core
for this platform.
***************************************************************************/
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/Gateway.h" // The main node is the Gateway, we have just one node
#include "conf/IPBroadcast.h"
#include "DHT.h"
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "myWIFI"
#define WiFi_Password "myPWD"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
// This identify the number of the LED logic
//#define MYLEDLOGIC 0
// **** Define here the right pin for your ESP module ****
//#define OUTPUTPIN 5
#define DHTPIN 0 // what digital pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
//DHT dht(DHTPIN, DHTTYPE);
#define TEMPERATURE 0
#define HUMIDITY 1
DHT dht(DHTPIN, DHTTYPE);
#define ANTITHEFT 2 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 3 // This is the memory slot used for the execution of the watchdog
void setup()
{
Initialize();
//Serial.begin(9600);
//Serial.println("DHTxx test!");
dht.begin();
// 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(0xAB01, 0xFF00, 0x0000);
SetAsPeerNode(0xAB02, 1);
SetAsPeerNode(0xAB03, 2);
SetAsPeerNode(0xAB04, 3);
SetAsPeerNode(0xAB05, 4);
SetAsPeerNode(0xAB06, 5);
SetAsPeerNode(0xAB07, 6);
SetAsPeerNode(0xAB08, 7);
SetAsPeerNode(0xAB09, 8); //PIR
Souliss_SetT52(memory_map, TEMPERATURE);
Souliss_SetT53(memory_map, HUMIDITY);
// Setup the anti-theft
Set_T41(ANTITHEFT);
// Define inputs, outputs pins and pullup
// pinMode(2, INPUT); // Hardware pullup required
// Set_SimpleLight(MYLEDLOGIC); // Define a simple LED light logic
// pinMode(OUTPUTPIN, OUTPUT); // Use pin as output
pinMode(DHTPIN, INPUT);
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_110ms() { // We process the logic and relevant input and output every 50 milliseconds
// Logic_SimpleLight(MYLEDLOGIC);
// DigOut(OUTPUTPIN, Souliss_T1n_Coil,MYLEDLOGIC);
// Wait a few seconds between measurements.
//delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
// Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
// Serial.print("Humidity: ");
// Serial.print(h);
// Serial.print(" %\t");
// Serial.print("Temperature: ");
// Serial.print(t);
// Serial.print(" *C ");
// Serial.print(f);
// Serial.print(" *F\t");
// Serial.print("Heat index: ");
// Serial.print(hic);
// Serial.print(" *C ");
// Serial.print(hif);
// Serial.println(" *F");
}
FAST_2110ms()
{
Logic_Temperature(TEMPERATURE);
Logic_Humidity(HUMIDITY);
// mInput(ANTITHEFT) = Watchdog(0xAB09, WATCHDOG, Souliss_T4n_Alarm);
}
// // Process every 510ms the logic that control the curtain
// FAST_510ms() {
// // Input from anti-theft sensor
// LowDigIn(2, Souliss_T4n_Alarm, ANTITHEFT);
//// Execute the anti-theft logic and report to the main node
//Logic_T42(ANTITHEFT, 0xAB01);
// }
// Here we handle here the communication with Android
FAST_GatewayComms();
}
EXECUTESLOW() {
UPDATESLOW();
SLOW_10s() {
// Read temperature and humidity from DHT every 10 seconds
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
Souliss_ImportAnalog(memory_map, TEMPERATURE, &t);
Souliss_ImportAnalog(memory_map, HUMIDITY, &h);
}
}
}
/**************************************************************************
Souliss - Hello World for Expressif ESP8266
This is the basic example, create a software push-button on Android
using SoulissApp (get it from Play Store).
Load this code on ESP8266 board using the porting of the Arduino core
for this platform.
***************************************************************************/
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/IPBroadcast.h"
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "MyWifi"
#define WiFi_Password "MyPWD"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
// Define the network configuration according to your router settings
//#define Gateway_address 0xAB01 // The Gateway node has two address, one on the Ethernet side
// and the other on the wireless one
//#define Peer_address_n1 0xAB09
#define Peer_address_n2 0xAB0A
//#define myvNet_subnet 0xFF00
//#define myvNet_supern Gateway_address
#define ANTITHEFT 0 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 1 // This is the memory slot used for the execution of the watchdog
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(0xAB09, 0xFF00, 0xAB01);
// Setup the anti-theft
Set_T42(ANTITHEFT);
// Define inputs, outputs pins and pullup
pinMode(0, INPUT); // Hardware pullup required
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
// Process every 510ms the logic that control the curtain
FAST_510ms() {
// Input from anti-theft sensor
LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
// Execute the anti-theft logic and report to the main node
Logic_T42(ANTITHEFT, 0xAB01);
}
// Process the communication
FAST_PeerComms();
// Execute the code every 2110ms
FAST_2110ms() {
// // Build a watchdog chain to monitor the nodes
// mInput(ANTITHEFT) = Watchdog(Peer_address_n2, WATCHDOG, Souliss_T4n_Alarm);
}
}
} È consigliabile creare nodi peer esp01 così da creare dei sensori pir allarme wifi con watchdog?
Ho creato tutto a banco ma il timore che una qualche esp 01 si dovesse scollegare dato che ho notato poca stabilità in wifi e far scattare l'allarme e quindi la sirena non mi da molta fiducia.
Cosa ne pensate?
Vedo Set_T41 ma non Logic_T41, ho guardato velocemente, se manca aggiungilo.
Dario.
From Mobile.
// // Process every 510ms the logic that control the curtain
FAST_510ms() {
// // Input from anti-theft sensor
// LowDigIn(2, Souliss_T4n_Alarm, ANTITHEFT);
//// Execute the anti-theft logic and report to the main node
Logic_T41(ANTITHEFT);
}Si alle prime due, per la terza fai una catena che chiudi sul t41.
Dario.
From Mobile.
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "souliss-it" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a souliss-it+...@googlegroups.com.
Per postare in questo gruppo, invia un'email a souli...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/1f37c6c8-4f0e-48aa-82a7-811c269f3275%40googlegroups.com.
Per altre opzioni visita https://groups.google.com/d/optout.
#define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 5 // This is the memory slot used for the execution of the watchdog
prima erano 3 e 4
per il watchdog non ho capito
al momento sul gateway ho impostato
FAST_2110ms()
{
Logic_Temperature(TEMPERATURE);
Logic_Humidity(HUMIDITY);
mInput(ANTITHEFT) = Watchdog(0xAB09, WATCHDOG, Souliss_T4n_Alarm);
}
mInput(ANTITHEFT) = Watchdog(Peer_address_n2, WATCHDOG, Souliss_T4n_Alarm);#define Peer_address_n1 0xAB09
#define Peer_address_n2 0xAB01
Devi costruire un anello chiuso, il peer sul gateway ed il gateway sul peer nel tuo caso.
Dario.
From Mobile.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/eb109e33-1a7f-432c-afc8-c84888e3a979%40googlegroups.com.
#define TEMPERATURE 0
#define HUMIDITY 2
DHT dht(DHTPIN, DHTTYPE);
#define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 5 // This is the memory slot used for the execution of the watchdog
FAST_2110ms()
{
Logic_Temperature(TEMPERATURE);
Logic_Humidity(HUMIDITY);
mInput(ANTITHEFT) = Watchdog(0xAB09, WATCHDOG, Souliss_T4n_Alarm);
}
#define Peer_address_n1 0xAB09
#define Peer_address_n2 0xAB01
//#define myvNet_subnet 0xFF00
//#define myvNet_supern Gateway_address#define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 5 // This is the memory slot used for the execution of the watchdog
mInput(ANTITHEFT) = Watchdog(Peer_address_n2, WATCHDOG, Souliss_T4n_Alarm);
Puoi inviare una notifica (pushetta), accendere un led o altro quando Watchdog restituisce un valore di allarme.
Basta un if(mInput(...)) subito dopo la chiamata Watchdog da cui fai partire un'azione di notifica.
Un'altra possibilità é quella di definore dei T13 fittizzi a cui forzi mInput quando rilevi che l'uscita (mOutput) di un T42 é in allarme.
Dario.
From Mobile.
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "souliss-it" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a souliss-it+...@googlegroups.com.
Per postare messaggi in questo gruppo, invia un'email a souli...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/2831db0f-1226-4583-94d3-e4464f3af53f%40googlegroups.com.
Per ulteriori opzioni, visita https://groups.google.com/d/optout.
/**************************************************************************
Souliss - Hello World for Expressif ESP8266
This is the basic example, create a software push-button on Android
using SoulissApp (get it from Play Store).
Load this code on ESP8266 board using the porting of the Arduino core
for this platform.
***************************************************************************/
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/IPBroadcast.h"
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "merola-Alice"
#define WiFi_Password "mlivio6703"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
// Define the network configuration according to your router settings
//#define Gateway_address 0xAB01 // The Gateway node has two address, one on the Ethernet side
// and the other on the wireless one
//#define Peer_address_n1 0xAB09
#define Peer_address_n2 0xAB01
//#define myvNet_subnet 0xFF00
//#define myvNet_supern Gateway_address
#define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 5 // This is the memory slot used for the execution of the watchdog
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(0xAB09, 0xFF00, 0xAB01);
// Setup the anti-theft
Set_T42(ANTITHEFT);
// Define inputs, outputs pins and pullup
pinMode(0, INPUT); // Hardware pullup required
pinMode(2, OUTPUT); // accende un led se il pin di input ha un valore HIGH
pinMode(1, OUTPUT); //tx pin
pinMode(3, OUTPUT); //rx pin
digitalWrite(1, 0);
digitalWrite(3, 0);
}
void loop()
{
int val = 0; // variable to store the read value
val = digitalRead(0); // legge il valore del pin0
digitalWrite(2, val); // imposta il pin 2 al valore del pin 0, se in allarme il led si accende
// Here we start to play
EXECUTEFAST() {
UPDATEFAST(); // Process every 510ms the logic that control the curtain
FAST_510ms() {
// Input from anti-theft sensor
LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
// Execute the anti-theft logic and report to the main node
Logic_T42(ANTITHEFT, 0xAB01);
}
// Process the communication
FAST_PeerComms();
// Execute the code every 2110ms
FAST_2110ms() {
// // Build a watchdog chain to monitor the nodes
mInput(ANTITHEFT) = Watchdog(Peer_address_n2, WATCHDOG, Souliss_T4n_Alarm);
if (mInput(5)== Souliss_T4n_Alarm) {
digitalWrite(1,HIGH); //pin 1 SLOT MEMORY 5 - led giallo
}
// else {
// digitalWrite(1, 0);
// }
if (mInput(4)==Souliss_T4n_Alarm) {
digitalWrite(3,HIGH); //pin 3 SLOT MEMORY 4 - led blu
}
//else {
// digitalWrite(3, 0);
// }
}
}
} if (mInput(WATCHDOG)== Souliss_T4n_Alarm) {
digitalWrite(1,HIGH); //pin 1 SLOT MEMORY 5 - led giallo
}
// else {
// digitalWrite(1, LOW);
// }
if (mInput(ANTITHEFT)==Souliss_T4n_Alarm) {
digitalWrite(3,HIGH); //pin 3 SLOT MEMORY 4 - led blu
}
//else {
// digitalWrite(3, LOW);
// }
}
}
}
#define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
#define WATCHDOG 5 // This is the memory slot used for the execution of the watchdog Set_T41(ANTITHEFT); // Setup the anti-theft
FAST_2110ms()
{
Logic_Temperature(TEMPERATURE);
Logic_Humidity(HUMIDITY);
mInput(ANTITHEFT) = Watchdog(0xAB09, WATCHDOG, Souliss_T4n_Alarm);
}
FAST_510ms() {
Logic_T41(ANTITHEFT);
} pinMode(1, OUTPUT); //tx pin
pinMode(3, OUTPUT); //rx pin
digitalWrite(1, LOW);
digitalWrite(3, LOW);
if (mOutput(5)==Souliss_T4n_Alarm) {
digitalWrite(1,HIGH); //pin 1 SLOT MEMORY 5 - led giallo
}
else {
digitalWrite(1, LOW);
}
if (mOutput(4)==Souliss_T4n_Alarm) {
digitalWrite(3,HIGH); //pin 3 SLOT MEMORY 5 - led blu
}
else {
digitalWrite(3, LOW);
}Ciao Livio,
il watchdog non é un tipico e quindi non usi Set_Tnn e per come é pensato ora non puoi escludere dinamicamente un nodo dal watchdog.
Puoi escludere un nodo dall'antifurto (zona) creando un T11 nel nodo da escludere ed usando un codice del genere:
Logic_T11(ZONA1);
if(mOutput(ZONA1)) DigIn(pin, ANTOFURTO);
Logic_T42(ANRIFURTO);
Così solo attivando il T11 vai a leggere il pin che fa scattare il T42.
Per i consigli su SoulissApp, apri un issue (in inglese) sul relativo github.
Dario.
From Mobile.
if (mOutput(WATCHDOG)==Souliss_T4n_Alarm) {
digitalWrite(1,HIGH); //pin 1 SLOT MEMORY 5 - led giallo
}
else {
digitalWrite(1, LOW);
}
if (mOutput(ANTITHEF)==Souliss_T4n_Alarm) {
Leggi tre pir e li usi per scrivere nello stesso slot, il primo che salta ti fa suonare l'allarme.
Dario.
From Mobile.
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "souliss-it" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a souliss-it+...@googlegroups.com.
Per postare in questo gruppo, invia un'email a souli...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/66a9c55c-0976-48a0-a725-56a5921ef2ed%40googlegroups.com.
se imposto il jumper in un modo il segnale si ripete all'infinito quando il time (impostato con il potenziometro) si resetta, il mio led si accende e si spegne a intervalli regolari anche se non c'è nessuno nella stanza.
se lo metto nell' altro modo il sensore va in allarme una e sola una volta e il led rimane acceso all'infinito senza rilevare altri movimenti...nenache se gli do delle martrellate.
/*
* PIR sensor tester
*/
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}
void loop(){
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
// EXECUTE FAST E UPDATE FAST VANNO QUI?????
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// qui ci va il il FAST???
/*
FAST_510ms() {
// Input from anti-theft sensor
LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
// Execute the anti-theft logic and report to the main node
Logic_T42(ANTITHEFT, 0xAB01);
}
*/
// e il codice seguente dove va???????????
/*
FAST_PeerComms();
// Execute the code every 2110ms
FAST_2110ms() {
// // Build a watchdog chain to monitor the nodes
mInput(ANTITHEFT) = Watchdog(Peer_address_n2, WATCHDOG, Souliss_T4n_Alarm);
*/
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
conDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
e vedi se funziona.
Nello sketch che hai postato non fai altro che memorizare in una variabile lo stato iniziale del sensore..
Ti allego cmq uno sketch che penso funzioni, io non l'ho provato, serve per accendere un led quando il PIR rileva la presenza
if(memory_map[MaCaco_OUT_s + ANTITHEFT] == Souliss_T4n_Alarm){
memory_map[MaCaco_OUT_s + ANTITHEFT]==Souliss_T4n_Alarm
mOutput(ANTITHEFT)==Souliss_T4n_Alarm
/**************************************************************************
Souliss - Anti-theft + led
*/
// Configure the framework
#include "bconf/MCU_ESP8266.h"
#include "conf/IPBroadcast.h"
// **** Configurar WiFi ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "XXXXXx"
#define WiFi_Password "yyyyyyyy"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include "Souliss.h"
//Indirizzo ip statico
uint8_t ip_address[4] = {192, 168, X, x}; //indirizzo peer corrente
uint8_t subnet_mask[4] = {255, 255, 255, 0}; //subnet
uint8_t ip_gateway[4] = {192, 168, X, X}; // indirizzo gateway internet
uint8_t gatewaysouliss[4] = {192, 168, X, X}; // indirizzo gateway Souliss
#define myvNet_gateway gatewaysouliss[3]
#define myvNet_subnet 0xFF00
#define myvNet_supern 0x0000
#define Gateway_address 0xAB01
#define Peer_address_n1 0xAB09
#define ANTITHEFT 4
#define WATCHDOG 5
int valore_sensore = 0;
void setup()
{
Initialize();
// Setup the network configuration
SetIPAddress(ip_address, subnet_mask, ip_gateway);
SetAsGateway(myvNet_gateway);
SetAddress(0xAB09, 0xFF00, 0xAB01);
// Setup the anti-theft
Set_T42(ANTITHEFT);
pinMode(0, INPUT);
pinMode(2, OUTPUT);
pinMode(1, INPUT);
pinMode(3, OUTPUT);
//digitalWrite(1, LOW);
digitalWrite(3, LOW);
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_510ms() {
// Input SENSORE PIR
LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
LowDigIn(1, Souliss_T4n_Alarm, ANTITHEFT);
Logic_T42(ANTITHEFT, Gateway_address);
if(memory_map[MaCaco_OUT_s + ANTITHEFT] == valore_sensore){
digitalWrite(2, LOW);
}else{
if(memory_map[MaCaco_OUT_s + ANTITHEFT] == Souliss_T4n_Alarm){
digitalWrite(2, HIGH); // turn LED ON
}
valore_sensore = memory_map[MaCaco_OUT_s + ANTITHEFT];
}
}
// Process the communication
FAST_PeerComms();
// Execute the code every 2110ms
FAST_2110ms() {
// Build a watchdog chain to monitor the nodes
mInput(ANTITHEFT) = Watchdog(Gateway_address, WATCHDOG, Souliss_T4n_Alarm);
/*
if (mOutput(5)==Souliss_T4n_Alarm) {
digitalWrite(1,HIGH); //pin 1 SLOT MEMORY 5 - led giallo
}
else {
digitalWrite(1, LOW);
}
*/
if (mOutput(4)==Souliss_T4n_Alarm) {
digitalWrite(3,HIGH); //pin 3 SLOT MEMORY 5 - led blu
}
else {
digitalWrite(3, LOW);
}
}
}
}
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "souliss-it" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a souliss-it+unsubscribe@googlegroups.com.
Per postare in questo gruppo, invia un'email a souli...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/souliss-it/3f852976-b564-4f4f-8b4d-e072dfc05010%40googlegroups.com.