Closed Fux2 closed 8 months ago
@Fux2 ,
Most common mistakes:
The only way to further debug is to attach a signal analyser, since signals are slow a low end debugger is fine. I can recommend to look into sigrok backend & pulseview GUI supported ones.
Unfortunately I cannot read any data from the BME280. The following is output on the BMP280: 0x04 0x1230 0.00 C (bmp280) 0x04 0x1231 0.00 hPa (bmp280)
The BME280 says “No BME280 found”.
To test I changed the address of BMP280 to 76 ( here ). My Raspberry displayed this address on I2C.
Now the measured values from the BMP280 are correct, but the BME280 still says "No BME280 found".
0x04 0x1230 21.29C (bmp280) 0x04 0x1231 1012.02 hPa (bmp280)
0x04 0x1240 No BME280 found.
Do you have a tip for me? Thanks
@no-ahnu ,
Did you enable -DBME280
flag (and may remove -DBMP280) in the make.sh script ?
https://github.com/cbalint13/tinnymodbus/blob/024dad54e0ae67c3fa570620e4a8934f21528c19/make.sh#L21
Hello cbalint13 and thank you for the quick answer. I think the project is very great.
I changed the line in Make.sh. DEVS_ENABLE="-DDS18B20 -DBME280"
0x04 0x1230 No BMP280 found.
0x04 0x1240 11018751.18C (bme280)
0x04 0x1241 11490358.07 hPa (bme280)
0x04 0x1242 11118287.26 %RH (bme280)
The BME280 now delivers values, but unfortunately the wrong ones.
Hello cbalint13 and thank you for the quick answer. I think the project is very great.
I changed the line in Make.sh.
DEVS_ENABLE="-DDS18B20 -DBME280"
DEVS_ENABLE="-DDS18B20 -DBME280 -DCALIBRATION"
0x04 0x1230 No BMP280 found.
0x04 0x1240 11018751.18C (bme280)
0x04 0x1241 11490358.07 hPa (bme280)
0x04 0x1242 11118287.26 %RH (bme280)
The BME280 now delivers values, but unfortunately the wrong ones.
I don't own/use bme280
variant , since it is untested by me i left this as a experimental driver.
@stif , do you have ideas what might be wrong with these bad values ?
thanks for the tip. I activated the "-DCALIBRATION", unfortunately no success:
user@rtu:~/tinnymodbus/tools$ sudo python3 examples/pymodbus3.x/sensors-read2.py 0x03 0x0000 0 running mode
0x03 0x0001 0.06 software version
0x03 0x0002 1 slave address
0x03 0x0003 5.166972637176514V (internal)
0x03 0x0004 38.7674446105957 C (internal)
1-wire 0x04 0x0001 2 devices found id: 0 0x04 0x0100 28b0315704f53ceb id: 0 0x04 0x0200 22.75 Celsius
id: 1 0x04 0x0101 289e3581e37c3c79 id: 1 0x04 0x0201 22.5 Celsius
i2c 0x04 0x1240 11018698.75C (bme280) 0x04 0x1241 11490341.68 hPa (bme280) 0x04 0x1242 11118287.26 %RH (bme280)
I hope for an answer from stif
thanks for the tip. I activated the "-DCALIBRATION", unfortunately no success:
i2c 0x04 0x1240 11018698.75C (bme280) 0x04 0x1241 11490341.68 hPa (bme280) 0x04 0x1242 11118287.26 %RH (bme280)
I hope for an answer from stif
Could you try this patch / changes below (with DEVS_ENABLE="-DDS18B20 -DBME280"
) ?
diff --git a/main.c b/main.c
index 78a72df..db92e85 100644
--- a/main.c
+++ b/main.c
@@ -681,21 +681,21 @@ int main(void)
bme280_done = 0x01;
}
float V;
int32_t V; if ( daddr == 0x1240 ) {
V = (float) bme280_read_value( BME280_TEMP )/100;
V = bme280_read_value( BME280_TEMP );
V = V + CAL_TOffset;
#endif
}
if ( daddr == 0x1241 )
{
V = (float) bme280_read_value( BME280_PRES )/100;
V = bme280_read_value( BME280_PRES ); } if ( daddr == 0x1242 ) {
V = (float) bme280_read_value( BME280_HUM )/100;
V = bme280_read_value( BME280_HUM );
V = V + CAL_HOffset;
#endif
I suspect the issue is the cast of float
, BMP280 use int32_t
, avoiding expensive float
in the firmware.
Here I first have to understand what I should do. But I will definitely try it. Thanks for the tip!
Here I first have to understand what I should do. But I will definitely try it. Thanks for the tip!
@no-ahnu ,
I just pushed this commit upstream, you can update your local copy now with git pull
& recompile it.
Some notes:
float
in the drivers.int32
type is expected on the modbus wire, see:Let me know about the outcome of results on your side.
I just saw that you have already made the changes to main.c. Then I no longer have to think about what needs to be adjusted.
I have now downloaded the new main.c and created a new main.hex with DEVS_ENABLE="-DDS18B20 -DBME280"
in make.sh.
Flashed this and here is the output.
user@rtu:~/tinnymodbus/tools$ sudo python3 examples/pymodbus3.x/sensors-read2.py 0x03 0x0000 0 running mode
0x03 0x0001 0.06 software version
0x03 0x0002 1 slave address
0x03 0x0003 5.119999885559082 V (internal)
0x03 0x0004 38.7674446105957 C (internal)
1-wire 0x04 0x0001 2 devices found id: 0 0x04 0x0100 28b0315704f53ceb id: 0 0x04 0x0200 22.9375 Celsius
id: 1 0x04 0x0101 289e3581e37c3c79 id: 1 0x04 0x0201 22.5625 Celsius
i2c 0x04 0x1240 21.81C (bme280)
0x04 0x1241 1011.56 hPa (bme280)
0x04 0x1242 49.29%RH (bme280)
That looks really GREAT. THANKS!!!
@no-ahnu
i2c 0x04 0x1240 21.81C (bme280)
0x04 0x1241 1011.56 hPa (bme280)
0x04 0x1242 49.29%RH (bme280)
That looks really GREAT. THANKS!!!
Thank you too for the time and patience !
Hello, I built up two of the tinnymodbus. Flashing over modbus works fine. I can also read out the internal voltage (0x03 0x0003), the internal temperature is too high. I tested with a DS18S20 and a I2C SHT21 sensor. Both can't be read.
When using the Python script "sensors-1w-read.py" the readout works once (beside of wrong sensor values) and the Attiny hangs up afterwards and power has to be removed and connected again for further working. I tried also an older firmware - same results. How can I debug the readout of the sensors or do you have any suggestions? Any help is appreciated.