disabled MY_USE_UDP and it's connecting now... Thanks, feel pretty stupid.. Attaching the humidity sensor does cause de gateway to a reboot loop. Could that be a power issue since it's connected to my laptop's usb right now?
Posts made by Bram81
-
RE: ESP8266 gateway - Connection refused
-
RE: ESP8266 gateway - Connection refused
Because further down is stated:
// Controller ip address. Enables client mode (default is "server" mode).
// Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.My assumption was that I want it both to be a client and have it's data send to my domoticz controller, but obviously this isn't the way to go..?
-
RE: ESP8266 gateway - Connection refused
I tried it the other way around, but still no improvement.
My sketch:#include <ESP8266WiFi.h> #include <ESP8266WiFiMulti.h> #include <WiFiClient.h> #include <WiFiClientSecure.h> #include <WiFiServer.h> #include <WiFiUdp.h> #include <EEPROM.h> #include <SPI.h> // Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "Bram&Nathalie" #define MY_ESP8266_PASSWORD "mykey" // Enable UDP communication #define MY_USE_UDP // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,2,242 // If using static ip you need to define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,2,254 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 2000 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 2, 1 // Enable inclusion mode //#define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway // #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) //#define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button //#define MY_INCLUSION_MODE_BUTTON_PIN 3 // Flash leds on rx/tx/err // #define MY_LEDS_BLINKING_FEATURE // Set blinking period // #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Led pins used if blinking feature is enabled above #define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin #define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED #if defined(MY_USE_UDP) #include <WiFiUdp.h> #else #include <ESP8266WiFi.h> #endif #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 5 // Liquid #define MAX 114 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor void receive(const MyMessage &msg) {} MyMessage msg(CHILD_ID_LIGHT, V_HUM); void setup() { } void presentation() { // Present locally attached sensors here // Send the sketch version information to the gateway and Controller sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) present(CHILD_ID_LIGHT, S_HUM); } void loop() { // Send locally attached sensors data here // read the value from the sensor: sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 5, 114, 0, 100); send( msg.set( sendValue ) ); sleep(9000); }
Serial log of arduino shows:
0‚~?–4û!ƒ{“_Qaû0;255;3;0;9;Starting gateway (R-NGE-, 2.0.0-beta) scandone state: 0 -> 2 (b0) ..reconnect state: 2 -> 0 (0) f 0, .scandone state: 0 -> 2 (b0) .state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 3 pm open phy_2,type:2 0 0 cnt .. connected with Bram&Nathalie, channel 11 ip:192.168.2.242,mask:255.255.255.0,gw:192.168.2.254 .IP: 192.168.2.242 0;255;3;0;9;Init complete, id=0, parent=0, distance=0 65535 65535 65535
the number 65535 keeps being printed like every second, which seems strange to me.
-
RE: ESP8266 gateway - Connection refused
gateway address must be my internet gateway right? In that case 192.168.2.254 is correct.
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 2, 1 is my Domoticz server. Is that the way to go or am I doing something wrong? -
ESP8266 gateway - Connection refused
Hi,
I'm trying to use a esp8266 gateway as a standalone node and let it connect to Domoticz. After some hick ups I managed to compile my sketch. The gateway boots, but I'm not sure if it gets connected the right way. Serial log shows:
0‚~?–$û!ƒ{ƒOAaû0;255;3;0;9;Starting gateway (R-NGE-, 2.0.0-beta) scandone state: 0 -> 2 (b0) .state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 4 pm open phy_2,type:2 0 0 cnt connected with Bram&Nathalie, channel 11 ip:192.168.2.242,mask:255.255.255.0,gw:192.168.2.254 .IP: 192.168.2.242 0;255;3;0;9;Init complete, id=0, parent=0, distance=0 65535 65535
In Domoticz I've added a Mysensors Lan Gateway in Hardware, with remote address 192.168.2.242 and port 5003. Which is opened in my router for 192.168.2.242. Domoticz log keeps showing:
2016-02-22 12:48:16.489 Error: MySensors: Error: Connection refused 2016-02-22 12:48:16.490 Error: TCP: Error: Connection refused
The inclusion button in the sketch is disabled, but inclusion time is set to 60 seconds. Could this be part of the problem?
Hope someone can help.. -
RE: How to - Standalone node on esp8266 using wifi only - sketch problem
My sketchbook location is set to E:\documenten\Arduino and it contains the MySensors library. I think I was using 1.5 before so I removed all libraries and extracted everything from the 2.0 zip to that folder, Now compiling gives me this:
Arduino: 1.6.5 (Windows 8.1), Board:"NodeMCU 0.9 (ESP-12 Module), 80 MHz, Serial, 115200, 4M (3M SPIFFS)" In file included from E:\Documenten\Arduino\libraries\MySensors/MySensor.h:219:0, from GatewayESP8266.ino:133: E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:46:25: error: 'WiFiClient' does not name a type #define EthernetClient WiFiClient ^ E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:64:9: note: in expansion of macro 'EthernetClient' static EthernetClient clients[MY_GATEWAY_MAX_CLIENTS]; ^ E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportInit()': E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:103:9: error: 'WiFi' was not declared in this scope (void)WiFi.begin(MY_ESP8266_SSID, MY_ESP8266_PASSWORD); ^ E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:107:27: error: 'WL_CONNECTED' was not declared in this scope while (WiFi.status() != WL_CONNECTED) ^ E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool _readFromClient(uint8_t)': E:\Documenten\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:194:10: error: 'clients' was not declared in this scope while (clients[i].connected() && clients[i].available()) { ^ Multiple libraries were found for "WiFiUdp.h" Used: C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi Not used: C:\Program Files (x86)\Arduino\libraries\WiFi Fout bij compileren. Dit rapport zou meer informatie hebben met "Tijdens de compilatie uitgebreide uitvoer weergeven" ingeschakeld in Bestand > Voorkeuren.
Edit:
Manualy include the eps8266wifi library on top of the sketch did the trick. Despite the fact that these libraries where included later on in the sketch. @hek, thanks for puting me on the right track!
-
RE: How to - Standalone node on esp8266 using wifi only - sketch problem
Hi,
After a day of trying I'm starting to drive mad... After several reinstalls of Arduino IDE, Java and my libraries it seems like I'm almost there, but I realy don't have a clue on how to fix this anymore..I'm trying to use this sketch:
Insert Code Here
#include <EEPROM.h> #include <SPI.h> // Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "ssid" #define MY_ESP8266_PASSWORD "wpa" // Enable UDP communication #define MY_USE_UDP // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,2,242 // If using static ip you need to define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,2,254 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68 // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway // #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // Flash leds on rx/tx/err // #define MY_LEDS_BLINKING_FEATURE // Set blinking period // #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Led pins used if blinking feature is enabled above #define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin #define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED #if defined(MY_USE_UDP) #include <WiFiUDP.h> #else #include <ESP8266WiFi.h> #endif #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 5 // Liquid #define MAX 114 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor void receive(const MyMessage &msg) {} MyMessage msg(CHILD_ID_LIGHT, V_HUM); void setup() { } void presentation() { // Present locally attached sensors here // Send the sketch version information to the gateway and Controller sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) present(CHILD_ID_LIGHT, S_HUM); } void loop() { // Send locally attached sensors data here // read the value from the sensor: sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 5, 114, 0, 100); send( msg.set( sendValue ) ); sleep(90); }
Giving me this error trying to compile..
Arduino: 1.6.5 (Windows 8.1), Board:"NodeMCU 0.9 (ESP-12 Module), 80 MHz, Serial, 115200, 4M (3M SPIFFS)" GatewayESP8266.ino: In function 'void presentation()': GatewayESP8266:153: error: 'sendSketchInfo' was not declared in this scope GatewayESP8266:156: error: 'present' was not declared in this scope GatewayESP8266.ino: In function 'void loop()': GatewayESP8266:169: error: 'send' was not declared in this scope GatewayESP8266:170: error: 'sleep' was not declared in this scope 'sendSketchInfo' was not declared in this scope
Maybe I'm just being stupid, but I don't see what to do anymore. Hope there is someone who can help me with this.
-
RE: How to - Standalone node on esp8266 using wifi only - sketch problem
Nope.. That what I thought too. Getting this error Arduino: 1.6.5 (Windows 8.1), Board:"NodeMCU 0.9 (ESP-12 Module), 80 MHz, 9600"
In file included from C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:32:0,
from esp_gateway_aangepast.ino:63:
C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = char*; size_t = unsigned int]':
C:\Users\braml\Documents\Arduino\libraries\MySensors/core/MyGatewayTransportEthernet.cpp:164:52: required from here
C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/WiFiClient.h:113:36: error: request for member 'available' in 'source', which is of non-class type 'char*'
size_t left = source.available();
^
C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/WiFiClient.h:117:5: error: request for member 'read' in 'source', which is of non-class type 'char*'
source.read(buffer.get(), will_send);
^
Multiple libraries were found for "EEPROM.h"Used: C:\Users\braml\Documents\Arduino\libraries\EEPROM
Not used: C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\EEPROM
Multiple libraries were found for "SPI.h"
Used: C:\Users\braml\Documents\Arduino\libraries\SPI
Not used: C:\Users\braml\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\SPI
Fout bij compileren.
I've removed all libraries and reinstalled the board manager.. Have you seen this before?
-
RE: How to - Standalone node on esp8266 using wifi only - sketch problem
Thanks very much for your quick reply! Now suddenly I get compiling errors saying there is no such file as espwifi8266.h, which is weird because it was compiling other sketches just fine. Reinstalling libraries and the board manager now....
I'll let you know whether this works. Thanks again!
-
How to - Standalone node on esp8266 using wifi only - sketch problem
Hi,
I'm trying to use a nodemcu 0.9 as a standalone node using wifi and not the radio to connect to my Domoticz. Using the ESP8266 gateway i'm facing a problem. I've added the setup and loop part to it from a sketch I used earlier on a node with a traditional radio on it.
My guess is that trying to use the wifi connection to send data the commands in a sketch must be slightly different, but I have no idea how and can't find useful examples. Using this code gives me an error compiling in the line MySensor gw; , saying 'MySensor' does not name a type.Can anyone help me out?
Thanks in advance!!Insert Code Here #include <EEPROM.h> #include <SPI.h> // Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "myssid" #define MY_ESP8266_PASSWORD "wpa key" // Enable UDP communication //#define MY_USE_UDP // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,2,242 // If using static ip you need to define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,2,254 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. #define MY_CONTROLLER_IP_ADDRESS 192, 168, 2, 1 // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway // #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // Flash leds on rx/tx/err // #define MY_LEDS_BLINKING_FEATURE // Set blinking period // #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Led pins used if blinking feature is enabled above #define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin #define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED #if defined(MY_USE_UDP) #include <WiFiUDP.h> #else #include <ESP8266WiFi.h> #endif #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 5 // Liquid #define MAX 114 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_HUM); int lastLightLevel; int oldBatteryPcnt = 0; void setup(){ Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_HUM); } void loop(){ // read the value from the sensor: sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 5, 114, 0, 100); gw.send( msg.set( sendValue ) ); gw.sleep(90); } ` ` `
-
RE: Nodes only seen once with using I/O pin as power
@ericvdb
Hi, yeah sorry for that. I only realised that when I took a closer look at your sketch because it gave me the check wires message..
Thanks a lot, I've now put the radio on a seperate pin too powering it down and let the radio reinitialize by using gw.begin(); in the void loop section.This is the final code now and it is working well!
#include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 300 // Liquid #define MAX 700 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor int power =4; int radio =5; MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_HUM); int lastLightLevel; void setup(){ pinMode(power, OUTPUT); digitalWrite(power, HIGH); pinMode(radio, OUTPUT); digitalWrite(radio, HIGH); delay (5000); Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_HUM); digitalWrite(power, LOW); } void loop(){ // Turn sensor On digitalWrite(power, HIGH); // Turn Radio on digitalWrite(radio, HIGH); // read the value from the sensor: delay (5000); gw.begin(); sensorValue = analogRead(sensorPin); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 0, 842, 0, 100); gw.send( msg.set( sendValue ) ); // Turn sensor Off digitalWrite(power, LOW); // Turn radio off digitalWrite(radio, LOW); gw.sleep(3600000); }```
-
RE: Nodes only seen once with using I/O pin as power
Cheers, when only powering down the sensor it is working now! Is there a way to reinitialize the radio after powering it down or do you know of other ways to reduce the power usage of the radio?
-
RE: Nodes only seen once with using I/O pin as power
Hi, thanks for your reply. I was using delay so much because it seemed that the radio and sensor both needed some time to start up after they were powered on by puting pin 4 high.
Using your sketch wasn't working because both the radio and sensor are powered by the same pin. In the Void setup the pin was not set high so the node and radio were not started and it would not come to the loop part of thee sketch.
Also I've put the digitalWrite low at the end before puting it to sleep, because otherwise it would not sent anything because being powered off.
Making this small changes to your sketch still made it be presented to the gateway only once. Could there be a problem in puting pin 4 high both in the setup and the loop part? This is the code right now...
#include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 300 // Liquid #define MAX 700 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor int power =4; MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_HUM); int lastLightLevel; void setup(){ pinMode(power, OUTPUT); digitalWrite(power, HIGH); Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_HUM); } void loop(){ // Turn sensor On digitalWrite(power, HIGH); // read the value from the sensor: delay (5000); sensorValue = analogRead(sensorPin); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 0, 842, 0, 100); gw.send( msg.set( sendValue ) ); // Turn sensor Off digitalWrite(power, LOW); gw.sleep(60000); }
-
Nodes only seen once with using I/O pin as power
Hi there,
I'm having a sketch problem.. In order to try and save battery power on my moisture sensors I'm trying to use a IO pin as power by setting it high for some time, let the sensor take a measurement, send the results to the gateway, setting the IO pin low again, let the node go to sleep for some time .
This works only one time, the node presents itself to the gateway, sends data but after that it's not seen again after the expected sleep time.
My guess was that somehow after puting the IO pin low it doesn't come back up in a high state. The strange thing is that when I measure the current on the pins of my moisture sensor with a multimeter the current goes from 0 to aprox 4.27V in the given time, so actually that indicates the pin is going from high to low and back to high as needed, but somehow the radio doesn't come back up... This is my code:#include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 300 // Liquid #define MAX 700 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor int power =4; MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_HUM); int lastLightLevel; void setup(){ pinMode(power, OUTPUT); digitalWrite(power, HIGH); delay(3000); Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_HUM); delay (2000); } void loop(){ // read the value from the sensor: digitalWrite(power, HIGH); delay (5000); sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 0, 842, 0, 100); gw.send( msg.set( sendValue ) ); delay(10000); digitalWrite(power, LOW); delay (2000); gw.sleep(60000); }
Does anyone have any clue..?
-
RE: Help needed on a sketch...
Hi there,
I'm having another sketch problem.. In order to try and save battery power on my moisture sensors I'm trying to use a IO pin as power by setting it high for some time, let the sensor take a measurement, send the results to the gateway, setting the IO pin low again, let the node go to sleep for some time .
This works only one time, the node presents itself to the gateway, sends data but after that it's not seen again after the expected sleep time.
My guess is that somehow after puting the IO pin low it doesn't come back up in a high state. The strange thing is that when I measure the current on the pins of my moisture sensor with a multimeter the current goes from 0 to aprox 4.27V in the given time, so actually that indicates the pin is going from high to low as needed, but somehow the radio doesn't come back up... This is my code:#include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define MIN 300 // Liquid #define MAX 700 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor int power =4; MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_HUM); int lastLightLevel; void setup(){ pinMode(power, OUTPUT); digitalWrite(power, HIGH); delay(3000); Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile Sensor 1", "Kruiden"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_HUM); delay (2000); } void loop(){ // read the value from the sensor: digitalWrite(power, HIGH); delay (5000); sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 0, 842, 0, 100); gw.send( msg.set( sendValue ) ); delay(10000); digitalWrite(power, LOW); delay (2000); gw.sleep(60000); }
Does anyone have any clue..?
-
RE: New house - help me getting started!
Hi, like someone mentioned above no controller is perfect but I can only tell you what I'm using for the same purposes as you intend, Lightning, Curtains, Irrigation en a couple of sensors.
I've been running Domoticz on a Raspberry pi for over a year now with great pleasure. Together with a RFXCOM transeiver which is able to send 433mhz signals to wide range switches etc.
For Z-wave there are USB-dongles or shields that can be easily attached to the Rasberry Pi. Besides that I have an Arduino Uno attached to the pi to act as a Mysensors gateway.
As I said I'm not sure if this is the best way to go, but it fits my needs perfectly. Accept for the transeiver all the hardware is relatively cheap, easy to get and low on power consumption.
-
RE: Domoticz crashes after more than one node being presented
However it's not realy a specific Mysensors matter I thought it might be usefull for others suffering on the same problem. It turned out that the Rpi and Domoticz crashed after being presented more than 1 node due to some 1Wire issue. Strange thing is I wasn't even using 1wire.
Disabling it running sudo rmmod w1_gpio did the trick. Domoticz is running stable and taking as by now, four nodes without any problem.
-
RE: Help needed on a sketch...
Working like a charm now! Thank you very much for your help!!
-
RE: Help needed on a sketch...
When i set batteryPcnt back to int it shows: no matching function for call to 'MySensor::send(int&)'
-
RE: Help needed on a sketch...
Do i have to use a different command to send the battterypcnt to the gateway?
gw.send(batteryPcnt);
gives this error:
no matching function for call to 'MySensor::send(float&)'
-
RE: Help needed on a sketch...
define batteryPcn as float didn't make a difference, but after that I did:
float spanning = voltage * 11.714;
float batteryPcnt = ((spanning-Vmin)/(Vmax-Vmin))*100;It seems to be working now! Thanks a million again..
-
RE: Help needed on a sketch...
Oh and I mean shown as 0% in the serial monitor since I haven't put in the gw.send command in yet..
-
RE: Help needed on a sketch...
Ok, I'm almost where I want to be... Feeding my pro tinket 5v on a 9v battery I've managed to get the correct voltage reading. Which is aprox 9.10v on a new battery. The only thing I can't get to work is the % which I need to send to Domoticz .
I'm using this code, being pretty sure that the formula is correct but whatever I try, the battery % is shown as 0 on every voltage level. Am I missing something... ?
// number of analog samples to take per reading #define NUM_SAMPLES 10 int sum = 0; // sum of samples taken unsigned char sample_count = 0; // current sample number float voltage = 0.0; // calculated voltage #include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define BATTERY_SENSE_PIN A1 // select the input pin for the battery sense point #define MIN 300 // Liquid #define MAX 700 // Air // number of analog samples to take per reading #define NUM_SAMPLES 10 int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); void setup(){ Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile1", "1.16"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop(){ // read the value from the sensor: sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 1023, 250, 0, 100); gw.send( msg.set( sendValue ) ); gw.sleep(3000); // take a number of analog samples and add them up while (sample_count < NUM_SAMPLES) { sum += analogRead(A1); sample_count++; delay(10); } // calculate the voltage // use 5.0 for a 5.0V ADC reference voltage // 5.015V is the calibrated reference voltage voltage = ((float)sum / (float)NUM_SAMPLES * 4.92) / 1024.0; int Vmax = 9.10; int Vmin =4.92; int spanning = voltage * 11.714; int batteryPcnt = ((spanning-Vmin)/(Vmax-Vmin))*100; if ( batteryPcnt > 100 ) batteryPcnt = 100; // send voltage for display on Serial Monitor // voltage multiplied by 11 when using voltage divider that // divides by 11. 11.132 is the calibrated voltage divide // value Serial.print(voltage * 11.714); Serial.println (" V"); sample_count = 0; sum = 0; Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); }
-
RE: Help needed on a sketch...
@rvendrame Hi, It seems to work now... THANKS! Another question, I'm trying to measure the level of a 9v battery in the same sketch as well, using this:
Insert Code Here ``#include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define BATTERY_SENSE_PIN A1 // select the input pin for the battery sense point #define MIN 300 // Liquid #define MAX 700 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor boolean metric = true; MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); int lastLightLevel; int oldBatteryPcnt = 0; int battLoop =0; void setup(){ Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile1", "1.16"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop(){ // read the value from the sensor: sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); int sendValue = map(sensorValue, 1023, 250, 0, 100); gw.send( msg.set( sendValue ) ); // get the battery Voltage int batteryValue = analogRead(BATTERY_SENSE_PIN); Serial.println(batteryValue); // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 // vout = (sensorvalue x 3.3) / 1023 //vin = vout / (R2/(R1+R2)); float batteryV = ( batteryValue * 0.0088 ) / 0.8; // divide R2/(R1+R2) int batteryPcnt = batteryValue / 10 ; if ( batteryPcnt > 100 ) batteryPcnt = 100; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep gw.sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; gw.sleep(300000); }
Using this sketch causes the battery check into some kind of loop and not sending it back correctly to domoticz. Log shows:
Battery Voltage: 1.68 V
Battery percent: 15 %
384
send: 1-1-0-0 s=0,c=1,t=23,pt=2,l=2,st=ok:82
153
Battery Voltage: 1.68 V
Battery percent: 15 %
385
send: 1-1-0-0 s=0,c=1,t=23,pt=2,l=2,st=ok:82
153
Battery Voltage: 1.68 V
Battery percent: 15 %
384Any ideas on this?
-
RE: Help needed on a sketch...
@rvendrame Hi! Just changed the code as you suggested. That 1800000 was still from an old test, I'm sure that the sleeptime on the nodes was set for 2 hrs. It's set in miliseconds right? In that case it wasn't 20 but 30 minutes..
For the test I've set it to 600000 - do we agree on this being 10 min..? Since I'm using a Pro Trinket which can only use the serial monitor via FDTI I had to connect a breadbord to get some extra GND pins.. Node are running now.. Knowing more within the next half hour...
-
Help needed on a sketch...
Hi,
I'm running a serial gateway on a rpi running Domoticz with two moisture sensores connected. Since I want to feed the nodes by batteries I'm trying to only let the nodes send their info a couple of times a day, starting with a two hours interval for now.
The nodes are seen by domoticz and their info is updated after two hours only once, after that no new data is send/received until I've restarted the nodes. Domoticz and the gateway are running fine for the entire time. It seems that the nodes don't wake up after sleeping for two hours for the second time. This is the sketch I use:Insert Code Here #include <SPI.h> #include <MySensor.h> #define CHILD_ID_LIGHT 0 #define LIGHT_SENSOR_ANALOG_PIN 1 #define BATTERY_SENSE_PIN A1 // select the input pin for the battery sense point #define MIN 300 // Liquid #define MAX 700 // Air int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); int lastLightLevel; int oldBatteryPcnt = 0; int battLoop =0; void setup(){ Serial.begin(9600); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Mobile2", "1.16"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } void loop(){ // read the value from the sensor: sensorValue = analogRead(sensorPin); delay(1000); int lastsensorValue = sensorValue; Serial.println(sensorValue); gw.send(msg.set(constrain(map(sensorValue, 1023, 250, 0, 100),0,100))); gw.sleep(1800000); } void check_batt() { // get the battery Voltage int batteryValue = analogRead(BATTERY_SENSE_PIN); Serial.println(batteryValue); // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 // vout = (sensorvalue x 3.3) / 1023 //vin = vout / (R2/(R1+R2)); float batteryV = ( batteryValue * 0.003225806 ) / 0.3; // divide R2/(R1+R2) int batteryPcnt = batteryValue / 10 ; if ( batteryPcnt > 100 ) batteryPcnt = 100; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep gw.sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } }```
I'm still a newbie when it comes to coding, so maybe there is just a obvious error that I just miss?
BTW, the both nodes are fed through USB for now, so I'm sure it's not because of low battery levels. Is there anyone that can help me solve this? -
RE: Domoticz crashes after more than one node being presented
@AWI Hey, I've already rebuild the DB too and still without luck.. The gateway is connected to a quite old RPI B model in the barn just to control watervalves over GPIO which have to operate autonomous after my soil moisture sensors send back a certain value. First I thought that it could be some kind of power problem, but feeding the gateway with it's own 5v power supply didn't solve anything either.
I've read something about domoticz crashing in some cases due to too much EMI, but all devices are boxed and the gateway is as far away from the pi as the cable allows so that doesn't seen a very likely cause to me..
Every idea or suggestion is more than welcome...!
-
RE: Domoticz crashes after more than one node being presented
@sundberg84 hi, I've just reinstalled everything using the latest image this afternoon and the problem still exists.. But thanks anyway!
-
Domoticz crashes after more than one node being presented
Hi,
I'm using Domoticz on a Raspi and have an Arduino Uno as a serial Mysensors gateway . The gateway starts and a node connected to a Pro Trinket 5v running on a 9v battery shows up in Domoticz without a problem.
Now the thing is when I add a second node, also on a Pro Triketk 5v sometimes the two nodes are both seen by Domoticz and within a couple of minutes Domoticz crashes or it crashes almost right away. Both nodes use the same sketch with different sketchnames. When a crash occurs I cannot even ssh into the pi anymore and domoticz is shown as being offline. The log shows no errors what so ever...
Anyone familiar with this problem?
-
RE: How to add a sensor to the serial gateway
@sundberg84 Hey! Thank you verry much for your help and suggestions!!
I actually got it working combining your sketch witch my simple one resulting in this:#include <SPI.h>
#include <MySensor.h>#define CHILD_ID_LIGHT 0
#define LIGHT_SENSOR_ANALOG_PIN 1
#define MIN 300 // Liquid
#define MAX 1023 // Airint sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensorMySensor gw;
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
int lastLightLevel;void setup(){
Serial.begin(9600);
gw.begin();
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Soil_Moist_Sensor_grb", "1.15");// Register all sensors to gateway (they will be created as child devices)
gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
}void loop(){
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
delay(1000);
Serial.print("sensor = " );
Serial.println(sensorValue);
gw.send(msg.set(sensorValue));
}The sensor shows up in Domoticz as a light sensor meassuring in lux, but the numbers do match the output of the sensor.
Another thing is that after about 15 min the gateway started functioning. Seems like a problem that I had last week returned...
Loading the board with the pingpongtest shows that suddenly my radio chip is recognized as NRF24L01 instead of the + version, although the label on te chips shows NRF24L01+
Changing radios doesn't help, I'm completely in the dark... maybe just shitty radios..? -
RE: How to add a sensor to the serial gateway
@sundberg84 Hi, I've been trying to modify the sketch
But it gives me errors I cant resolve... Got to a point where the node send back info to the gateway:683
send: 3-3-0-0 s=0,c=1,t=1,pt=2,l=2,st=ok:0
682
send: 3-3-0-0 s=0,c=1,t=1,pt=2,l=2,st=ok:0
683
send: 3-3-0-0 s=0,c=1,t=1,pt=2,l=2,st=ok:0
682
send: 3-3-0-0 s=0,c=1,t=1,pt=2,l=2,st=ok:0Also Domoticz was receiving info, log showed
2015-07-02 10:31:24.898 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:24.914 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:24.929 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:24.944 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:24.959 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:24.975 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:24.990 (Gateway) Temp + Humidity (TempHum)
2015-07-02 10:31:25.005 (Gateway) Temp + Humidity (TempHum)But still the humidity switch was showing either 0% or 1%.
I guess that is propably because the values must be transfered into % in the sketch, but I am kind of stuck... -
RE: How to add a sensor to the serial gateway
Hey, thanks for your help. The sensor presents itself as a Humidity sensor and shows a value of 1% even after adding water to the ground nothing changes, so it seems it's not being updated correctly.
Last week when I was just playing around for the first time with the arduino and sensor used this simple sketch:
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensorvoid setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
}void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
delay(1000);
Serial.print("sensor = " );
Serial.println(sensorValue);
}Using the analog output on the sensor and analog0 on the arduino. The values are presented in number between 1-1200 (aprox.)
Even readings in just a number would be fine for me / can be easily transered to a % I guess, where a value of aprox 300 is liquid water and 1050 is the value read when the sensor is in the open air and not sticked in the soil.
Can you think of alike types of sensors with values presented in that range?
-
RE: How to add a sensor to the serial gateway
Hi@sundberg84 Yes, that's me.. I saw that file too, but being still a newbie in Mysensors, Arduino and sketches I didn't really know how to use it. Do I have to put in my libraries folder and add a line #include <filename> in the gateway sketch..?
Right now the sensor is automatically seen as a certain device, within Domoticz there is no way to present it otherwise right?
-
RE: How to add a sensor to the serial gateway
Oh and I'm using this sketc btw : http://www.mysensors.org/build/moisture
-
RE: How to add a sensor to the serial gateway
@sundberg84 Hey!
Domoticz log shows:
015-07-01 15:44:03.331 MySensors: Gateway Ready...
2015-07-01 15:44:28.776 Hardware Monitor: Fetching data (System sensors)
2015-07-01 15:44:41.187 (Gateway) Lighting 2 (Vochtigheid border)
2015-07-01 15:44:45.357 (Gateway) Lighting 2 (Vochtigheid border)
2015-07-01 15:44:58.920 Hardware Monitor: Fetching data (System sensors)
2015-07-01 15:45:28.298 MySensors: Node: 3, Sketch Name: Soil Moisture Sensor
2015-07-01 15:45:28.302 MySensors: Node: 3, Sketch Version: 1.0Hooking up the gateway and node to a laptop to use the serial monitor shows data being send from the sensor and received by the gateway.
After plugging in the gateway to my pi running domoticz there was a new hardware detected right away, but only not as a sensor but as a lightning2 type lamp switch which I've named 'vochtigheid border'. The log of this 'switch itself shows:
2015-07-01 15:44:45 On
2015-07-01 15:44:41 Off
2015-07-01 15:41:02 On
2015-07-01 14:49:43 Off
2015-07-01 14:31:56 On
2015-07-01 14:31:56 OffDoes this make any sense to you...?
-
RE: How to add a sensor to the serial gateway
Thanks everybody! Got the serial gateway working and it's being picked up by domoticz. Now another Arduino Uno is holding a moisture sensor, it's communicating with the gateway, but Domoticz sees the sensor as a lamp so it's not logging the sensor output. The sensor is a YL-38. Is there a way to fix this or is this type simply not supported by Domoticz?
-
RE: How to add a sensor to the serial gateway
Thanks for your post. Aha I thought that working without radio was the difference between serial and ethernet gateways. I've ordered some nRF24L01+. modules, probably getting them in a couple of days.
So I'll have to connect one of those to the gateway and one to the arduino Uno holding my moisture sensors?
-
RE: How to add a sensor to the serial gateway
@scalz Ok, that is what I was hoping... Right now I have one Arduino Uno conncted through USB to my Rpi running the gateway sketch on port ACM0
Another Uno which has a soil moisture sensor connected to it and running a sketch is also connected through USB to ACM1 port. Still I can't see any new devices in Domoticz...
Would this be the way to go or am I doing something verry wrong..?
-
RE: How to add a sensor to the serial gateway
@Moshe-Livne Thanks for your reply! So if I understand correctly there is one Arduino with the serial sketch on it that acts as the gateway and I have to use another arduino to add sensors to. Will a second Arduino connected to the Rpi through USB and running my sensor sketch be picked up by the gateway automatically?
-
How to add a sensor to the serial gateway
Hi,
Maybe this is a stupid question, but I've only got my first Arduino Uno in two days ago and I'm a complete mysensors newbie... Already have been working with Domoticz on Rpi for over a year now. Recently I've build a water irrigation system for my garden, controlled by a relay which can be switched through Domoticz using a GPIO. Now I would like to add some ground moisture sensors, using a Arduino and the domoticz Gateway to Mysensors to water the garden when the soil gets too dry.
I've uploaded the serialgateway sketch to an Arduino Uno and I also have a sketch to read the output of the sensor using the Analog output. Now my question is, how can a add this sketch to the arduino without deleting the gateway sketch?If I understand correctly, uploading the gateway sketch is obviously the first step, after that you'll have to upload specific sketches for various sensors to be able to add a 'node' ?
Can anyone put me on the right track? Thanks in advance!