@TimO .. perfect thanks very much. this is the missing part.
Posts made by Coffeesnob
-
RE: Mysensor Serial with OpenHab2 how to please....
-
RE: Mysensor Serial with OpenHab2 how to please....
@gohan that's a great suggestion. The short answer is because I have no idea how to do that. As I said in my last post I'm not a Linux guy and while I like to think I'm pretty intelligent, with your suggestion I would not know where to begin. Having said that it is a great idea, less parts= less things that can go wrong.
-
Mysensor Serial with OpenHab2 how to please....
Greetings, I am very new to openHAB. I think I might like it but I am struggling a lot with the gaps in documentation. which is why I'm posting here.
my setup is openHABian running on a Raspberry Pi v 1b, openHab is running perfectly and i can control network devices such as Wemo switches, I have Mysensor v2 running on a Nano with 5 nodes, these are all working perfectly with my very old and slow Vera 2.
I am using a serial gateway because this suites my setup better than Ethernet. I figure I have Raspberry Pi that has power and Ethernet, my not use it to power the Arduino as well. Besides that, I have not been able to successfully get the Ethernet gateway on Mysensor to work. But that’s another battel for another day.
So here is my question. How do I configure OpenHab v2 to use the USB port to talk to Mysensor? There is no description on how to configure Mysensor to work serially with Openhab 2. there is a basic description on how to do it for v1.x but this is not at all helpful because OpenHab 2 doesn't use openhab.cfgThe screenshot below shows the Mysensor Serial configuration page, but I don’t know what to put here.
![alt text]( image url)
In case its not obvious. I’m not a Linux guy, so what may be obvious to anybody who is a Linux guy is not remotely obvious to us windows dudes.
Thanks in advance for your help. -
RE: Still not going well for me.
Thanks heaps @Hek and @petewill I didn't realise that without the controller running I will not get a node id. I thought incorrectly the node id came from the gateway. I booted up MYSController and it now works as expected. thanks for pointing me in the right direction..
cheers until next time.
-
RE: Still not going well for me.
Ok, so the new hardware has finally arrived and I have been pulling my hair out trying to get it working. It appears like there is something wrong in the way the node and the gateway are setting up. I didn't have this problem a couple of weeks ago but since I have upgraded to v2.1.1 the problem has manifested. I have seen that there are a number of posts that appear to have similar issues but not exactly the same. Perhaps somebody can shed some light.
The setup is still exactly the same as I have described earlier in this post. I have a Mega and a Nano both with NRF24L01, I have a 10uf Cap across the power supplies of both radios, and I am 100% sure that the radios and the Arduinos are all working because I have built a NON Mysensor test sketch to prove this is all fine. Aside from that you can also see from the log transcript below that the units are actually talking. They just don’t seem to be able to complete the negotiation.
So here is what I am seeing. in the log transcript below you can see that the two devices are talking to each other. the Bold text are the messages being sent from the gateway and the normal text is the messages being sent from the Node.
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.1.1
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=10 MCO:BGN:INIT REPEATER,CP=RNNRA--,VER=2.1.1
3 MCO:BGN:BFR
5 TSM:INIT
6 TSF:WUR:MS=0
12 TSM:INIT:TSP OK
14 TSM:FPAR
16 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:0;255;3;0;9;TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
0;255;3;0;9;TSF:MSG:BC
0;255;3;0;9;TSF:MSG:FPAR REQ,ID=255
0;255;3;0;9;TSF:CKU:OK,FCTRL
0;255;3;0;9;TSF:MSG:GWL OK
0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:089 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
94 TSF:MSG:FPAR OK,ID=0,D=1
2023 TSM:FPAR:OK
2024 TSM:ID
2025 TSM:ID:REQ
2027 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;4035 TSM:ID
4036 TSM:ID:REQ
4038 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;4035 TSM:ID
4036 TSM:ID:REQ
4038 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;4035 TSM:ID
4036 TSM:ID:REQ
4038 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;10066 !TSM:ID:FAIL
10067 TSM:FAIL:CNT=1
10070 TSM:FAIL:PDTWhat you can clearly see here is that the initial node setup takes place, the request from the node to the gateway is received by the gateway and it reply’s. the node receives the reply and then it sends its reply, the Gateway receives the reply and then try to send an acknowledgment, but the node never gets the message. I suspect this is because the message being sent from the gateway is incomplete for some reason.
For example the Node sends
4038 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
The gateway responds with
0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:Which in and of its self doesn’t look exactly right to me, but as I am not the expert in this I am probably wrong.
The gateway then prints 255;255;3;0;3; with nothing else in the line, this looks to me like its trying to send something but the message is empty.
What are your thoughts? @mfalkvidd and @petewill I am hoping you guys can shed some light here.
Thanks in advance.
-
RE: Still not going well for me.
@mfalkvidd, I have finally had the opportunity to reply to your question from a week back “Could you list the top 3-5 things that would have helped you the most, and where you would have expected to find that information? That would be great input.”
Ok so I think the big thing is there is not a lot of detail in troubleshooting. Clearly the radios are the most problematic part and not being able to get access to how they actually work makes it very frustrating. The table that peterwill provided is very helpful but this also requires you to have some background information.
I understand that you are trying to limit the amount of detail so as not to scare people away but I personally believe that having optional reference material would be extremely helpful. For example a diagram which explains how all the different liberties link together, this would have helped me to determine how the SPI components are setup.
It would have been extremely helpful if in your initial radio setup guide you had a reference to how the SPI components of the radios work. This would be an optional reference that people could look at if they wanted to. At the moment, the way these radios work is very much black magic, and because I am new to the whole Arduino thing I was unable to determine if you are using the standard SPI features of the Arduino or if you had created your own. An example of a reference might be https://www.arduino.cc/en/reference/SPI however it is also important to explain that Mysensors is using its own SPI library, you could (should) go into more detail about how the SPI library is setup from the Mysensors point of view, because if you have to work it out your self this is very chanalgin because there is no common reference to understand how Arduino default SPI relates to mysensors SPIAnd finally, something which would make things oh so much easier, is a sample sketch that will just allow you to test the radios, i.e you type the number 1 into the serial monitor on the gateway and you will see a message on the node if the radios are all working. And vice versa. I am willing to take this on as a project as I am already working on it however I would ideally like it to use all the Mysensors library’s. In other words, it should behave like any other sensor network would. But I really need a lot more information to work out how to do this. In the meantime, once I get my radios back up and running again I will post a very quick and dirty version and let you have a look at it.
I hope this all makes sense. I am a huge fan of the work the my sensors team have done here. I want to do what I can to help make it better. -
RE: Still not going well for me.
@tekka, will do. I have had a hardware related issue that is unrelated to this directly. (i bricked my Nano trying to flush the eprom) but it means that until I get this fixed or get new hardware I am not going to be able to do anymore. Im hoping that Im getting close because this is really getting pretty frustrating.
-
RE: Still not going well for me.
@petewill, yep you would think that would do it... however, it doesn't seem to work. what is interesting is if I send a 1 it also doesn't turn on the relay, only sending an empty message turns it on. I think I might post in the MYSController forum to see if they have any ideas.
-
RE: Still not going well for me.
@mfalkvidd, I can post here no problem. but I also want to provide a how-to of sorts that will help newbies like me to rule out anything that is Mysensors related. I just thought this would require me a to PM you
-
RE: Still not going well for me.
@petewill, appreciate it. I'm very happy with the outcome, for the most part. However, I now have a new challenger. I am using a relay module and I can happily turn relays on using MYSController but can't seem to figure out how to turn them off. I know you know a little about this product so I wonder if you can point me in the right direction.
I have also connected to my gateway serially using HomeGenie and it can't turn either on or off. but I haven't had time to do any further fault finding there yet.As soon as I have time, I will provide promised doc. i then need to know where to send them.
-
RE: Still not going well for me.
@mfalkvidd thanks for your reply. I was going to try and contact you about this very thing. If its ok can I PM you will suggestions, I completely get what you’re talking about, I know this problem very well. But there is a way you can provide the information required that is not so in your face which I agree can be an issue.
I would also like to develop a test Sketch that can be used to prove that all the hardware is working independent of anything in the API. This would have made my experience that much easier because I was not actually able to determine where the issue was until I had first proven that it was not the radio or the two different boards I am using (which was suggested in this post as well as in the troubleshooting guide). Are we able to perhaps have a chat via email or something about how to facilitate that? -
RE: Still not going well for me.
@petewill, you sir are a star... this was the information I was missing and it is now working as expected. below is the serial monitor trace from both the Mega and the Uno.
First the Mega
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;TSF:MSG:READ,10-10-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
0;255;3;0;9;TSF:MSG:SEND,0-0-10-10,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
0;255;3;0;9;TSF:MSG:READ,10-10-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.0
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDEDand this is the Uno...
8994 TSF:MSG:SEND,10-10-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
9000 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
9006 MCO:SLP:TPDI have literally spent hours on this. I think the documentation in terms of getting started needs to be expanded on considerably. I get this is a huge task but if you don't know much about Arduino or know where to look you pretty much screwed.
-
RE: Still not going well for me.
@petewill, Wow this is EXACTLY what I have been looking for. thanks very very much. I will give it a try.
-
RE: Still not going well for me.
@petewill, thanks for the tip. I think you might actually be onto something. But as I don't have any other nano's that's not really an option today. I have order more but they will take at least 3 weeks to get here.
having said that, I have made some important discoveries in the last 24 hours. bottom line I have written a test sketch that runs on both a nano and a Mega and it send messages back and forth between them. This has proven 100% that the issue is not hardware related but it is software related. Now my plan is to write a script that uses the MyConfig.h to get the SPI settings. That way once it's all working with the test sketch you will have a very high probability of it working with Mysensors.
also while I have your attention. I really found your troubleshooting video very very helpful, thanks a lot for doing that. but I wonder do you happen to have or know of a video which shows how to use MYSController. once I get past my current woes I suspect I will need MYSController to resolve other issues.
thanks for your help so far. i really do appreciate it.
-
RE: Still not going well for me.
MarcoE- thanks for the tip. I don't have a spare radio but I have another Arduino project I can load which is from another home automation system (DeviceBit) , when load that up I get 100% reliable communication between the two radios so I'm pretty sure its nothing at all to do with hardware.
iotearoa- I am not convinced that the issues is power related. given that the Devicebit method doesn't require a cap and it is using the power from the Arduino. Never the less, i have a 10uf cap i can try.
Having said that clearly given the very low number of responses I must be the only one with this issue. so i think what I'm going to do now is reverse engineer a test communication network using the code from DeviceBit. if I get this to work, then I will post the results here. this may also end up being useful for somebody else because, to be honest, the diagnostics on mysensors are a little bit light on and this makes the exercise a lot frustrating.
-
Still not going well for me.
Hi there, I apologise in advance if the questions I am about to ask has a post that relates to it already. I have spent the last 2 weeks trying to get this working and I have been all over the forum many times without success so I have resorted to posting here. I have already posted earlier explaining my setup and how it all fits together. If your interested you can read it here.
https://forum.mysensors.org/topic/5657/im-brand-new-to-mysensor-and-its-not-going-well
but to recap, I have an Arduino mega with a WS5100 Ethernet Shield, an Arduino Nano, 2 x NRF24L01 modules and a relay module. The post above asks how about errors I was getting on the Mega with the NRF24L01 module, this is now solved or at least it appears to be. Thanks very much mfalkvidd and FotoFieber for your assistance.
So here is what’s happening now. All I am trying to do to start with is connect the Mega and the Nano together, the mega is my gateway and the Nano is my Node. As the troubleshooting guide suggests, I am starting small therefore I have removed the WS5100 Ethernet shield to simplify.
Below is a drawing of my Mega setup, as you can see the NRF24L01 is connected to pins 9.10,14,15,16 and 2. This now appears to be workingBelow is the sketch for the mega
* 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 * The ArduinoGateway prints data received from sensors on the serial link. * The gateway accepts input on seral which will be sent out on radio network. * * The GW code is designed for Arduino Nano 328p / 16MHz * * Wire connections (OPTIONAL): * - Inclusion button should be connected between digital pin 3 and GND * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series * * LEDs (OPTIONAL): * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * */ // 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 // 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 // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds //#define MY_WITH_LEDS_BLINKING_INVERSE // Flash leds on rx/tx/err // 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 <MySensors.h> void setup() { // Setup locally attached sensors } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here }
I am using the default MyConfig.h for the Mega, with one small exception, the #define MY_SOFTSPI is enabled because I am using the Soft SPI pins.
Below is the Serial-Monitor output.
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.0
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.1.0
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1So far so good!
Now we get to the Nano. Below is a drawing, as you can see the NRF24L01 is connected to pins 9.10,13,11,12 and 2. This now appears to be working but it doesn’t seem to be able to reach the gateway.The two devices are sitting about a meter apart so it is very very unlikely to be a range issue.
Below is the sketch for the Nano/** * 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. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik Ekblad * * DESCRIPTION * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // Enable debug print #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #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 1 // 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 bool 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); }
The MyConfig.h for the Nano is default.
Below is the Serial-Monitor output.
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.0
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=10
14 TSM:FPAR
51 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2058 !TSM:FPAR:NO REPLY
2060 TSM:FPAR
2096 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
4104 !TSM:FPAR:NO REPLY
4106 TSM:FPAR
4142 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
6150 !TSM:FPAR:NO REPLY
6152 TSM:FPAR
6188 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
8196 !TSM:FPAR:FAIL
8197 TSM:FAIL:CNT=1
8199 TSM:FAIL:PDTI have seen on one of the troubleshooting posts that you can use MYSController to try and fault find this. But I can’t find any instructions on how to use it which is to say the least annoying. I tried my best to figure it out but it doesn’t seem to be working. It says it is connected but nothing happens. If you happen to know of instructions that would probably be a good first step.
It appears to me that the node is not able to connect to the gateway, originally I was getting an error
4142 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
6150 !TSM:FPAR:NO REPLYWhich if I read the API document correctly is a broadcast. But I set the define MY_NODE_ID 10 in an attempt to connect it to MYSController but could not get it to work so I switched it back to Auto.
What am I missing?... thanks for any assistance. I am about to give up because this is starting to seem to me to be unnecessarily difficult.
-
RE: im brand new to MySensor and its not going well
@mfalkvidd Thanks again for your reply, I greatly appreciate your efforts. So, I have made some good progress and now I think we are getting close. I discovered a bit of an anomaly in the way things are described on the website which doesn’t make it easy to understand how to connect things up when your first crack at this. It is probably worthwhile clarifying on this page https://www.mysensors.org/build/ethernet_gateway. So what I have discovered is that the page linked to above describes setting the NRF24L01 on pins A2,A1,SCK,CSN,CE however it also goes on to talk about potential conflicts with SPI, and to use alternative pins, however, it doesn’t really make it very clear how to do that.
So here is what I did. I found a library called NRF24L01_h which was provided to me by Device.bit when I was looking at using their approach. By reading this I was able to get a much clearer understanding of how the SPI works and as you can see this file maps the NRF24L01 pins to 30,28,26,24,22 and 32 as the IRQ.#ifndef NRF24L01_h #define NRF24L01_h #include "API.h" //--------------------------------------------- #define TX_ADR_WIDTH 5 // 5 unsigned chars TX(RX) address width #define TX_PLOAD_WIDTH 1 // 20 unsigned chars TX payload //--------------------------------------------- #define CE 22 // CE_BIT: Digital Input Chip Enable Activates RX or TX mode #define CSN 24 // CSN BIT: Digital Input SPI Chip Select #define SCK_PIN 26 // SCK BIT: Digital Input SPI Clock #define MOSI_PIN 28 // MOSI BIT: Digital Input SPI Slave Data Input #define MISO_PIN 30 // MISO BIT: Digital Output SPI Slave Data Output, with tri-state option #define IRQ 32 // IRQ BIT: Digital Output Maskable interrupt pin //********************************************* #endif
So I started to re-write the example code to user this but in doing so I discovered these lines of code in the example script and then the penny dropped.
#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
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
IP: x.x.20.12So we are away. The radio is working and now I am starting to understand how the code works a little better….however!!!!
In the Ethernet code there is a line #define MY_PORT 5003 which is what mynode will connect to. Only issue now is this port doesn’t seem to be open or it is in the wrong mode somewhere deeper in the code. If I load the example code for Chat server. And set the port to 5003 then my node can connect to the Mega no problem. So I know it's not firewall or hardware or in fact network related. Can you point me in the right direction to troubleshoot this please. i suspect the issue will be in one of the libraries further down the line.
-
RE: im brand new to MySensor and its not going well
@mfalkvidd thanks very very much for the warm welcome and rapid reply particularly at this time of year. I can see that you have put a huge amount of work into getting this all setup up so you are to be congratulated. However, as a new user coming into this cold with little Arduino knowledge I can see there are some big gaps in the documentation.
First of all, the Ethernet tutorial which is where I started doesn’t say anything at all about DHCP it only says to configure a static IP so that is why I went that direction. But just a point on that. If im not mistaken your code doesn’t show you what the IP address is. This would be extremely useful particularly if you are using MyNode like I am.
In any case, here is what the current status is. I have added a static gateway and Subnet but this didn’t work so there is something else wrong. I have also tried to set to DHCP Mode but according to my Router (Cisco) the device is not getting an IP address. (I have not given full IP and Mac address for security reasons) the mac address is not showing up in the address list.x.x.20.52 ffff.ffff.1ea8 Jan 02 2017 12:18 PM Automatic
x.x.20.55 ffff.ffff.6926 Jan 02 2017 09:32 PM Automatic
x.x.20.59 ffff.ffff.4f1c.d8 Jan 02 2017 07:15 PM Automatic
x.x.20.69 ffff.ffff.30a1.00 Jan 02 2017 09:00 PM Automatic
x.x.20.80 ffff.ffff.5cfb.9e Jan 02 2017 11:07 PM Automatic
x.x.20.86 ffff.ffff.d903.0b Jan 02 2017 09:42 PM Automatic
x.x.20.90 ffff.ffff.3103.ff Jan 02 2017 11:50 AM Automatic
x.x.20.91 ffff.ffff.25fd.9e Jan 02 2017 10:30 PM Automatic
x.x.20.104 ffff.ffff.00f4.2c Jan 02 2017 10:18 PM Automatic
x.x.20.105 ffff.ffff.c58b.f5 Jan 02 2017 09:01 PM Automatic
x.x.20.106 ffff.ffff.1a61.1f Jan 02 2017 11:13 PM Automaticthe full code is below.
/** * 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. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik EKblad * Contribution by a-lurker and Anticimex, * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de> * Contribution by Tomas Hozza <thozza@gmail.com> * * * DESCRIPTION * The EthernetGateway sends data received from sensors to the ethernet link. * The gateway also accepts input on ethernet interface, which is then sent out to the radio network. * * The GW code is designed for Arduino 328p / 16MHz. ATmega168 does not have enough memory to run this program. * * LED purposes: * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions. * */ // 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 13 #define MY_SOFT_SPI_MISO_PIN 12 #define MY_SOFT_SPI_MOSI_PIN 11 #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,101,240 // If this is disabled, DHCP is used to retrieve address //#define MY_IP_GATEWAY_ADDRESS 192,168,101,1 //#define MY_IP_SUBNET_ADDRESS 255,255,255,0 // 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 // 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 // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Flash leds on rx/tx/err // 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 // Transmit led pin #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensors.h> void setup() { } void loop() { }
In relation to the errors, I have done as you have suggested and the NRF24L01+ is connected as per https://www.mysensors.org/build/connect_radio
There does appear to be a bit of confusion if using a W5100 shield module because the Ethernet page talks about issues sharing SPI.
“The W5100 ethernet module has problems sharing SPI with radio. To solve this, we put the radio on a couple of other pins and use so called soft-spi. That's why you have to wire the radio a little differently here than on the usual sensors.”
Can you please clarify if this might apply in my situation.I'm going to keep playing around for about another half hour and see if i can figure out why this isn't working but I would really appreciate your help.
thanks in advance
-
im brand new to MySensor and its not going well
Hi there, I apologies in advance if the questions I am about to ask here are obvious and I should already have been able to find the answers. But I can’t so here we are.
First of I’m not new to home Automation, I have a Smarthings setup which works very well but its very expensive to expand and I find the configuration a little “home automation for dummies” I have also played around with device.bit but this site appears to have been converted from chines so the language is a little challenging. But it works so if I can’t get the mysensor thing working then I will just go back to that for all its short comings.
So here’s the thing. I have spent many hours now trying to get my first project working with no success.
First of all I have an Arduino mega with a WS5100 Ethernet Shield, an Arduino Nano, 2 x NRF24L01 modules and a relay module.
All I am trying to do to start with is connect the Mega and the nano together, the mega is my gateway and the Nano is my Actuator I then want to control the relay using mynodes.net as my controllerSo first this first. Below is the Fritzing sketch of the circuit layout of the Mega
I have loaded the example code from the my sensor library, this is unchanged with the exception of the IP address of cause. Here is where I hit my first issue.
I am using mynodes.net, I really like how it looks so I want to give it a go. I have installed it on my local PC to start with. I will figure out a more permanent solution later. But when I try to connect the mynodes.net to my Arduino it fails. It is just unable to reach the ip address. Doing further digging I discovered that I can not ping the Mega so I decided to do some more fault finding.
I loaded an example from the Arduino Ethernet library called “chat server”, Code is below. The only thing I have changed from default is the ip Address and port. Because this code also asks for gateway dns and subnet, I have also configured them. I loaded it onto the Mega and bingo I was able to connect with mynodes.net without issue. Of cause I could not see any devices because none of that is in the chat server code.#include <SPI.h> #include <Ethernet.h> // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network. // gateway and subnet are optional: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192, 168, 1, 177); IPAddress myDns(192,168,1, 1); IPAddress gateway(192, 168, 1, 1); IPAddress subnet(255, 255, 0, 0); // telnet defaults to port 23 EthernetServer server(5100); boolean alreadyConnected = false; // whether or not the client was connected previously void setup() { // initialize the ethernet device Ethernet.begin(mac, ip, myDns, gateway, subnet); // start listening for clients server.begin(); // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.print("Chat server address:"); Serial.println(Ethernet.localIP()); } void loop() { // wait for a new client: EthernetClient client = server.available(); // when the client sends the first byte, say hello: if (client) { if (!alreadyConnected) { // clear out the input buffer: client.flush(); Serial.println("We have a new client"); client.println("Hello, client!"); alreadyConnected = true; } if (client.available() > 0) { // read the bytes incoming from the client: char thisChar = client.read(); // echo the bytes back to the client: server.write(thisChar); // echo the bytes to the server as well: Serial.write(thisChar); } } }
So this has led me to conclude that the GatewayW5100.ino must be relying on some default gateway and possibly subnet configuration that I can’t find. If this is true where do I set it. And also this should be more clearly defined in the initial setup instructions.
The next step. Below is the Fritzing sketch of the circuit layout of the nano
I have uploaded the default example for a relay Actuator. This loads successfully but when I open the serial window I see the following message, so clearly the two RF24’s are not talking.
0;255;3;0;9;TSM:INIT
0;255;3;0;9;!TSM:RADIO:FAIL
0;255;3;0;9;!TSM:FAILURE
0;255;3;0;9;TSM:PDTNow I have performed a bunch of test on this and I have categorically ruled out any hardware related issues. I did this by following a set of tutorials provided on the following link, https://www.sunfounder.com/learn/Smart-Home-Kit-V2-0-for-Arduino/experiments-smart-home-kit-for-arduino.html the English on this site is pretty average and it took me ages to work out what they were talking about but suffice to say I got it working.
Before I go any deeper, I wonder if there is any detailed instructions on how to setup your first node. This seems to be lacking, for example I have read in a couple of place a reference to addressing the nodes. So I need to understand how to do this? Because its completely unclear how the system works out how to communicate with the different devices, is there some magic involved that I need to configure.
I hope this will be straightforward to answer. I’m not somebody who normally posts in forums I usually figure things out on my own but I think some fundamental how to information is missing somewhere between the getting started and the build my first project. Because I seem to be missing a lot of fundamentals.