Dashboard temperature widgets stopped working

I’m using a Raspberry pi zero W with the MQTT C library and a PC Web dashboard to display information on my pool. Water temp, air temp, waterfall on/off, spa on/off, etc. It can also turn features on/off.

It was working great but I noticed after several days of running the widgets on my dashboard that display temperature are not showing any numbers, just “-”. I have 2 widgets that show hour and minute and they work fine. I rebuilt my project so it would print out the temperature information and it’s correct. I restarted my Pi and it sill does not show temperature information on the dashboard. I know that there is communication between the dashboard and my Pi because I can turn on/off my pool features from the dashboard. It’s just the none of my temperature widgets are showing data. Below is the loop of my project that sends the information. Any ideas?

// Main loop where MQTT code is run.
void loop(void)
{
	static int count = 0;
	
	while (1) {
		// Yield to allow MQTT message processing.
 		pool_Update();
                // I need to call pool_Update faster than once a second so I'll 
                // wait a tenth of the regular time and only publish every 10 times.
		CayenneMQTTYield(&mqttClient, 100);

		count++;
		if (count > 10)
		{
			count = 0;
			
			// Publish some example data every second. This should be changed to send your actual data to Cayenne.
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 0, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_PoolTemperature);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 1, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_PoolSetTemperature);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 2, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_AirTemperature);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 3, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_SpaSetTemperature);
			
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 4, NULL, NULL, g_Hour);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 5, NULL, NULL, g_Minute);

			myPublish(SPA_CIRCUIT, SPA_CHANNEL);
			myPublish(JETS_CIRCUIT, JETS_CHANNEL);
			myPublish(POOL_LIGHT_CIRCUIT, POOL_LIGHT_CHANNEL);
			myPublish(SPA_LIGHT_CIRCUIT, SPA_LIGHT_CHANNEL);
			myPublish(DECK_LIGHT_CIRCUIT, DECK_LIGHT_CHANNEL);
			myPublish(WATERFALL_CIRCUIT, WATERFALL_CHANNEL);
			
			if (g_Heater)
			{
				CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, HEATER_CHANNEL, NULL, NULL, "1");
			}
			else
			{
				CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, HEATER_CHANNEL, NULL, NULL, "0");
			}
		}		
	}
}

Thanks for any help,
Mike

Is this something that always works after a reboot and then after a couple days shows ‘-’, or it was working and now doesn’t work at all?

This was working and now doesn’t work all. Even after a rebooted my Pi, the dashboard temperature widgets are just showing “-”. I know my app is still running because the widgets that display the g_Hour and g_Minute are correct.

Thanks,
Mike

Sorry, also should have asked what sensor you are using. Is it a 1-wire like ds18b20?

The data is coming in from the UART and I’m decoding it in the application. I’ve added printf statements to make sure the data is valid and it is. Regardless, the display is not displaying the wrong number, it’s not displaying any number. See below.

Thanks for you time,
Mike

I just want to clarify. The temperature data is not showing. You can see that the Hours and Minutes are correct.

Thanks,
Mike

I posted a separate topic on this…but just to chime in I am seeing the same thing on 2 different PI’s that I am using and 2 different sensors. I use the SI7021 Temp/Humidity sensor on one PI and the BME280 Temp/Humidity/Pressure on another PI and the exact same thing is happening to me, the Temp data is not showing, all of the other data humidity and pressure display just fine. So I too would like to find a fix for this and this issue just occurred within the last week or so.

Can you please post your code?

Sure. Just FYI. The temperature widgets started working again on my iOS app on my iPhone 6. But when I log into MyDevices on my PC (Windows 10) they are not showing up.

Code Begin:

Network network;
CayenneMQTTClient mqttClient;

#define SPA_CHANNEL			20
#define WATERFALL_CHANNEL	21
#define JETS_CHANNEL		22
#define POOL_LIGHT_CHANNEL	23
#define SPA_LIGHT_CHANNEL	24
#define DECK_LIGHT_CHANNEL	25
#define HEATER_CHANNEL		26
#define SPA_SET_CHANNEL		30

void outputMessage(CayenneMessageData* message)
{
	int i;
	
	switch (message->topic)	{
	case COMMAND_TOPIC:
		printf("topic=Command");
		break;
	case CONFIG_TOPIC:
		printf("topic=Config");
		break;
	default:
		printf("topic=%d", message->topic);
		break;
	}
	printf(" channel=%d", message->channel);
	if (message->clientID) {
		printf(" clientID=%s", message->clientID);
	}
	if (message->type) {
		printf(" type=%s", message->type);
	}
	for (i = 0; i < message->valueCount; ++i) {
		if (message->values[i].value) {
			printf(" value=%s", message->values[i].value);
		}
		if (message->values[i].unit) {
			printf(" unit=%s", message->values[i].unit);
		}
	}
	if (message->id) {
		printf(" id=%s", message->id);
	}
	printf("\n");
}

// Handle messages received from the Cayenne server.
void messageArrived(CayenneMessageData* message)
{
	BOOL status;
	UCHAR circuit;
	long	  spaTemp;
	
	outputMessage(message);
	
	// Add code to process the message here.
	if (message->topic == COMMAND_TOPIC) 
	{
		if (message->channel == SPA_SET_CHANNEL)
		{
			spaTemp = strtol(message->values[0].value, NULL, 10);
			printf("\nNew Spa Temp = %d\n", (int)spaTemp);
			spaTemp = pool_ChangeSpaTemp(spaTemp);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, SPA_SET_CHANNEL, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, spaTemp);
			return;
		}
			
		if (message->values[0].value[0] == '1')
		{
			status = TRUE;
		}
		else
		{
			status = FALSE;
		}
		
		switch(message->channel)
		{
			case WATERFALL_CHANNEL:
				circuit = WATERFALL_CIRCUIT;
				break;
			case SPA_CHANNEL:
				circuit = SPA_CIRCUIT;
				break;
			case JETS_CHANNEL:
				circuit = JETS_CIRCUIT;
				break;
			case POOL_LIGHT_CHANNEL:
				circuit = POOL_LIGHT_CIRCUIT;
				break;
			case SPA_LIGHT_CHANNEL:
				circuit = SPA_LIGHT_CIRCUIT;
				break;
			case DECK_LIGHT_CHANNEL:
				circuit = DECK_LIGHT_CIRCUIT;
				break;
			case HEATER_CHANNEL:
				// If this is a command message we publish a response to show we recieved it. Here we are just sending a default 'OK' response.
				// An error response should be sent if there are issues processing the message.
				CayenneMQTTPublishResponse(&mqttClient, message->clientID, message->id, NULL);

				if (g_Heater) 
				{
					// Send the updated state for the channel so it is reflected in the Cayenne dashboard. If a command is successfully processed
					// the updated state will usually just be the value received in the command message.
					CayenneMQTTPublishData(&mqttClient, message->clientID, DATA_TOPIC, message->channel, NULL, NULL, "1");
				}
				else
				{
					// Send the updated state for the channel so it is reflected in the Cayenne dashboard. If a command is successfully processed
					// the updated state will usually just be the value received in the command message.
					CayenneMQTTPublishData(&mqttClient, message->clientID, DATA_TOPIC, message->channel, NULL, NULL, "0");
				}
				return;
				break;
		}
		
		pool_SetCircuit(circuit, status);
		
		// If this is a command message we publish a response to show we recieved it. Here we are just sending a default 'OK' response.
		// An error response should be sent if there are issues processing the message.
		CayenneMQTTPublishResponse(&mqttClient, message->clientID, message->id, NULL);

		// Send the updated state for the channel so it is reflected in the Cayenne dashboard. If a command is successfully processed
		// the updated state will usually just be the value received in the command message.
		CayenneMQTTPublishData(&mqttClient, message->clientID, DATA_TOPIC, message->channel, NULL, NULL, message->values[0].value);
	}
}


// Connect to the Cayenne server.
int connectClient(void)
{
	// Connect to the server.
	int error = 0;
	printf("Connecting to %s:%d\n", CAYENNE_DOMAIN, CAYENNE_PORT);
	if ((error = NetworkConnect(&network, CAYENNE_DOMAIN, CAYENNE_PORT)) != 0) {
		return error;
	}

	if ((error = CayenneMQTTConnect(&mqttClient)) != MQTT_SUCCESS) {
		NetworkDisconnect(&network);
		return error;
	}
	printf("Connected\n");

	// Send device info. Here we just send some example values for the system info. These should be changed to use actual system data, or removed if not needed.
	CayenneMQTTPublishData(&mqttClient, NULL, SYS_VERSION_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, CAYENNE_VERSION);
	CayenneMQTTPublishData(&mqttClient, NULL, SYS_MODEL_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, "Linux");

	CayenneMQTTSubscribe(&mqttClient, NULL, COMMAND_TOPIC, CAYENNE_ALL_CHANNELS, NULL);
	CayenneMQTTSubscribe(&mqttClient, NULL, CONFIG_TOPIC, CAYENNE_ALL_CHANNELS, NULL);
	CayenneMQTTSubscribe(&mqttClient, NULL, DATA_TOPIC, CAYENNE_ALL_CHANNELS, NULL);
	CayenneMQTTSubscribe(&mqttClient, NULL, ANALOG_TOPIC, CAYENNE_ALL_CHANNELS, NULL);
	CayenneMQTTSubscribe(&mqttClient, NULL, ANALOG_COMMAND_TOPIC, CAYENNE_ALL_CHANNELS, NULL);
	
	
	return CAYENNE_SUCCESS;
}

void myPublish(int Circuit, int Channel)
{
	if (pool_GetCircuit(Circuit))
	{
		CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, Channel, NULL, NULL, "1");
	}
	else
	{
		CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, Channel, NULL, NULL, "0");
	}
}
	
// Main loop where MQTT code is run.
void loop(void)
{
	static int count = 0;
	
	while (1) {
		// Yield to allow MQTT message processing.
 		pool_Update();
		CayenneMQTTYield(&mqttClient, 100);

		count++;
		if (count > 10)
		{
			count = 0;
			
			// Publish some example data every second. This should be changed to send your actual data to Cayenne.
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 0, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_PoolTemperature);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 1, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_PoolSetTemperature);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 2, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_AirTemperature);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 3, TYPE_TEMPERATURE, UNIT_FAHRENHEIT, g_SpaSetTemperature);
			
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 4, NULL, NULL, g_Hour);
			CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 5, NULL, NULL, g_Minute);

			myPublish(SPA_CIRCUIT, SPA_CHANNEL);
			myPublish(JETS_CIRCUIT, JETS_CHANNEL);
			myPublish(POOL_LIGHT_CIRCUIT, POOL_LIGHT_CHANNEL);
			myPublish(SPA_LIGHT_CIRCUIT, SPA_LIGHT_CHANNEL);
			myPublish(DECK_LIGHT_CIRCUIT, DECK_LIGHT_CHANNEL);
			myPublish(WATERFALL_CIRCUIT, WATERFALL_CHANNEL);
			
			if (g_Heater)
			{
				CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, HEATER_CHANNEL, NULL, NULL, "1");
			}
			else
			{
				CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, HEATER_CHANNEL, NULL, NULL, "0");
			}
		}		
	}
}

// Main function.
int main(int argc, char** argv)
{
	pool_Init();
	
	// Initialize the network.
	NetworkInit(&network);

	// Initialize the Cayenne client.
	CayenneMQTTClientInit(&mqttClient, &network, username, password, clientID, messageArrived);

	// Connect to Cayenne.
	if (connectClient() == CAYENNE_SUCCESS) {
		// Run main loop.
		loop();
	}
	else {
		printf("Connection failed, exiting\n");
	}

	return 0;
}

Are your temps always int? you could try CayenneMQTTPublishDataFloat vs CayenneMQTTPublishDataInt.

You can try something like the code below to see if you are getting an error:

if ((error = CayenneMQTTPublishDataInt(&mqttClient, NULL, DATA_TOPIC, 1, TYPE_LUMINOSITY, UNIT_LUX, 1000)) != CAYENNE_SUCCESS) {
    printf("Publish luminosity failed, error: %d\n", error);
}

Hi Guys,
I am new to this and have recently set up my pi I have noticed the same issue, the CPU temp shows a temp reading on the mobile app but not on the desktop version it only shows “-”. I am in the process of setting up another temp sensor any assistance would be greatly appreciated.
Thanks Regards
Carl

Raspberry Pi is slightly different than Arduino. Was your Raspberry Pi offline when this happened?

~benny

I will try changing the format to float and see if that fixes it. I’ll let you know.

Hi Bestes. No, my Raspberry Pi was on-line when this happened.

Thanks,
Mike

Hi Benny,

thanks for the reply no my pi is online but does not show temp on desktop version only on the app it shows even when using both at the same time.

Oh, were you using the Pi internet browser?

~Benny