Hello DB. I am not an Arduino fan. I use the Arduino hardware but do the programming with Atmel Studio 7. I do not use Arduino IDE. So I do not use Arduino libraries. But I observed that the sprintf statement does not give output as negative values, even though the LCD shows negative readings. Can you spot any issues in my use of the sprintf function? Also, can you please guide me how to use MATLAB's data conversion functions to generate correct output from signed hex integer? Thanks.
How can I upload and plot temperature values that are both above zero (e.g., ambient) and below zero (e.g., in a freezer)?
6 views (last 30 days)
I wish to upload and plot on channel chart both positive and negative temperatures from DS18B20 sensor. While I can see the positive temperatures properly on the chart, the negative temperatures also show as above zero. The code snippet is as below:
if(temp_data & 0x80)
temp_data = (~temp_data)+1;
sprintf(esp_buff, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, -temp_data);
sprintf(esp_buff, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, temp_data);
//sprintf(esp_buff, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, temp_data);
It can be seen that the last two readings which are -6 and -9 deg C,show as +6 and +9 deg C. what should I do to make them come below the zero line?
Image Analyst on 12 Sep 2022
If you can get your data into a double image, you can use
Christopher Stapels on 12 Sep 2022
Edited: Christopher Stapels on 12 Sep 2022
I think the library answer seems best.
Here is an example using the dallas one wire (that has some other dependancies built in )
This article seems to indicate that you can use arduino libraries in Atmel Studio.
If you wanted to fix the code above, I would start by writing rawtemp to thingspeak and seeing if the negative values are encoded in there. Then you can fix your code to translate rawtemp appropriately.
sprintf(esp_buff, "GET /update?api_key=%s&field1=%d&field2=%d", API_WRITE_KEY, temp_data,rawtemp);
More Answers in the ThingSpeak Community