Temperature decimals from emonglcd to emoncms

Hi all,

I've just assembled and install my 1st kit and everything worked great. I then start to make some modifications to the code (my programming skills are very basic) and there's an issue I'm unable to overcome.

I wanted temperature from GLCD to be sent to emoncms, so I added temperature to the payloadtx and switch the order with payloadglcd in order to have "temperature" variable defined

___________________

typedef struct { int temperature; } PayloadGLCD;
PayloadGLCD emonglcd;

typedef struct { int power1, power2, power3, Vrms, temperature; } PayloadTX;     
PayloadTX emontx;

___________________

 

As it was a 4 digit "number", and I want the temperature to be XX.Y I removed the *100 on this line:

______________

emonglcd.temperature = (int) (temp);

______________

It worked but probably I'm missing something because all I can get on emoncms (feeds) are the first 2 digits (no decimals)

I have the same issue with the milivolts from the emontx_low_temperature module. Can anyonte explain how can I have decimal readings on the XX.Y (or XX.YY) format either from temperature and battery voltage on emontx? 

Sorry if it's kind of a dumb question, but I search for this and couldn't find an anwser.

Thanks,

Tiago

Robert Wall's picture

Re: Temperature decimals from emonglcd to emoncms

emoncms has been designed to receive and accept signed integer values. Therefore for something like a temperature that has a restricted range - at the most -20 to +60 say, it makes sense to multiply by 100 first. Then it becomes possible to have a temperature like 26.78º which is transmitted in the form 2678. Inside emoncms, before you display it, you divide by 100 to get back to 26.78º. If you don't multiply by 10 or 100 first, you can send a temperature of 26 or 27, but you can get no closer.

digitalmisery's picture

Re: Temperature decimals from emonglcd to emoncms

I am sending a 4-digit value to emonCMS from a pressure sensor (reading in inHg) and used the input processing to multiply the value by 0.01 to get the decimal back. For example, it is sent like 2999 and I want to see it as 29.99. The input processing does scale it properly except it will only show one significant digit when I view it in a feed (29.9 versus 29.99). My battery voltage reading has two digits of precision and I'm trying to figure out how to get that with this reading since that is how it is usually displayed. Any help would be greatly appreciated.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.