Hi,
as an example build a B4R & B4J solution to display DHT11 sensor data (Temperature & Humidity) in a google line chart created and refreshed by a B4J webserver.
Update 2016.05.24
There are two solutions developed with the same result:
B4J MQTT Client & Server with Websocket
See attached - which also includes a B4J datagenerator (used to test the server), a B4J MQTT non-UI client and an older B4J server handler version.
Again cool to see the B4X integration.
as an example build a B4R & B4J solution to display DHT11 sensor data (Temperature & Humidity) in a google line chart created and refreshed by a B4J webserver.
Update 2016.05.24
There are two solutions developed with the same result:
- Post #1 uses MQTT to communicate between the Arduino and the Server.
- Post #5 uses Websockets for both Arduino and Server. This solution is simpler as using MQTT.
- DHT11 sensor connected to an Arduino. The Arduino has an Ethernet shield.
- Arduino to publish in regual interval (by a timer) the DHT11 sensor data via MQTT.
- Arduino to subscribe to the "interval" topic, which is published by the B4J server. If "interval" topic received, the timer interval is changed.
B4J MQTT Client & Server with Websocket
- Two servers are defined, one for the MQTT Broker (port 51043) and the other for the B4J webserver (port 51042).
- MQTT client receives the Arduino published payload and stores the values in a data file located in the dirapp folder (with a limited number of data entries).
- When a client connects via webbrowser to the B4J server, a timer is started to regular refresh the line chart.
- The webinterface has in addition to the line chart, a button to show an About modal dialog and a button to set the interval via a modal inputdialog - the interval is taken by the B4R program and changed accordingly.
- The footer of the webinterface shows the last update and the refresh interval.
- W3.CSS is used for the webinterface.
See attached - which also includes a B4J datagenerator (used to test the server), a B4J MQTT non-UI client and an older B4J server handler version.
Again cool to see the B4X integration.
Attachments
Last edited: