Making sensor data available in MQTT
Like our other robot functions, we will make this available via MQTT. MQTT will be used to control this sensor and to start broadcasting it’s data.
System design
Before we build more, let’s check on the system design. Look at the following figure:
The preceding figure shows our system design. It has elements from our driving system; however, some items are left out as we aren’t changing them or directly making use of them here. The Distance sensor service is designed to send it’s sensor data over MQTT while receiving sensor control instructions over MQTT. The Web server serves web pages. In the browser, the Distance plotting library uses JS components (such as Chart JS) to display our distance sensor data, received via MQTT, and it’s made use of in a Distance plotter page, and a Manual drive with distance page too.The code running in the browser may still send Motor topic...