WEEK 14. interface and application programming¶
Individual assignment:
Write an application that interfaces a user with input and/or output device(s) on a board that you made.
Group assignment:
Compare as many tool options as possible
To see our group assignment click here
Objective¶
For this week, I decided to design a control and data acquisition interface for our final project, the Cipi robot, using the Node Red solution.
What is Node Red¶
Node-RED is a programming tool for connecting hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to connect streams using the wide range of palette nodes that can be deployed in its runtime environment with a single click. For more details click here
Here’s an overview of the Node Red interface
Installation of Node red¶
For the installation of Node Red we chose to use our Windows 10 computer. According to the Node Red installation documentation, we must first install Nodejs on our computer. To do this, we followed the procedure below:
- Download the latest LTS version of Node.js from the official Node.js home page.Run the downloaded MSI file
- Click Next until installation is complete and you see the window below. Then click on finish
- Once installed, open a command prompt and run the following command to ensure Node.js and npm are installed correctly.
Using cmd: node --version
- We can now move on to installing node red enter the following command line:
npm install -g --unsafe-perm node-red
- Once installed, the easiest way to launch Node-RED is to use the command:
node-red
as shown below and copy and paste the url circled in red into the browser of your choice.
- After entering the above url in your browser you should get the following result.
Node Red programming¶
- To program Node red, we used several Nodes as shown below. For more information, click here.
- In order to set the different nodes, double click on them and the settings window will appear as shown below.
- once the nodes are set up we click on Deploy and we should have the following result
- We can now view our interface by entering the IP address:
127.0.0.1:1880/ui
. Here’s our interface.
Programming the MCU¶
To program our MCU, we used the MQTT protocol, with WiFi as the communication medium.
MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport, ideal for connecting remote devices with a small code footprint and minimal network bandwidth.
We will use Arduino IDE with the PubSubClient library. The PubSubClient library provides a client to perform simple publishing and subscription operations with a server that supports MQTT.
For the code, you have to modify the code with your own SSID, password and computeur IP address.
Arduino_xiao_rp2040_program_1.ino | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|