How to add a pseudo sensor to Pi Agent 2.0?

Hi,

Could you kindly share with me how to add a pseudo sensor to Pi Agent 2.0 and show its data on the Raspberry Pi project web page? let’s say another temperature or humidity sensor. I am a beginner for Pi Agent even Python. I just want a clear understanding about Pi Agent structure and operations, and I think a pseudo sensor means more focus on the software, in case I don’t have sensor hardware on my hand.

I try to learn from the README on the github, but there are too abstract for me. Hope anyone can give me a more detail example.

Thanks!

you can try with Python MQTT library to send the data value to cayenne Cayenne-MQTT-Python/Example-01-SendData.py at master · myDevicesIoT/Cayenne-MQTT-Python · GitHub

Hi,

Thanks for your reply!
I am trying the Raspberry Pi Agent 2.0 now, and I have very limited knowledge about python, sorry about this.

I am trying to add a pseudo sensor, that I want to see it on the Cayenne web page together with other Raspberry Pi value, like RAM, CPU and so on.
I read the README on the github, but I don’t know how to run the test script.
Could do show me how to add a pseudo sensor to Raspberry Pi Agent 2.0?

which pseudo sensor are you using?

Hi,

I want to add another temperature sensor to Raspberry Pi Agent 2.0. The temperature sensor is not a real one,
it just a pseudo sensor, means I put a temperature value, like 23 Celsius degree, and want to see it on the Cayenne web page.

It is helpful for better understanding Raspberry Pi Agent 2.0, I can add a real temperature sensor and its driver later.

:slight_smile:

@overheat1984 To add a pseudo sensor you’d need to modify one of the temperature classes in the agent. For instance, if you wanted to override the BMP180_TEMPERATURE class in Cayenne-Agent/bmp085.py at master · myDevicesIoT/Cayenne-Agent · GitHub you could replace it with some code like this:

class BMP180_TEMPERATURE(BMP180):
    def __init__(self, altitude=0, external=None):
        self.temperature = True
        self.pressure = False
        
    def __str__(self):
        return "BMP180_TEMPERATURE"

    def __getCelsius__(self):
        return 23.0

Then you can add a BMP180 Temperature sensor via the dashboard and you should get a new temperature widget that will display the pseudo sensor data.

2 Likes

Cool!!
It works.

Looks it is a from top to bottom way.
I want to add a temperature sensor HTS221, which is come from ST. It is I2C interface and similar to BMP180. but I can not find it in the dashboard.
What should I do?
Many thanks!

Hi @overheat1984 !
Feel free to submit a PR for the Cayenne-Agent with the HTS221 driver so we can then add it to the UI as well.