Simulation of a photovoltaic system (based on MQTT) and an electric car (based on HTTP) to demonstrate a smart charging scenario based on the W3C Web of Things approach.
Sun-Inverter | eCar | |
---|---|---|
Protocol | MQTT | HTTP |
Content-type | text-plain | application-json |
Data model / functions | status ("powerOn”, "powerOff”, "error”) Topic (publish): {..}/status |
status ("readyToCharge”, "charging”, "stopCharging”) Resource (GET): {..}/state |
power (0..7500 Watt) Topic (publish): {..}/power |
soc (0..100%) Resource (GET): {..}/soc |
|
startCharging Resource (POST): {..}/startCharging |
||
stopCharging Resource (POST): {..}/stopCharging |
- NodeJS version 10+
- MQTT broker (e.g., Eclipse Mosquitto)
Install dependencies (Eclipse node-wot)
npm install @node-wot/core@0.7.7
npm install @node-wot/binding-http@0.7.7
npm install @node-wot/binding-mqtt@0.7.7
npm install @node-wot/binding-file@0.7.7
- start PV simulation in terminal I:
node pv-system.js <MQTT_Broker_Address:Port>
(e.g.,node pv-system.js 127.0.0.1:1883
) - start eCar simulation in terminal II:
node ecar.js
- start smart charging application in terminal III:
node smart-charging.js
Note: The PV and eCar simulations automatically expose their Thing Descriptions. This simple application stops when the eCar is fully charged.