@ZsoltZombori
Exactly that was a problem with my system too. When I had it connected to the computer using the serial cable everything would just run fine but as soon as I removed the serial cable from computer and let it run on its own with the power supply connected with a DC jack, everything would just fall apart the LED's would go dim and that's when I discovered the problem of the ground but you already have all the grounds connected so I'm out of clues here.
I would suggest you to check the power supply connections again with a multimeter to make sure that everything is connected properly.
Posts made by palande.vaibhav
-
RE: 💬 Connecting the Radio
-
RE: 💬 Connecting the Radio
@ZsoltZombori
I had a problem of the LED on pin 13 glowing dim after some time of system running fine when I had 2 sensors connected to the Arduino and sensors had their own separate 5V power supply. So, I had a 5V power supply separate from the Arduino's 5V and that was supplying current to those sensors.
I had the sensor's data pins connected to Arduino but I didn't have GND of power supply and Arduino connected. I solved the problem by connecting the GND of power supply to the GND of the Arduino.
See if that is the case with you.
Hope this helps.
-
RE: When requesting with request() function what reply should I expect?
@sundberg84 As far as I understand by looking at the code you have sensor on the same node which is requesting the pulse count from the GW??
OR you have reed switch on this node and sensor is on some other node? In the debug prints do you see a READ message in the serial monitor for your node which has reed switch?
With me, I am sending the request() from node 1 to node 2. I can see SEND message in serial monitor of node 1 and READ message in the serial monitor of GW and also a SEND message in GW serial monitor and READ message in node 2. So the message is reaching node 2 successfully but my node 2 is not sending any reply to that message.
So, node 1 is sending to GW, GW is receiving it and sending it to node 2, node 2 is receiving the message but node 2 is not replying. Is this what is supposed to happen? OR node 2 is actually supposed to send a reply back to node 1?
-
RE: When requesting with request() function what reply should I expect?
@sundberg84
Can you share your snippet of code where you have request() function? -
RE: When requesting with request() function what reply should I expect?
@sundberg84
OK. And does your request() function looks just like mine?
So, are you requesting V_VAR1 from the node? -
RE: When requesting with request() function what reply should I expect?
@sundberg84
I have void receive() in node 2. But to code something I need to know what I am listening to.Is that just a bool message with the state of the switch saying its ON or OFF??
What do you have in the void receive() function you are using?
-
RE: How to send message from one sensor to other or send message with different node and sensor ID?
Got it after some trial and error with getters and setters.
In case someone needs. I did following.
MyMessage msg(); //Create a blank MyMessage instance. Do this before void setup()
then when you want to send the message. Create a message on the fly like following.
1. msg.setType(2); 2. msg.setSensor(1); 3. msg.setDestination(2); 4. send(msg.set(1));
This is what I am doing above:
- set message type ex. V_LIGHT is 2. Look at API for more
- Set sensor child ID of the sensor you want to change status of
- This is the destination node ID which has the sensor you are trying to reach
- Send the message just like you would usually.
Hope this helps someone
-
When requesting with request() function what reply should I expect?
Hello all,
I am requesting the status of a switch with child ID 1 from another sensor node ID 2.
I used request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
In my case variable type is V_LIGHT so its request(1, 2, 2).I can see the sensor node 1 sending message and sensor node 2 receiving message in the debug log but sensor node doesn't send anything back to the requesting node.
Now what kind of message should I expect from the node? OR I should write some code in the receiving node to create a response?
Thank You
-
How to send message from one sensor to other or send message with different node and sensor ID?
Hello all,
I have pH sensor on node ID 1 and valve that controls pH on node ID 2. Now when the pH level falls below some value I want to open the valve. How can I send message from one node to other to open the valve
OR
How can I send message to domoticz from node ID 1 to open the valve on node ID 2?
Thank You,
Vaibhav -
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@chrille
I noticed it. Made the change and now it works. Thanx for your help. -
RE: How to update LIGHT state on Domoticz?
@AWI how do I use request()?
What I need to do is my automation for the sensors is running on the Arduino itself. So, if domoticz stops working and then some values of the switches or lights change, I want Domoticz to display the same values not the values it had the last time.
I tried what @nagelc said but it changes the state of the switch in domoticz. I just want to update what domoticz displays not actually change the state of the LIGHT.
I read on Domoticz forum that this can be achieved using dummy switch which when set up as the slave for the actual switch only updates the displayed state of the switch. But this was discussed for JSON. I don't know how to make mysensors talk to the dummy node.
Do you have any idea about this? -
How to update LIGHT state on Domoticz?
Hello all,
I want to send message to Domoticz to only update the state of the LIGHT without actually changing it.
So for example if my Light is ON and I reset my Arduino, the default state of the LIGHT is OFF but Domoticz knows the last state as ON, now I want my node to send a message to Domoticz and only update the state of the LIGHT to OFF.
I tried sending a message using send command and MyMessage but it doesn't work.
Any solution?
Thank You
-
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@chrille
I think I also got it to work.
I have DS18B20 which is child 5, SHT31-D temperature is child 6 and Humidity is 7.
Here child 4, 5, 6 have the same number #4 but they are not grouped, they show up as separate sensors in Devices tab.
Now I understand why 6 and 7 are in a group but why is child 4 which is a LIGHT also combined with them? -
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@AWI
Thanks for the info. I will try to implement this today.At the end of discssion gizmocuz says that "this is already taken care of, see the forum thread about mysensors/grouping". But I checked Domoticz forum and couldn't find a thread named grouping in mysensors subforum.
Can you find it? Or its the same one as mentioned in the last comment from issue which takes us here ?
-
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@chrille
Hello,
This is indeed very annoying.
I am going to try what @AWI has suggested. Presenting sensors in sequence and then spacing them apart when presenting to see what this new feature in Domoticz does.
Can you also try this? and report here? That would be really helpful.Thank You
-
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@sundberg84 The instructions you pointed to are for raspberry pi. Can you point me to some instructions on how to do it on Windows?
-
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@AWI
Thanks for the information. So does this mean that if I don't want to combine any sensors then I should present them as 1,3,5,7. So just skipping one number between them?You said "So, make sure you present the sensors you want to combine after each other."
So why are sensors with child ID 0, 1, 2 not combined when their child ID's are in sequence and 3, 7, 255 are combined when their child ID's are not in sequence? I still don't understand this?Forgive me for my beginner ness
-
RE: DS18B20 ans SHT31-D show up as combined sensors on Domoticz
@sundberg84
Here is the thread that I found on MySensors forum. zampedro explains how that can be done but I don't know how to edit the files. I can't find them in the Domoticz installation on Windows. Also check my last reply to that post. -
DS18B20 ans SHT31-D show up as combined sensors on Domoticz
Hello all,
I have built a node with total of 9 sensors.Two of them are DS18B20 (Temperature) and SHT31-D(Temperature and Humidity) from adafruit. In Domoticz they show up as combined sensors. DS18B20 is combined with the Humidity from SHT31-D and another sensor shows up with SHT31-D temperature and Humidity combined.
How can I make them show up as separate Temperature and Humidity sensors?
I want DS18B20, Temperature from SHT31-D and Humidity from SHT31-D all as separate sensors. I am presenting all of them as separate child sensors.I will really appreciate the help.
Thank You,
Vaibhav -
RE: DHT22 and DS18b20 on same node: DS shows up with Humidity now.
@zampedro said:
I modified MySensorBase.cpp
void MySensorsBase::SendSensor2Domoticz
case V_TEMP:at lines 595 and 603 (numbers from last git code) for Temperature
// SendTempHumBaroSensorFloat(cNode, pChild->batValue, Temp, Humidity, Baro, nforecast, (!pChild->childName.empty()) ? pChild->childName : "TempHumBaro");
if ( (pChildHum->childID+1)== pChild->childID)
SendTempHumBaroSensorFloat(cNode, pChild->batValue, Temp, Humidity, Baro, nforecast, (!pChild->childName.empty()) ? pChild->childName : "TempHumBaro");
else
SendTempSensor(cNode, pChild->batValue, Temp, (!pChild->childName.empty()) ? pChild->childName : "Temp");// SendTempHumSensor(cNode, pChild->batValue, Temp, Humidity, (!pChild->childName.empty()) ? pChild->childName : "TempHum");
if ( (pChildHum->childID+1)== pChild->childID)
SendTempHumSensor(cNode, pChild->batValue, Temp, Humidity, (!pChild->childName.empty()) ? pChild->childName : "TempHum");
else
SendTempSensor(cNode, pChild->batValue, Temp, (!pChild->childName.empty()) ? pChild->childName : "Temp");case V_HUM:
at lines 678 and 686 for Humidity
// SendTempHumBaroSensorFloat(cNode, pChildTemp->batValue, Temp, Humidity, Baro, nforecast, (!pChild->childName.empty()) ? pChild->childName : "TempHumBaro");
if ( (pChild->childID+1)== pChildTemp->childID)
SendTempHumBaroSensorFloat(cNode, pChildTemp->batValue, Temp, Humidity, Baro, nforecast, (!pChild->childName.empty()) ? pChild->childName : "TempHumBaro");
else
SendHumiditySensor(cNode, pChild->batValue, Humidity, (!pChild->childName.empty()) ? pChild->childName : "Hum");// SendTempHumSensor(cNode, pChildTemp->batValue, Temp, Humidity, (!pChild->childName.empty()) ? pChild->childName : "TempHum");
if ( (pChild->childID+1)== pChildTemp->childID)
SendTempHumSensor(cNode, pChildTemp->batValue, Temp, Humidity, (!pChild->childName.empty()) ? pChild->childName : "TempHum");
else
SendHumiditySensor(cNode, pChild->batValue, Humidity, (!pChild->childName.empty()) ? pChild->childName : "Hum");In this way hum+temp of DHT11 are shown together ( CHILD_ID_HUM +1 == CHILD_ID_TEMP ) and
temperatures from ds18b20 are alone in separate widgets.#define CHILD_ID_HUM 9 // DHT11
#define CHILD_ID_TEMP 10 // DHT11
#define DS18B20_STARTID 15 // DS18B20Regards
Where can I find the MySensorsBase.cpp? I am running domoticz on windows and in the installation folder I can't find the file. I can see the file on GitHub but how do I install domoticz from GitHub?
-
RE: 💬 Connecting the Radio
@DiverAlpha
I tried it on my setup. The node shows the output with BC (st=bc) when I only have the node connected in that is powered ON. But when I power ON my gateway in they start communicating and I get st=ok.Here is the node without gateway connected:
Starting sensor (RNNNA-, 2.0.0) TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=1) TSM:FPAR TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: !TSM:FPAR:FAIL !TSM:FAILURE TSM:PDT TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=1) TSM:FPAR TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
After I power ON the gateway I get following output:
TSM:PDT TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=1) TSM:FPAR TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 0-0-1 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:PAR OK (ID=0, dist=1) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=1) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:MSG:READ 0-0-1 s=255,c=3,t=25,pt=1,l=1,sg=0:1 TSP:MSG:PONG RECV (hops=1) TSP:CHKUPL:OK TSM:UPL:OK TSM:READY SHT31 test TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100 TSP:MSG:SEND 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0 TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0 TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=11,pt=0,l=22,sg=0,ft=0,st=ok:Temperature and switch TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0 TSP:MSG:SEND 1-1-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 1-1-0-0 s=1,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 1-1-0-0 s=2,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok: Request registration... TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2 TSP:MSG:READ 0-0-1 s=255,c=3,t=27,pt=1,l=1,sg=0:1 Node registration=1 Init complete, id=1, parent=0, distance=1, registration=1 TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.0 Temp *C = 21.32 TSP:MSG:SEND 1-1-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:21.32 Hum. % = 75.48 TSP:MSG:SEND 1-1-0-0 s=1,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=ok:75.48
Basically you need to have at least one node and a gateway working for MySensors to run properly.
Here is the thread I started when I had the same problem: https://forum.mysensors.org/topic/4941/problem-getting-the-code-to-run-with-mysensors-library-2-0/35Read last few comments, you will get the idea of what I am saying. You can also try the fix for this suggested by ayo in the comment #35.
-
RE: 💬 Connecting the Radio
@DiverAlpha
I am no expert in this. But when I started using MySensors few months ago, I also had some problems. Not because there is a problem with MySensors but because I was doing the simplest of the mistakes and I needed to think simple and do simple things first.What I would suggest is just try the simplest of the code first. This post is considering that you are using MySensors library 2.0.
This is what I did when I was trying out MySensors and I think you can try this too.
Firstly connect Arduino you are using properly to the radio with the proper connections using the instructions here. If you are using Arduino Mega, the SPI pins are different. Here is the link for Arduino Mega: https://forum.mysensors.org/topic/4940/arduino-mega-nrf-wiring/3. Make sure you have decoupling capacitors attached between the VCC and GND pins of both the radios.
After you make the connections upload the code for the gateway to one of the Arduinos. You can find the code in Arduino IDE, File > Examples > MySensors > GatewaySerial. Don't make any changes just upload the code.
Then what I did the first time is just run the following motion sensor code to the other Arduino. I have made a few changes to make things simpler for the node to find the gateway.
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 1 #define MY_PARENT_NODE_ID 0 #include <SPI.h> #include <MySensors.h> //unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 0 // Id of the sensor child // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); } void loop() { // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. //sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); }
Here, I have defined a NODE ID and defined the PARENT NODE ID for the node. Defining parent ID makes sure that the gateway that you have is the one, the node is supposed to connect to. I didn't even have motion sensor connected to the node here. This is just to make sure that first time you get everything working.
If this is done correctly the node and gateway should talk to each other and gateway should have the motion sensor registered.
Hope this helps.
-
RE: 💬 Connecting the Radio
@DiverAlpha said:
Hi all,
I'm using the Arduino Micro with al NRF24L01 radio. With the micro it's not posible to use the pin config of the Nano.
I got it working with the connections below.NRF24 > Micro
Miso > Miso
Mosi > Mosi
SCK > SCK
CSN > Pin D7
CE > Pin D8Thereby I put the code below in my arduino code before de "#include <SPI.h>"
// Pin Confuguration for Arduino Micro
#define MY_RF24_CE_PIN 8
#define MY_RF24_CS_PIN 7Maybe this is helpful for some other users.
Grtz Diver
@DiverAlpha
Thanx a lot for commenting with that information. I was having problems with the Arduino Mega. I connected the NRF24L01+ to the appropriate SPI pins on the Mega and then just defined the CE and CS pins in the code an now it works. Thanks again -
RE: [Solved] Communication from Gateway to Sensor node not working
@BartE said:
@palande.vaibhav
i think the answer is in the code// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime);
Replace sleep(); by wait();
During a sleep the GW does not receives the message acknowledge and thus claims the broadcast did fail.
This worked.
Thanks a lot for the help. I guess I need to read stuff properly.Thanks for the help.
-
RE: [Solved] Communication from Gateway to Sensor node not working
@sundberg84
No it doesn't turn on. And I even don't see anything on the serial monitor for the sensor node. I think I should be able to see the READ on the serial monitor for the sensor node. But I don't get that on there.digitalWrite(4, !digitalRead(4));
This means,
digitalRead(4)
------> Read the value at pin 4.
!
-----> Toggle it, that is after reading the value, if it is 0 then make it one and if it is 1 make it 0.
digitalWrite(4,
----> Write it back to pin 4.digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
This line actually checks for the payload that comes with the received signal and makes RELAY_ON or RELAY_OFF decision accordingly.
So, I am doing much simpler task than relay example. I am trying to not even check what the received message says, I am just checking if I get the message or not and make LED toggle if I do get the message. -
RE: [Solved] Communication from Gateway to Sensor node not working
@sundberg84
I just have LED connected to the pin 4 of Arduino.
I have written code such that when receive() is executed the LED is toggled. -
[Solved] Communication from Gateway to Sensor node not working
Hello guys,
I have built temperature sensor DS18B20 using the example sketch, I also have a simple on off switch and LED on my sensor node. I am using Arduino Uno for both Gateway and sensor node.
My sensors work and show values on the MYSController. Now when I try to control LED using the MYSController, it doesn't work.
Here is the screenshot of what happens in MYSController:
I have tried with with and without payload. My code doesn't really need a payload to turn on or off the LED. It just toggles the state of an LED when it receives V_LIGHT message.
Here is my code for sensor node:
// 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 <MySensors.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; bool receivedConfig = false; bool metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); //Initialize switch message MyMessage msg1(6, V_TRIPPED); void before() { // Startup up the OneWire library sensors.begin(); } void setup() { // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); // Setup the buttons for switch pinMode(2, INPUT); // Activate internal pull-ups digitalWrite(2, HIGH); //Set LED pin to OUTPUT pinMode (4, OUTPUT); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Temperature and switch", "1.0"); // 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(0, S_TEMP); //preset the switch present(6, S_DOOR); //present LED present(7, S_LIGHT); } 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); //Code for switch uint8_t value; static uint8_t sentValue=2; value = digitalRead(2); if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg1.set(value==HIGH ? 1 : 0)); digitalWrite(8,!(digitalRead(8))); String string = "Value changed to: "; Serial.println(string += value); sentValue = value; } // Sleep until something happens with the sensor //sleep(0,CHANGE,0); } void receive(const MyMessage &message) { Serial.println("Received command"); //Check for the message from controller if (message.type==V_LIGHT) { digitalWrite(4, !digitalRead(4)); Serial.println("LED status changed"); } }
For gateway I am using the example code without making any change. When I send command using MYSController, I can see RX LED blink on the Gateway Arduino but nothing on the sensor node serial monitor.
Serial Monitor for sensor node:
What am I doing wrong?
I will really appreciate the help.Thank You,
Vaibhav -
RE: Problem getting the code to run with MySensors library 2.0
Oh I get it now. Now I understand. I must have a gateway and at least one sensor node running for this to work. If there is no gateway then sensor nodes don't work because of the constant loop trying to find a parent.
My problem was I was trying to write and run the code with just the sensor node.
I will also do the modifications you mentioned to the core files.
Thanx a lot for your help. I really appreciate it.
-
RE: Problem getting the code to run with MySensors library 2.0
@ayo
How can I make sensor nodes with the MY_GATEWAY_SERIAL line in the code. This just makes the device a gateway. How do I make it a sensor node with that line included?Just having two different devices in the same code will work??
Like in this code:
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * DESCRIPTION * * Interrupt driven binary switch example with dual interrupts * Author: Patrick 'Anticimex' Fallberg * Connect one button or door/window reed switch between * digitial I/O pin 3 (BUTTON_PIN below) and GND and the other * one in similar fashion on digital I/O pin 2. * This example is designed to fit Arduino Nano/Pro Mini * */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_GATEWAY_SERIAL #define MY_NODE_ID 1 #include <SPI.h> #include <MySensors.h> #define SKETCH_NAME "Binary Sensor" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define PRIMARY_CHILD_ID 3 #define SECONDARY_CHILD_ID 4 #define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch #define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3) #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3) #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN) #error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same #endif #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID) #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same #endif // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED); MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED); void setup() { // Setup the buttons pinMode(PRIMARY_BUTTON_PIN, INPUT); pinMode(SECONDARY_BUTTON_PIN, INPUT); pinMode(8,OUTPUT); // Activate internal pull-ups digitalWrite(PRIMARY_BUTTON_PIN, HIGH); digitalWrite(SECONDARY_BUTTON_PIN, HIGH); Serial.begin(115200); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); Register binary input sensor to sensor_node (they will be created as child devices) You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. If S_LIGHT is used, remember to update variable type you send in. See "msg" above. present(PRIMARY_CHILD_ID, S_DOOR); present(SECONDARY_CHILD_ID, S_DOOR); } // Loop will iterate on changes on the BUTTON_PINs void loop() { uint8_t value; static uint8_t sentValue=2; static uint8_t sentValue2=2; // Short delay to allow buttons to properly settle //sleep(5); value = digitalRead(PRIMARY_BUTTON_PIN); if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg.set(value==HIGH ? 1 : 0)); digitalWrite(8,!(digitalRead(8))); String string = "Value changed to: "; Serial.println(string += value); sentValue = value; } value = digitalRead(SECONDARY_BUTTON_PIN); if (value != sentValue2) { // Value has changed from last transmission, send the updated value send(msg2.set(value==HIGH ? 1 : 0)); sentValue2 = value; } // Sleep until something happens with the sensor sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, 0); //sleep(0,CHANGE,0); }
-
RE: Problem getting the code to run with MySensors library 2.0
@ayo
Then this makes library 2.0 completely useless cause we always have to use MY_GATEWAY_SERIAL and so can't create sensor nodes.If you also confirm this then I am gonna report this as a bug.
-
RE: Problem getting the code to run with MySensors library 2.0
@ayo
But adding #define MY_GATEWAY_SERIAL to the code for the sensor node will make it a gateway. Right? Please check my last post where I posted the screenshots of this making both of them initialize as the gateway.And if both are gateways they won't communicate
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd
I have to keep #define MY_GATEWAY_SERIAL line in the code for both gateway and sensor nodes.
Now since I have #define MY_GATEWAY_SERIAL line in the code for both gateway and sensor node, both of them are initializing as gateways.
And this causes them not to be able to communicate with each other.
Please help
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd
Is it only me?
Can you please try this on your setup as time permits?
I have a manual install of the library 2.0
I want to use this for one of my projects and I am dead stuck. -
RE: Problem getting the code to run with MySensors library 2.0
@ayo Did you try running the code?
-
RE: Problem getting the code to run with MySensors library 2.0
@palande.vaibhav said:
@mfalkvidd
Thanx for the suggestion. It's worse than I thought.Here is the code:
//MySensors // Enable debug prints //#define MY_DEBUG //// Enable and select radio type attached #define MY_RADIO_NRF24 ////#define MY_RADIO_RFM69 #define MY_GATEWAY_SERIAL #include <SPI.h> #include <MySensors.h> // Initialize motion message //MyMessage msg(1, V_LIGHT); void setup() { // Setup locally attached sensors pinMode(8, OUTPUT); Serial.println("Setup runs"); } void presentation() { // Present locally attached sensors Serial.println("presentation runs"); } void loop() { // Send locally attached sensor data here Serial.println("loop runs"); digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
This is the output with #define MY_GATEWAY_SERIAL line.
Without #define MY_GATEWAY_SERIAL, it doesn't show anything on the serial monitor.
@mfalkvidd Any update on this?
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd
Thanx for the suggestion. It's worse than I thought.Here is the code:
//MySensors // Enable debug prints //#define MY_DEBUG //// Enable and select radio type attached #define MY_RADIO_NRF24 ////#define MY_RADIO_RFM69 #define MY_GATEWAY_SERIAL #include <SPI.h> #include <MySensors.h> // Initialize motion message //MyMessage msg(1, V_LIGHT); void setup() { // Setup locally attached sensors pinMode(8, OUTPUT); Serial.println("Setup runs"); } void presentation() { // Present locally attached sensors Serial.println("presentation runs"); } void loop() { // Send locally attached sensor data here Serial.println("loop runs"); digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
This is the output with #define MY_GATEWAY_SERIAL line.
Without #define MY_GATEWAY_SERIAL, it doesn't show anything on the serial monitor.
-
RE: Problem getting the code to run with MySensors library 2.0
I saw the post about the presentation function not working in 2.0. But that has been fixed in development version.
My problem is still there that code doesn't work at all. To which I think my loop function stops working if I don't have #define MY_GATEWAY_SERIAL line in the code.
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd said:
@palande.vaibhav said:
Cause I can't use MY_GATEWAY_SERIAL for a node. Right?
Yes you can. But I read that there is a bug in MySensors 2.0 that causes the presentation function to not run, so you'll need the latest code from the MySensors development branch on Github.
I tried with the library from Development branch on GitHub. It still doesn't work.
I must have #define MY_GATEWAY_SERIAL line in the code for the code to work with MySensors.h.Library version:
Code below doesn't work cause I have commented #define MY_GATEWAY_SERIAL: Just uncomment it and the same code works
//MySensors // Enable debug prints //#define MY_DEBUG //// Enable and select radio type attached #define MY_RADIO_NRF24 ////#define MY_RADIO_RFM69 //#define MY_GATEWAY_SERIAL #include <SPI.h> #include <MySensors.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) const byte DIGITAL_INPUT_SENSOR = 3; // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) //#define CHILD_ID 1 // Id of the sensor child // Initialize motion message //MyMessage msg(1, V_LIGHT); void setup() { // Setup locally attached sensors pinMode(8, OUTPUT); } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd said:
@palande.vaibhav said:
Cause I can't use MY_GATEWAY_SERIAL for a node. Right?
Yes you can. But I read that there is a bug in MySensors 2.0 that causes the presentation function to not run, so you'll need the latest code from the MySensors development branch on Github.
But am I right that for MySensors version 2.0, we must have #define MY_GATEWAY_SERIAL line in order for the code to work? OR is it just me?
And I don't even have anything in the presentation function. I think my problem is loop function not working if I don;t have #define MY_GATEWAY_SERIAL line in the code.
-
RE: Problem getting the code to run with MySensors library 2.0
@ayo
did you try commenting #define MY_GATEWAY_SERIAL and running your Blink code?
Can you please try that? -
RE: Problem getting the code to run with MySensors library 2.0
1.6.8 is the older version. 1.6.12 is the latest version.
And the CRC error is the known bug. So, if your IDE and MySensors work then don't change anything.
-
RE: CRC doesn't match. File is corrupted. MySensors version 2.0
@mfalkvidd
I have extracted the zip from GitHub, renamed the folder to MySensors and pasted it into Documents\Arduino\libraries folder. I don't have MySensors stuff in Program Files(86)\Arduino\libraries folder.And it works. Arduino library manager now shows MySensors library version 2.0.0 as installed.
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd
Any idea why this is happening?
Cause I can't use MY_GATEWAY_SERIAL for a node. Right? -
RE: CRC doesn't match. File is corrupted. MySensors version 2.0
@mfalkvidd
Haha okay. I am from US. It's a night time for me. So, didn't realize that. -
RE: CRC doesn't match. File is corrupted. MySensors version 2.0
@mfalkvidd
Can you please do that as time permits? -
RE: CRC doesn't match. File is corrupted. MySensors version 2.0
@mfalkvidd
OK. That makes sense. But for me if it doesn't work manual install in Documents\Arduino\libraries is the way to go, right?OR install should be in Program Files(86)\Arduino\libraries and there is a method to do it?
-
RE: CRC doesn't match. File is corrupted. MySensors version 2.0
Can you add this to the description on the website which talks about how to install the MySensors library?
Because for the older library versions we had to actually download the zip and then paste the contents of the libraries folder into the Program Files(x86)\Arduino\libraries folder.
You have the video for that on the website but not for the new library 2.0.And I believe for library 2.0 we have to extract it and put it as it is in the documents\Arduino\libraries folder.
-
RE: CRC doesn't match. File is corrupted. MySensors version 2.0
@mfalkvidd
If I just download the library from GitHub and then extract it and paste it into C:\Users"UserName"\Documents\Arduino\libraries folder, it should be fine right?OR I have to paste it in the Program Files(x86)\Arduino\libraries folder?
-
CRC doesn't match. File is corrupted. MySensors version 2.0
Hello all,
Installing the library 2.0 from Arduino library manager gives an error "
CRC doesn't match. File is corrupted." I am using Arduino IDE version 1.6.12.What am I doing wrong?
Thank You,
Vaibhav -
RE: Problem getting the code to run with MySensors library 2.0
@ayo
Something weird is happening right now. I am now running MySensors version 2.0. The code you gave works with library version 2.0.I was just experimenting with the lines of the code to see which line makes difference and I found that #define MY_GATEWAY_SERIAL line makes difference.
If I just add that line to my Blink code, it works with MySensors.hI don't know why this happens.
//// Enable debug prints to serial monitor //#define MY_DEBUG // // //// Enable and select radio type attached #define MY_RADIO_NRF24 ////#define MY_RADIO_RFM69 // //// Set LOW transmit power level as default, if you have an amplified NRF-module and //// power your radio separately with a good regulator you can turn up PA level. //#define MY_RF24_PA_LEVEL RF24_PA_LOW // //// Enable serial gateway #define MY_GATEWAY_SERIAL // //// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender) //#if F_CPU == 8000000L //#define MY_BAUD_RATE 38400 //#endif // //// Flash leds on rx/tx/err //#define MY_LEDS_BLINKING_FEATURE //// Set blinking period //#define MY_DEFAULT_LED_BLINK_PERIOD 300 // //// Inverses the behavior of leds ////#define MY_WITH_LEDS_BLINKING_INVERSE // //// Enable inclusion mode //#define MY_INCLUSION_MODE_FEATURE //// Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // //// Inverses behavior of inclusion button (if using external pullup) ////#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // //// 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 4 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED #include <SPI.h> #include <MySensors.h> void setup() { // Setup locally attached sensors pinMode(8, OUTPUT); } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
This code works but only if I have #define MY_GATEWAY_SERIAL line included. Can you try this on your setup?
In my code which was not working previously, If I just add #define MY_GATEWAY_SERIAL , it works.
In your Blink code, if you just comment out the line #define MY_GATEWAY_SERIAL, it won't work. Can you try this?
-
RE: Problem getting the code to run with MySensors library 2.0
@ayo
OK. I will give this a shot.One more thing is installing the library 2.0 from Arduino library manager gives an error "
CRC doesn't match. File is corrupted." I am using Arduino IDE version 1.6.12.I am downloading the zip from GitHub and pasting it in the Documents/Arduino/libraries folder. This is OK right??
-
RE: Problem getting the code to run with MySensors library 2.0
I just tested with older library version 1.5.4.
Both Blink and my Switch code work with MySensors library version 1.5.4 but doesn't work with version 2.0.
-
RE: Problem getting the code to run with MySensors library 2.0
@palande.vaibhav said:
Even uncommenting #define MY_RADIO_NRF24 WORKS.
So the problem starts when I uncomment #include <MySensors.h>.
-
RE: Problem getting the code to run with MySensors library 2.0
@ayo
I did. The problem is still there. I also tried simplest of the simple LED blink code. Check my new post.Thank You
-
RE: Problem getting the code to run with MySensors library 2.0
@mfalkvidd @ayo Thanks for the reply.
I have tried changing the pin to Pin8.
I now have tried a Arduino library LED blink code. I attached the LED to Pin 8. It blinks without the #include<MySensors.h> line. But when I add #define MY_RADIO_NRF24 and #include <MySensors.h>, it stops working.
I have to add #define MY_RADIO_NRF24 because if I don't it throws an error saying if I don't have a radio then adding MySensors.h is pointless. And I get it, its pointless.
So, problem starts after uncommenting #include<Mysensors.h> and #define MY_RADIO_NRF24.
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN takes care of use the correct LED pin whatever is the board used. If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at https://www.arduino.cc/en/Main/Products This example code is in the public domain. modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi */ //#define MY_RADIO_NRF24 //#include <MySensors.h> // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(8, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for a second }```
-
Problem getting the code to run with MySensors library 2.0
Hello guys,
I am trying to write a simple code using the MySensors library 2.0. Its a simple switch. I am generating interrupt on pin 2 of Arduino Uno. Switch is connected between Pin 2 and GND. The interrupt is invoked when I change the state of the switch and then LED on pin 13 toggles.
First I wrote the code without MySensors library. Just a simple Arduino code to make sure this thing works. It works flawlessly.
Below is the code for this without MySensors library: This code works. I have commented out the lines which involve use o MySensors library.
const byte ledPin = 13; volatile byte state = LOW; //MySensors // Enable debug prints //#define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 //#include <SPI.h> //#include <MySensors.h> const byte DIGITAL_INPUT_SENSOR = 2; //#define CHILD_ID 1 // ID of the sensor child // Initialize message //MyMessage msg(CHILD_ID, V_LIGHT); void setup() { pinMode(ledPin, OUTPUT); pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), state_change, CHANGE); Serial.begin(115200); } //void presentation() { // // Send the sketch version information to the gateway and Controller // sendSketchInfo("Switch", "1.0"); // // // Register all sensors to gw (they will be created as child devices) // present(CHILD_ID, S_LIGHT); //} void loop() { // boolean status = digitalRead(DIGITAL_INPUT_SENSOR); digitalWrite(ledPin, state); //Serial.println(digitalRead(ledPin)); //Serial.println(status); //send(msg.set((status)?"1":"0")); //Send status value to the GW } void state_change() { Serial.println(state); state = !state; }
The problem starts is when I add the line #include<MySensors.h>. When I add this line to the code, LED doesn't toggle when I flip the switch. I don't know what the problem is.
I really appreciate the help.Thank You,
Vaibhav -
RE: How does MySensors actually work
I have built the gateway using the NRF24L01+. I just followed the steps shown in the video on the mysensors website. I have different Arduino for the Gateway and the sensor. I have the DS18B20 temperature sensor connected to the Arduino, I followed stpes from https://www.mysensors.org/build/temp and uploaded the code for it on the Arduino with the gateway.
Which code should I upload to the Arduino with the sensor connected to it? How do those Arduino's talk to each other?Now I am trying to connect it to Domoticz. I followed the hardware setup instructions on the domoticz manual here: http://www.domoticz.com/DomoticzManual.pdf and typed in the information about the name, type, serial port and the baud rate and got a device to show up on the Hardware tab. But nothing shows up in the Devices tab. Whats the next step after this for connecting my gateway and sensors to Domoticz?
I am using Domoticz because it's a software based controller and I am just starting with the IOT realm, so I want to keep things simple. -
RE: How to connect sensors to Domoticz
@AWI
I have done that. I input the name, type, serial port and the baud rate information on there and now I can see the device in the hardware tab. What's the next step after that?I have different Arduino for gateway and DS18B20 sensor. I have flashed the code: https://www.mysensors.org/build/temp to the Arduino with gateway. Which code should I flash on to the Arduino with the temperature sensor DS18B20? How do the two Arduino's talk to each other? and what is the next step in getting the Domoticz connected to the gateway?
Thank You
-
How to connect sensors to Domoticz
Hello guys,
I need help.
I know this is very basic stuff but I am very new to IOT and mysensors. I am trying to get started with the serial gateway and Domoticz as my controller.I have built the gateway using the NRF24L01+. I just followed the steps shown in the video on the mysensors website. I have also built the DS18B20 temperature sensor from https://www.mysensors.org/build/temp and uploaded the code for it on the Arduino.
Now I am trying to connect it to Domoticz. I followed the hardware setup instructions on the domoticz manual here: http://www.domoticz.com/DomoticzManual.pdf. But nothing shows up in the Devices tab.
I have the sensor setup on the same Arduino on which I have setup the Gateway. Am I supposed to use two different Arduino's for Gateway and the sensor? What steps should I follow to connect it to the Domoticz. I am using Domoticz because it's a software based controller and I am just starting with the IOT realm, so I want to keep things simple.
Thank You
-
RE: How does MySensors actually work
@mfalkvidd
OK great. So I am not completely lost.I am doing a project where I am growing a plant in a enclosed box where I want to control the parameters like temperature, humidity, pH level of the water, CO2 concentration etc. and I want to monitor and control these parameters using an Android app.
Which controller do you recommend considering there are like 5-6 different sensors involved and monitoring/control with an app is crucial.
OR do you want me to make a different post for this?
Thank You,
Vaibhav -
RE: How does MySensors actually work
@sundberg84 Thanx for the reply.
I read the contents of the network page before posting this question.
Can you explain controllers more in the sense that if they are hardware based or software based? I saw OpenHAB controller which looked like a software based controller like you install it on the Windows machine and it works where as Vera has a hardware home automation controller.
What piece am I missing here?
Thank You,
Vaibhav -
How does MySensors actually work
Hello everyone,
I know this is a very dumb question but I am very new to all this. My question is how does this thing work? I have seen the getting started videos and I have also read the whole getting started page on the website. Here is what I understood.
- I need to get the Arduino, radio and a sensor. Wire everything up as shown on the website and power up.
What after that? I figure I need to connect to the internet using the radio. but after that how does this all connect up? What is vera? Do I need to have it? It looks like a router. Can I use my own router I already have at my home for this? How does the android app connect to the sensors?
All the videos show how to make a gateway and how to wire up arduino and sensors but then after that they suddenly show the web interface and the android app and everything just starts working. I am having hard time connecting the dots here.
I am very new to all this but I think I have read whats on the website and also watched the videos before posting this question. So can anyone guide me through the step by step process?
Thank You