UNSOLVED REXduino - 1-wire connection
I use REXYGEN version 2.50.10 on RPI with Arduino Mega - REXduino.
Question 1: I would like to ask whether it is possible to read different signal quality according to the example of connection with use of the VIN (Validation of the input signal) function block? It happens that some ds18b20 sensors are not of such quality or have a long line that they fail.
Question 2: It happened to me that after restarting RPI and starting REXCORE, the 1-wire sensor moves in the SW to another address / variable. Is it possible to somehow ensure that a unique address is assigned to the 1-wire sensor?
Thank you very much for the answer.
to the Question 1: In general, multiple VIN blocks can be used to read quality from multiple sources. Unfortunately, it probably won't work in your case, because all the data comes from one source (REXduino block).
to the Question 2: In REXduino, it is currently not possible to ensure that a 1-wire sensor will always get the same address if there are more sensors. We recommend using Monarco HAT or a 1-Wire hub instead of Arduino.
Using another hardware (with the Raspberry Pi) should also help solve the first problem. In the Raspberry Pi, it would then be possible to fix the addresses of the individual 1-wire sensors using this manual.
I have another problem. I read 1-wire sensors from Arduino (see below). I always have only one 1-wire sensor connected per one pin. For 1-wire sensors I used Arduino pins 22, 23, ..., 33. I configured the Arduino_MEGA2560hex function block as shown below. In the REXYGEN Studio / Target / System Log, I get these messages (see below). The values of the 1-wire sensors are read correctly. Yesterday the communication between RaspberyPI and ArduinoMega stopped working. I'm afraid it won't happen again (by REXduino I control the heating in the house). Because I found out according to the REXduino manual that this could be a poorly defined pin, I reconfigured pins 22, 23, 24, 25 as 0: Not connected. Then the System Log is error-free.
Why does this happen if these pins are reserved for 1-wire? I need to use them because I have a lot of sensors.
Thank you very much for your response.
@mtomek Hi Michal,
REXduino slave error, code 51 49 means that the master is sending too much data... in other words that the slave is unable to process data and respond to all the requests.
Keep in mind that reading data from 1-wire sensors takes a relatively long time (the slave is currently set as #define ONEWIRE_TEMPCONV_DELAY 800 ms). It can very easily happen that the slave will not be able to read data from twelve 1-wire sensors and send values over the serial to your Raspberry Pi with the period with which the master is running.
My advice is to try setting a larger value for the running period on the master side. You can do it in REXYGEN in the EXEC block (see documentation here https://www.rexygen.com/doc/ENGLISH/MANUALS/BRef/EXEC.html).
But my private opinion is that you are very close to the maximum possibilities of REXduino. In your place, I would consider the options I suggested to you above.
@reitinge Hi Jan,
I set the execution time for reading and writing data from/to Arduino on 1s. After this change came only one error for five hours (see below). Before this, the mistakes came every second, which is progress. What does this error code mean? Are these error codes somewhere described?
I definitely began to think about at least that I would blame another way of 1-Wire sensors. How could I join the RaspberryPI proposed 1-Wire Port Hub? Is it a function block in the REXYGEN for it? This could improve communication with Arduino and use it only for binary I/O.
Thank you very much.
@mtomek Hi Michal,
I found the meaning of the errors directly in the REXduino_slave.ino code. The first number indicates the type of error and can have values:
- 49 - ERROR_COMMAND
- 50 - ERROR_PINMODE
- 51 - ERROR_SERIAL
- 52 - ERROR_ONEWIRE
- 53 - ERROR_I2C
The second number indicates error specification. For example for ERROR_ONEWIRE:
- 49 - ERROR_ONEWIRE_NOMOREDEVICES
- 50 - ERROR_ONEWIRE_BUSYBUS
- 51 - ERROR_ONEWIRE_BADCRC
- 52 - ERROR_ONEWIRE_DEPLETED
- 53 - ERROR_ONEWIRE_NOTEMPDEVICE
I agree that the errors could be mentioned more explicitly somewhere.
So in your case, the code 52 51 means bad crc error. So, for example, some noise may have appeared during data transmission.
I don't have any experience with the UniPi hub, because I'm using Monarco HAT. But as I understand to the UniPi 1-wire knowledge base, you should use the first hub port to connect the hub to your Raspberry Pi GPIO. Default GPIO pin for 1-Wire is GPIO 4. After connecting, you can read the data in REXYGEN using OwsDrv module. Please pay special attention to the note in the knowledge base:
Unfortunately, I have no idea if the UniPi hub provides ESD protection. You should check this directly from the manufacturer. If the hub doesn't have protection, I definitely wouldn't connect it directly to the Raspberry GPIO. The resistance of such a solution to the induction of unexpected voltages is negligible and it's possible that your Raspberry would get burned. In the absence of ESD protection, I would rather invest in Monarco HAT, where ESD protection is present and Monarco communicates 1-Wire over the I2C bus (documentation here), so 1-Wire is not connected directly to the processor.