Reputation: 7613
I saw that Thingsboard can send RPC requests (https://thingsboard.io/docs/user-guide/rule-engine-2-0/action-nodes/#rpc-call-request-node). This example shows to send values to GPIO.
I was wondering if I can send values to the I2C physical devices connected to Raspberry Pi's.
And if I am using i2c-stub in order to create virtual I2C devices, how can I connect them to Thingsboard? So far I am using i2cset and i2cset on RPi's to read and write virtual sensors.
Thanks, Felipe
Upvotes: 0
Views: 183
Reputation: 151
You can use this guide: https://thingsboard.io/docs/samples/raspberry/gpio/
Core points:
def on_message(client, userdata, msg):
...
if data['method'] == 'getGpioStatus':
client.publish(msg.topic.replace('request', 'response'), get_gpio_status(), 1)
elif data['method'] == 'setGpioStatus':
set_gpio_status(data['params']['pin'], data['params']['enabled'])
client.publish(msg.topic.replace('request', 'response'), get_gpio_status(), 1)
client.publish('v1/devices/me/attributes', get_gpio_status(), 1)
You can define your own functions and RPC method names for I2C (instead of using get_gpio_status and set_gpio_status)
Upvotes: 1