This document will guide you through the Radio LCD Thermostat project. With this gadget you will be able to control remotly you temperature.

Block Concept

Requirements

  • Either BigClown Radio LCD Thermostat Kit, or individual components:

    • 1x BigClown LCD Module

    • 1x BigClown Core Module

    • 1x BigClown Mini Battery Module

    • 1x BigClown USB Dongle

  • One of these options:

    • BigClown Playground installed

      You can find more information in the document Playground Setup.

    • Raspberry Pi with the BigClown Raspbian distribution

      You can find more information in the document Raspberry Pi Installation.

  • BigClown Firmware Tool installed

    You can find more information in the document Toolchain Setup.

Firmware Upload

In this procedure we will use the BigClown Firmware Tool to upload firmware to the Core Module.

  1. Connect the Micro USB cable to the Core Module and your computer.

  2. Upload the firmware to the Core Module:

    bcf flash --device /dev/ttyUSB0 bigclownlabs/bcf-radio-lcd-thermostat:latest
    
  3. Remove the Micro USB cable from the Core Module and your computer.

Hardware Assembling

See short video with easy step by step demonstration:

  1. Start with the Mini Battery Module.

  2. Plug the Core Module on top of the Mini Battery Module.

  3. Plug the LCD Module on top of the Core Module.

Playground Bootstrap

  1. Open Node-RED in your web browser:

    http://localhost:1880/

  2. You should see the empty workspace with Flow 1.

  3. Insert the following snippet in the flow (using Menu >> Import) and click in Flow 1 tab:

    [{"id":"2fc604fc.3b6abc","type":"inject","z":"dfc861b.b2a02a","name":"List all gateways","topic":"gateway/all/info/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":560,"y":460,"wires":[["a2c10833.24d5d8"]]},{"id":"1e4502b8.2f63fd","type":"inject","z":"dfc861b.b2a02a","name":"Start node pairing","topic":"gateway/usb-dongle/pairing-mode/start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":570,"y":580,"wires":[["795ff5a7.8e266c"]]},{"id":"3d844ce2.932864","type":"inject","z":"dfc861b.b2a02a","name":"Stop node pairing","topic":"gateway/usb-dongle/pairing-mode/stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":560,"y":640,"wires":[["5967c452.c838bc"]]},{"id":"f202b253.2705b","type":"inject","z":"dfc861b.b2a02a","name":"List paired nodes","topic":"gateway/usb-dongle/nodes/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":560,"y":520,"wires":[["f0aca138.0b2c3"]]},{"id":"349f02fd.890f6e","type":"inject","z":"dfc861b.b2a02a","name":"Unpair all nodes","topic":"gateway/usb-dongle/nodes/purge","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":560,"y":700,"wires":[["2f1c5bb6.53d6f4"]]},{"id":"cf61d75d.4ad8f8","type":"mqtt in","z":"dfc861b.b2a02a","name":"","topic":"#","qos":"2","broker":"67b8de4a.029d3","x":530,"y":400,"wires":[["a5cb0658.f5d658"]]},{"id":"a5cb0658.f5d658","type":"debug","z":"dfc861b.b2a02a","name":"","active":true,"console":"false","complete":"false","x":790,"y":400,"wires":[]},{"id":"a2c10833.24d5d8","type":"mqtt out","z":"dfc861b.b2a02a","name":"","topic":"","qos":"","retain":"","broker":"717f7c18.ba0a24","x":770,"y":460,"wires":[]},{"id":"f0aca138.0b2c3","type":"mqtt out","z":"dfc861b.b2a02a","name":"","topic":"","qos":"","retain":"","broker":"717f7c18.ba0a24","x":770,"y":520,"wires":[]},{"id":"795ff5a7.8e266c","type":"mqtt out","z":"dfc861b.b2a02a","name":"","topic":"","qos":"","retain":"","broker":"717f7c18.ba0a24","x":770,"y":580,"wires":[]},{"id":"5967c452.c838bc","type":"mqtt out","z":"dfc861b.b2a02a","name":"","topic":"","qos":"","retain":"","broker":"717f7c18.ba0a24","x":770,"y":640,"wires":[]},{"id":"2f1c5bb6.53d6f4","type":"mqtt out","z":"dfc861b.b2a02a","name":"","topic":"","qos":"","retain":"","broker":"717f7c18.ba0a24","x":770,"y":700,"wires":[]},{"id":"67b8de4a.029d3","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"717f7c18.ba0a24","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

    It will look like this:

  4. Deploy the flow using the Deploy button in the top-right corner.

  5. Open the debug tab:

  6. Click on the List all gateways button. You should see a response like this in the debug tab:

Radio Pairing

In this section, we will create a radio link between the USB Dongle and the Radio LCD Thermostat.

Follow these steps in Node-RED:

  1. Click on the Start node pairing button.

  2. Insert the batteries into the Radio LCD Thermostat to send the pairing request (you should also see the red LED on the Core Module to be on for about 2 seconds).

  3. Click on the Stop node pairing button.

Communication Test

Follow these steps in Node-RED:

  1. Switch to debug tab on the right.

  2. Insert the following snippet in the flow (using Menu >> Import) and click in Flow 1 tab:

    [{"id":"12b3deae.bbbdf1","type":"mqtt in","z":"f2f80e07.95983","name":"","topic":"node/lcd-thermostat:0/#","qos":"2","broker":"25b87ea5.743312","x":390,"y":320,"wires":[["7694514b.9b64d"]]},{"id":"7694514b.9b64d","type":"debug","z":"f2f80e07.95983","name":"","active":true,"console":"false","complete":"false","x":630,"y":320,"wires":[]},{"id":"25b87ea5.743312","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
  3. If you see some messages in debug log (like temperature) your kit works correctly.

Integration with Blynk

Now we have assembled our kit and let's start with some basic integration with Blynk. We will start without describing what Blynk is. If you want get some information about what Blynk is. The best thing you can do is visit their page. In our example we will be showing you how monitor your temperature in time graph. As well as switch your relay which depends on pre-set temperature.

Firstly we need to configure our Node-RED app.

  1. If you are using BigClown raspi version you should be fine, but still check that Blynk nodes are installed. (You can view them on the left side menu in Node-RED). Otherwise you will need to install Node-RED package node-red-contrib-blynk-ws. You can follow this example for installing libraries to NodeRED.

  2. Add another flow (you can add them by big plus button next to the flow name).

  3. Insert the following snippet in the flow (using Menu >> Import) and click in Flow 3 tab:

    [{"id":"10207ce8.7828d3","type":"blynk-ws-out-write","z":"a037b5dc.0a06a8","name":"","pin":"1","pinmode":0,"client":"444c74b2.0e07ac","x":580,"y":320,"wires":[]},{"id":"cf5d84d7.428bc8","type":"mqtt in","z":"a037b5dc.0a06a8","name":"","topic":"node/lcd-thermostat:0/thermometer/0:1/temperature","qos":"2","broker":"b8503ac7.122c58","x":300,"y":240,"wires":[["1ab647f.3fd77b8"]]},{"id":"1ab647f.3fd77b8","type":"function","z":"a037b5dc.0a06a8","name":"Save data","func":"flow.set(\"temp\", parseFloat(msg.payload));\n\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":240,"wires":[[]]},{"id":"4813f9d6.053178","type":"inject","z":"a037b5dc.0a06a8","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":190,"y":320,"wires":[["ec216ad7.59b858"]]},{"id":"ec216ad7.59b858","type":"function","z":"a037b5dc.0a06a8","name":"Load data","func":"msg.payload = flow.get(\"temp\")||0;\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":320,"wires":[["10207ce8.7828d3"]]},{"id":"64ff6663.93a768","type":"mqtt out","z":"a037b5dc.0a06a8","name":"","topic":"node/kit-power-controller/relay/0:0/state/set","qos":"","retain":"","broker":"b8503ac7.122c58","x":870,"y":380,"wires":[]},{"id":"80286a4.d4b1f98","type":"mqtt out","z":"a037b5dc.0a06a8","name":"","topic":"node/kit-power-controller/relay/0:1/state/set","qos":"","retain":"","broker":"b8503ac7.122c58","x":870,"y":420,"wires":[]},{"id":"79351b30.f81bf4","type":"mqtt in","z":"a037b5dc.0a06a8","name":"","topic":"node/lcd-thermostat:0/thermometer/0:1/temperature","qos":"2","broker":"b8503ac7.122c58","x":300,"y":400,"wires":[["9442ee25.eee65"]]},{"id":"9442ee25.eee65","type":"function","z":"a037b5dc.0a06a8","name":"Relay switch","func":"var setTemperature = flow.get(\"temp\")||0;\n\nif(msg.payload > setTemperature) {\n    msg.payload = true;\n}\nelse {\n    msg.payload = false;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":400,"wires":[["64ff6663.93a768","80286a4.d4b1f98"]]},{"id":"444c74b2.0e07ac","type":"blynk-ws-client","z":"","name":"","path":"ws://blynk-cloud.com:8080/websockets","key":"","dbg_all":false,"dbg_read":false,"dbg_write":false,"dbg_notify":false,"dbg_mail":false,"dbg_prop":false,"dbg_low":false,"dbg_pins":""},{"id":"b8503ac7.122c58","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

    It will look like this:

  4. Configure MQTT node to connect it on you broker. It will propably connect on localhost if you are using Raspberry Pi. After that you will need to configure Blynk node. Just fill in URL ws://blynk-cloud.com:8080/websockets. The secret key we will configure later after obtaining one.

  5. Now download the Blynk app from App Store or Google Play.

  6. After installing, you should create account, login and you should see something like that:

  7. Now click a button on the top right to scan QR code.

  8. Now you should scan following QR code to get everything preconfigured.

  9. You should see something like this:

  10. Click the settings wheel and you should see settings for your project. Wee need to get auth-token which we will copy to our Node-RED in Blynk node configuration.

  11. Now deploy your Node-RED app and hit play button in your Blynk project and you should be done!

Integration workflow

Your LCD Thermostat kit will immedietaly start to send data to your NodeRED. NodeRED will be sending data to the Blynk. NodeRED will control your Power Controller Kit and whenever temperature will raise above set level. It will switch ON the relay. If it drops above set level relay sets OFF.

Chapters in this document:
Edit this page

We will inspire you!

You will get regularly our Clownsletter with real projects from other Makers. Do not miss it!

By sign up you will know how even you can inspire others and get €100 discount coupon!