Slider PWM output to transfer temperature setpoint

project description: I’m using a RPi as a smart thermostat using machine learning techniques. This is a python script running on my device, which is working fine. I currently use Cayenne to visualize my control scheme & temperature, but also want to use it to communicate a setpoint to my script to overrule the setpoint of the ML agent, eg when I’m coming home later.

hardware: RPi 3B (wifi), kernel 4.4 (downgraded from 4.9 as adviced), temperature sensor+relais, android cayenne app

my question: I want to make a slider that communicates a setpoint value (eg 20°C) to the RPi, which the script can use as input in the control scheme.

what I had in mind but didnt work: a cayenne slider on the PWM output 18 of the RPi, then read in my script the voltage on this pin.
Simply controlling the relais from the Cayenne app is working fine, but is not what I want to do.
Should I have a physical PWM driver to do this? Is there an alternative to communicate a setpoint value from the cayenne app to the RPi?

Since it sounds like you have a bit of experience with Python, I’d recommend you switch over to the MQTT API. This would probably makw what you are trying to do a lot easier. With MQTT you can send a “analog” value which you can then read on the Pi as a variable and make your overrides that way. Here are the docs for the API.

thanks @adam, good suggestion&documentation: it works fine (I used the cayenne.client)
Only I have one issue: in the web application the MQTT slider is working perfect with my code, but on android (v6.0.1) the slider returns an error: “can not connect to remote device” and is not transferring the value. A bug or did I forget something?

@rsiegel would know more than I do. I know there are issues with sliders but the app shouldn’t be showing cannot connect. I would suggest doing a clear data for the app and try again.

@ruben_b This one is a known bug with the Android app and MQTT sliders, so not anything wrong on your side. Apologies for the inconvenience. We have a new developer who will be dedicated to squashing some of these longer standing Cayenne bugs, so hopefully this one one will not be around much longer.

Thanks for your answer @rsiegel . Any update on this bug? I implemented my thermostat and this feature is quite important in my project.

No update thus far that I can provide, apologies. Our Android developer has been busy with another project during this time, I’m sure as soon as we have a new Android build this will be a top priority item to fix in it. Any updates for Cayenne (both on Android as well as iOS or the Web platform) will always be listed in our Cayenne Release Notes category on this forum, so you can check for it there.

Thanks for the update, although it is not fixed yet. My workaround is just 2 state buttons with a low& high fixed setpoint.

Just bumping this old thread as the Android slider known issues mentions in this thread are now resolved in the most recent updates to the app.

1 Like