In this document, you will learn how to send the temperature from an external sensor into the CAN network.
In order to achieve the aforementioned, you will need a temperature sensor that can share its API, which will let you read the temperature, and an Ampio installation with access to Node-RED.
Let’s start by going to Node-RED. A full guide on Node-RED alone can be found here.
Add a reading from your sensor and a mqtt out node and connect them. Open the mqtt node and select an existing configuration, or create a new one. Click Deploy and check whether the connection has been made successfully. In this example, due to the lack of an external sensor, a fixed reading of 27°C was simulated.
The next step is to open the MQTT node and enter:
ampio/to/broadcast/<MAC>/t in the topic: field.
Such information will be sent to the CAN network only if the MAC address is within the range of 0-fff, written in a hexadecimal format.
Select any MAC address from that range that is not used in your installation. In our case it will be 30.
Save and click Deploy. You can now close Node-RED and open the Smart Home configurator. In the configurator, open the Network monitor and go to the Monitor tab.
As you can see, a new device has appeared in the CAN network with the following MAC address:
110010<MAC provided earlier in Node-RED>, which in our case is: 11001030
Remember the MAC address, close the Network Monitor and then, from the top menu, go to Project -> Add a new device manually. Then, fill in the fields according to the MAC address that was displayed in the monitor.
After saving the changes, the device will show on the list in the configurator. Now, when you open the device monitor and go to the tab with sensors, you will see a reading from your external sensor.
From this moment on, you will be able to use the temperature reading in any way in any physical devices, for example, for displaying the temperature on a screen, or entering the temperature as a sensor in a heating zone.
It must be borne in mind that after closing the configurator, the virtual device will disappear from the list, but if the information is being sent to the CAN network. If, however, you would like to make any modifications to the device, you should have the project with the virtual device saved, or you will have to create a virtual device from scratch.