Problem with Accelerometer RAK1904 negative values to TTS

@projectsbminfo
I run your code on my WisBlock with the following small change by (trying to make) X negative and then print out the values before adding them to the payload:

	x_axis = -13 * 100;
	y_axis = 14 * 100;
	z_axis = 15 * 100;

	data = "Tem:" + String(temp) + "C " + "Hum:" + String(hum) + "% " + "Pres:" + String(pres) + "KPa " + "Gas:" + String(gas) + "Ohms" + "Device_Latitude: " + String(device_latitude_unit8) + "Devic_Longitude: " + String(device_longitude_unit8) + "Battery=" + String(vbat_per_unit8);
	Serial.println(data);

	Serial.printf("X %d Y %d Z %d\n", x_axis, y_axis, z_axis);

And it runs just fine, it does not crash. But of course the X value is very high, because x_axis is an unsigned int, so it converts the negative number to a very high value.

Chip ID=0xFF
BME680 initialized!
Setting DevEUI, etc...
lmh_init response code: 0
GPS uart init ok!
 CHARS=0 SENTENCES=0 CSUM ERR=0
** No characters received from GPS: check wiring **
Battery Voltages are: 4206.74mV
Battery Percentage is: 101%%
Battery Percentage_unit8 is: 101%%
result: Tem:295.48C Hum:0.00% Pres:5.12KPa Gas:20177OhmsDevice_Latitude: 0Devic_Longitude: 0Battery=101
X 64236 Y 1400 Z 1500
 CHARS=0 SENTENCES=0 CSUM ERR=0
** No characters received from GPS: check wiring **
Battery Voltages are: 4276.43mV
Battery Percentage is: 111%%
Battery Percentage_unit8 is: 111%%
result: Tem:295.48C Hum:0.00% Pres:5.12KPa Gas:20177OhmsDevice_Latitude: 0Devic_Longitude: 0Battery=111
X 64236 Y 1400 Z 1500

thank you to all , the device now is working .

2 Likes