@pjr Tanks a lot for your advice regarding our tank level Axis label and Icon in Domoticz.
Since I'm using the linux version of domoticz I can change these parameters!
Thanks again for your support.
Posts made by brix7be
-
RE: Water tank instant volume
-
RE: Water tank instant volume
Hello everyone,
Sorry for my delayed answer, i'm a bit busy at work for the moment, and my baby is sick this week.
@pjr : Thanks for you screenshot. In my version of domoticz(the last one running on w7 and soon on ubuntu server) , when i click on edit i'm only able to change the name and not the axis label like your's. An idea(something to activate) ?
@flopp : I've placed the ultrasonic sensor with an arduino uno and an ethernet stack under the tank cover (in a little electrical box). I'm going to connect it with a utp cable, for the length possibility(2pairs for the ethernet and 2wires for the power supply). For the connection schematics you'll find all you need on the distance sensor node and ethernet gateway on the site. Ask us for info.
@Boots33 : thanks for the your waterproof sensor link. I'll certainly change for it.Thank you all again for your support.
Have a nice evenning. -
RE: Water tank instant volume
@pjr, I've tested with S_DUST and V_LEVEL and it works :-). Tanks.
The UI edit button is included to the domoticz frontend or it is in backend(to change the icon and the axis label)?You're right, it could be wonderful if someone better than me on mysensors could add it or tell us how to add a V_LEVEL attribute to the S_WATER element.
Have a nice afternoon :-).
-
RE: Water tank instant volume
Tank you @pjr and @Boots33 for your ideas and support. I'll try it as soon as I can :-). I'ill keep you informed.
-
Water tank instant volume
Dear all,
I'm really glad to read that the Mysensors 2.0 now include by default the attachment of local sensors on gateways.
Then after one year in standby, i've started again my project to finish it.I'm using an Arduino Uno + Eth Wizenet 5100 and a distance sensor HC-SR04 => Domoticz as controller.
I want to measure the instant volume in liters of my water tank and not a consumption.
Actually I can see properly the value sent to domoticz from the sensors attached to my ethernet gateway.
My question is regarding the type: what type shall I use to send and read simply the instant value in liters in domoticz (not as counter).
I've found someone who did exactly what i would, but it's done with json! (see the image link below for the oil volume).
https://www.domoticz.com/wiki/images/0/06/Oil.pngHe write that the Volume sensor is (RFXMeter type 113, subtype 2).
I've found the pdf manual of mysensors but I only see the S_WATER with V_VOLUME type (this give me a water counter in domoticz and not an instant reading).How can I adapt a mysensor type (S_VOLUME_INSTANT by exemple) by my self?
I give you my sketch to measure and convert the distance in liters and percent for my tank if it could help someone else :-).
Tank you in advance for your help :-).
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endif // When W5100 is connected we have to move CE/CSN pins for NRF radio #ifndef MY_RF24_CE_PIN #define MY_RF24_CE_PIN 5 #endif #ifndef MY_RF24_CS_PIN #define MY_RF24_CS_PIN 6 #endif // Enable to UDP //#define MY_USE_UDP #define MY_IP_ADDRESS 192,168,1,113 // If this is disabled, DHCP is used to retrieve address // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003 // 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, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED // Flash leds on rx/tx/err #define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // 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 // Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED #include <SPI.h> #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensors.h> #include <NewPing.h> #define CHILD_ID 1 //constant for the sonar HC-SR04 sensor #define TRIGGER_PIN 3 #define ECHO_PIN 2 #define MAX_DISTANCE 350 //distance max measured //constant to calculate the volume of the tank #define high_water_level 200 //tank depth from the lowest point to the max water level #define distance_sensor 30 //distance in cm between the max water level and the sensor #define tank_volume 10000 //tank volume when it is fitted to the max water level unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds) NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. MyMessage msg(CHILD_ID, V_VOLUME); int lastDist; bool metric = true; void setup() { //present(255, 18); //metric = getConfig().isMetric; } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Capteur Citerne", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_WATER); } void loop() { Serial.print("Niveau d'eau "); Serial.print(tank_level("liters")); Serial.println("L"); /* if (dist != lastDist) { send(msg.set(dist)); lastDist = dist; } */ send(msg.set(tank_level("liters"))); sleep(SLEEP_TIME); } //function to measure and convert the tank volume int tank_level(String unit) { int level_liters = 0,level_percent = 0, echo_us = 0, echo_cm = 0, water_level_cm = 0; echo_us = sonar.ping_median(); //return the median time of 5measures between the ping and the echo in microseconds echo_cm = echo_us / US_ROUNDTRIP_CM; //convert the echo time to distance in cm. water_level_cm = high_water_level - (echo_cm - distance_sensor); level_liters = water_level_cm * (tank_volume / high_water_level); level_percent = (water_level_cm * 100) / high_water_level; if (unit == "liters") { return level_liters; } else if (unit == "percent") { return level_percent; } else { return 0; } }
-
RE: [n00b]]Ethernet GW - without NF24
Hi Hek, Everyone,
I've clean the approximative sketch I've made before to simply try to see the value of a DS18b20 sensor trough a serial gw in domoticz.
So i've placed the merged code below to have your advices.
In domoticz's log i can see the declaration of the gw but neither the dallas sensor!?Does someone could check my sketch please?
To be sure that the arduino see the dallas, i've tested a sketch wich send the value to the serial terminal (it works properly :-).Thank you in advance for your help.
Have a nice sunday all. (clouday in belgium today ;-)).// Enable debug prints to serial monitor #define MY_DEBUG // Enable serial gateway #define MY_GATEWAY_SERIAL // Flash leds on rx/tx/err //#define MY_LEDS_BLINKING_FEATURE // Set blinking period //#define MY_DEFAULT_LED_BLINK_PERIOD 300 // 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 //#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED #include <SPI.h> #include <MySensor.h> #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); void setup() { // Setup locally attached sensors // Startup up the OneWire library sensors.begin(); // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); } void presentation() { // Present locally attached sensors // Send the sketch version information to the gateway and Controller sendSketchInfo("Temperature Sensor", "1.1"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { present(i, S_TEMP); } } void loop() { // Send locally attached sensor data here // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) { #else if (temperature != -127.00 && temperature != 85.00) { #endif // Send in the new temperature send(msg.setSensor(i).set(temperature,1)); // Save new temperatures for next compare lastTemperature[i]=temperature; } } sleep(SLEEP_TIME); }
To be complete, there is the domoticz log.
2015-10-25 10:44:40.157 MySensors: Using serial port: COM3 2015-10-25 10:44:41.892 MySensors: Gateway Ready... 2015-10-25 10:44:41.892 MySensors: Node: 0, Sketch Name: Temperature Sensor 2015-10-25 10:44:41.946 MySensors: Node: 0, Sketch Version: 1.1
-
RE: [n00b]]Ethernet GW - without NF24
Is there anyone who have done a sketch to connect sensor directly on an ethernet gateway ?
Iam searching a working exemple or a working draft to see the process to build my own code.
Thank everyone for your advices. -
RE: [n00b]]Ethernet GW - without NF24
The final goal for me is the build ethernet sensor(s) (2 or 3 one each arduino board) connected to domoticz by lan gw.
-
RE: [n00b]]Ethernet GW - without NF24
i've changed as before and it won't compile.
The error is:
no matching function for call to 'EthernetClass::begin(int, int, int, int, int, int, int, int, int, int)'
No it takes the ip I put on the code before, cause the ping respond at this one.
Thks// BELOW the gateway W5100 sketch // Enable debug prints to serial monitor #define MY_DEBUG // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable to UDP //#define MY_USE_UDP #define MY_IP_ADDRESS 192,168,1,100 // If this is disabled, DHCP is used to retrieve address //byte ip[] = { 192, 168, 1, 100 }; // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003 // 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, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED //byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; #include <SPI.h> #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensor.h> //------------------------------------------------------------- //Below the Dallas temp sketch #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); void setup() { // ////Prepare the ethernet connection Ethernet.begin(MY_MAC_ADDRESS , MY_IP_ADDRESS); wait(1000); // Startup up the OneWire library sensors.begin(); // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Temperature Sensor", "1.1"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { present(i, S_TEMP); } } void loop() { // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) { #else if (temperature != -127.00 && temperature != 85.00) { #endif // Send in the new temperature send(msg.setSensor(i).set(temperature,1)); // Save new temperatures for next compare lastTemperature[i]=temperature; } } sleep(SLEEP_TIME); }
-
RE: [n00b]]Ethernet GW - without NF24
With the #define MY_IP_ADDRESS i can't compile the projet.
With the arduino command it works now, i can ping it on 192.168.1.100.
But still nothing in domoticz.
Am I on the right way?
thanks again// BELOW the gateway W5100 sketch // Enable debug prints to serial monitor #define MY_DEBUG // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable to UDP //#define MY_USE_UDP //#define MY_IP_ADDRESS 192,168,1,100 // If this is disabled, DHCP is used to retrieve address byte ip[] = { 192, 168, 1, 100 }; // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003 // 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, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. //#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; #include <SPI.h> #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensor.h> //------------------------------------------------------------- //Below the Dallas temp sketch #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); void setup() { // ////Prepare the ethernet connection Ethernet.begin(mac , ip); wait(1000); // Startup up the OneWire library sensors.begin(); // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Temperature Sensor", "1.1"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { present(i, S_TEMP); } } void loop() { // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) { #else if (temperature != -127.00 && temperature != 85.00) { #endif // Send in the new temperature send(msg.setSensor(i).set(temperature,1)); // Save new temperatures for next compare lastTemperature[i]=temperature; } } sleep(SLEEP_TIME); }
-
RE: [n00b]]Ethernet GW - without NF24
Here is the merged code
Thanks for the advices// BELOW the gateway W5100 sketch // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // I DONT WANT TO USE THE RADIO MODULE // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. //#if !defined(MY_W5100_SPI_EN) // #define MY_SOFTSPI // #define MY_SOFT_SPI_SCK_PIN 14 // #define MY_SOFT_SPI_MISO_PIN 16 // #define MY_SOFT_SPI_MOSI_PIN 15 //#endif // When W5100 is connected we have to move CE/CSN pins for NRF radio //#define MY_RF24_CE_PIN 5 //#define MY_RF24_CS_PIN 6 // Enable to UDP //#define MY_USE_UDP //#define MY_IP_ADDRESS 192,168,1,100 // If this is disabled, DHCP is used to retrieve address // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode //#define MY_PORT 5003 #define IP_PORT 5003 // The port you want to open IPAddress myIp (192, 168, 1, 100); // Configure your static ip-address here COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later! // 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, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. //#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // DEAD BEEF FEED // a R/W server on the port EthernetServer server = EthernetServer(IP_PORT); // handle to open connection EthernetClient client = EthernetClient(); // Flash leds on rx/tx/err //#define MY_LEDS_BLINKING_FEATURE // Set blinking period //#define MY_DEFAULT_LED_BLINK_PERIOD 300 // 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 //#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED #include <SPI.h> #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensor.h> //------------------------------------------------------------- //Below the Dallas temp sketch // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensor.h> #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface int inputPos = 0; bool sentReady = false; void output(const char *fmt, ... ) { va_list args; va_start (args, fmt ); vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args); va_end (args); Serial.print(serialBuffer); server.write(serialBuffer); } void setup() { // ////Prepare the ethernet connection Ethernet.begin(mac, myIp); // Startup up the OneWire library sensors.begin(); // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Temperature Sensor", "1.1"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { present(i, S_TEMP); } } void loop() { // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) { #else if (temperature != -127.00 && temperature != 85.00) { #endif // Send in the new temperature send(msg.setSensor(i).set(temperature,1)); // Save new temperatures for next compare lastTemperature[i]=temperature; } } sleep(SLEEP_TIME); }
-
RE: [n00b]]Ethernet GW - without NF24
You are right, it blocks when i call sendSketchInfo directly (without to be an attribute of gw) !?!
-
RE: [n00b]]Ethernet GW - without NF24
It doesn't work.
But i found the code of Bram81 http://forum.mysensors.org/topic/1591/how-to-add-a-sensor-to-the-serial-gateway/22
and I can compile it well.
And it calls the gw.sendSketchInfo("Soil_Moist_Sensor_grb", "1.15");Do you have another tip?
-
RE: [n00b]]Ethernet GW - without NF24
hum, strange.
I continue to search a solution.
I'll give you a feed back ;-).Thanks
-
RE: [n00b]]Ethernet GW - without NF24
Hi Hek,
Sure, you can't realise every solutions or exemple for everyone :-).
So it's a good advice for me to begin my tests.When i merge the both codes, i receive an error "sendSketchInfo was not declared in this scope"!
I've checked and normally all the librairies are available for the code.
(When i'm building the GatewayW5100 only it works) but not for the dallas.Do you have an idea?
Thanks :-).
Gwen.
-
RE: [n00b]]Ethernet GW - without NF24
Thanks for your quickly answer.
I'm sorry but I didn't found the code or information regarde my question into the repository you noticed.
Could you please give me the complete link?
Thanks you again.
-
RE: [n00b]]Ethernet GW - without NF24
Hello Hek, Hello Everyone,
I've actually one arduino uno and an ethernet shield Wizenet W5100 and for exemple a temp sensor DS18B20 directly connected to it.
I can send to a serial terminal the temperature value. It's working properly :-).
I would to know how I could simplify the code of the "Ethernet GW" Sketch for send the value of a sensor directly from the GW to Domoticz. (Without using an urduino dedicated to the sensor acquisition and without an RF module).Could you give me an exemple of the code or the command to send to domoticz?
Or do you have a documentation link?
Because the link you posted before is dead https://github.com/mysensors/Arduino/tree/gateway-refactoring.I've made many rescearch, and i don't find the protocol documentation to discuss with domoticz!
I appreciate if you could help me to the right way :-).
Awayting your answer, thanks very much in advance.
PS: Sorry for my bad english...