You don’t need to create the persistence file yourself. You just need to make sure that the path to the persistence file in your home assistant configuration.yaml leads to a directory that exists on your computer and that home assistant can write to that directory. The first time a mysensors sensor reports a value, home assistant will create the persistence file.
Regarding the error to decode the message from the gateway: Make sure that only home assistant is connected to the usb serial gateway device. The serial connection is exclusive, meaning that there will be a problem if two programs try to connect and read from the same serial device at the same time. For example, you can’t have the Arduino IDE serial monitor connected to the gateway at the same time as home assistant is running.
Thanks for helping me out. About the points you raised, I changed the presistence_file to:
persistence_file: 'C:\mysensors.json'
And I still get the error that such file doesn’t exist or it is not readable.So I think now what can be the cause, is that the sensor is not reporting any value which in turn will trigger the HA to create that “mysensors.json” file …
Also, I triple checked and there is no other program that is trying to use same gateway as the HA …
I personally had several issues with this (might be related to security … ) so I ended up with creating the file myself as a regular practice
hey @mehrdad.silatani, can you please paste again the logs from the GW and HA for the same timeframe? this way we can see both sides of the communication.
To add to my list of confusions, I noticed that once you copy paste a local file address from my windows explorer, all the rootings are done by using " ", whereas in the original YAML file, the field in front of “persistence_file” is using “/”. To compare:
Window explorer: “C:\Users\Mehrdad\AppData\Roaming.homeassistant\mysensors.json”
YAML original file : “path/mysensors.json”
If you’re using a regular Arduino Nano as gateway, which runs at 16 MHz, you should not change the baudrate to 38400. You can remove that line from your config.
Regarding the persistence file, I wouldn’t worry about it until you have the gateway successfully reporting values in home assistant. If you then still get the warning when restarting home assistant, we can look at it then.
There is only one USB connected to my laptop which is the Arduino nano … I doubled checked with looking at the port of serial communication when I was uploading the sketch to the board (which I later closed so it doesnt interfere …)
That output is from a sensor sketch, not a gateway sketch. If you’re sure you have the arduino that you want to use as gateway connected, you should upload the serial gateway sketch again to the arduino.
Ow I think I get it now … I have been doing things wrong !
Correct me if I am wrong, I need to include the following code lines at beginning of every sketch of a sensor before uploading it to my arduino board …
And then in following of it, the rest of sketch comes.
By including those lines at beginnig of my Light sensor code, now the HA is showing some activity … For the first time, a circle named as light sensor has poped up in my HA !
No, that is not correct. Only the gateway needs to be defined as a gateway in the sketch. There are gateway sketches and there are sensor or actuator sketches among the examples for the mysensors library.
To one arduino you should upload a gateway sketch. To another arduino you should upload a sensor sketch. Make sure this is working before involving the controller. You can check that it’s working by using the serial monitor in Arduino IDE. If you start two instances of Arduino IDE, you can monitor both sides at the same time, gateway and sensor.
I suggest you go to mysensors.org and read more about how the mysensors network works and how to use the library.
OK, I am heading to mysensors again to go through their information. Hopefully I will understand it this time. My apologies for not knowing much and possibly wasted everyone’s time !
But to make sure I understand you correctly; I need,
One (Arduino + nRF24L01+) only having “serialgateway” sketch on, which is also connected to my computer with a USB interface. (Basically, some sort of a server/receiver)
Second (Arduino + nRF24L01+) having the “sensor” sketch on, which communicates with the first Arduino (server) to send data to HA. (Client Arduino)
Edit: There is another case also, where you can have local sensors on the gateway. This is only available in mysensors 2.0 and later. But usually you want to have some nodes with sensors connected via radio to the gateway.
I think, I made a step forward and I am getting close to where I want thanks to you all.
At the moment, I have my GW (server) and my node (client/sensor) both up and running ! And I think the GW successfully discovered the sensor, judging based on the readings on the Serial port of the GW ;
Once I fired up the HA on my desktop (before I was using a laptop, so HA is now on a different machine), it recognises the sensor as it shows up in the homepage of it, however, it comes up with a new error while initialising the HA;