Introduction: IoT Split-flap Weather Forecast Powered by XOD
Hi everyone!
In this instructable, I tell you how to make split-flap display and show the current weather conditions on it. Also how to fetch the weather information from the Web using Wi-Fi and API.
I am a fan of the XOD visual programming environment. With the 0.22.0 version, XOD entered the Internet of things. So I have an excellent opportunity to create a device in the style of IOT and program it using XOD.
The idea is to display data about the current weather and temperature in my city. To display the information I decided to make a retro split-flap display in the spirit of the old railway station display boards.
The display can show up to four characters.
This instruction can be divided into several stages:
- Preparation.
- Creation the mechanics for the display.
- Electronics configuration.
- Interaction with the weather API app.
- Programming the device.
Step 1: Preparation. Tools.
You need several things to make this project:
- A home computer with a printer and XOD IDE installed.
- Scissors.
- Clippers.
- Set of a crewdrivers.
- Drill and drill bits.
- Dremel to cut the metal shafts.
- M3 Thread tap.
- Soldering tools.
Step 2: Preparation. Lasser Cutting.
I chose plexiglass as a material for the body parts and laser cutting to manufacture. Here is the minimal list of parts for the 4-digit display that you need to order or make them by yourself:
- Disk 3mm thickness - 8 pieces.
- Panel 3mm thickness- 8 pieces.
- Large gear 3mm thickness - 4 pieces.
- Medium gear 3mm thickness - 8 pieces.
- Small gear 3mm thickness - 4 pieces.
- Gear sleeve 3mm thickness - 8 pieces.
- Sleeve 3mm thickness - 8 pieces.
- Sleeve 2mm thickness - 8 pieces.
- Limiter 3mm thickness - 4 pieces.
- Flip 1mm thickness - 144 pieces.
- Front electronics panel 3mm thickness - 1 piece.
Back electronics panel 3mm thickness - 1 piece.
The DXF CAD files are attached.
Step 3: Preparation. Shopping List.
The minimum list of things that you need to obtain. Remember, this is not a mandatory list and components can be replaced.
Electronics:
- Unipolar stepper motor Nema 17 1.8deg 12V 42x42x48mm - 4 pieces. Link
- Digital line track follower sensor - 4 pieces. Link
- Arduino mega 2560 - 1 piece. Link
- Arduino Stepper driver module - 4 pieces. Link
- Arduino ESP 8266 AT-modem module - 1 piece. Link
- Button - 2 pieces. Link
- Arduino prototype shield - 3 pieces. Link
- Prototyping wires - 1 pack. Link
- USB (A — B) wire - 1 piece. Link
- 12V, 3A AC-DC power supply - 1 piece. Link
Metalware:
- Steel corner braces about 30x30mm - 3 pieces. Link
- Steel or brass rod/shaft 5mm diameter, about a meter length.
PCB supports and spacers:
- PCB Brass or Steel hex standoff M3 Male - Female 25mm length - 16 pieces. Link
- PCB Brass or Steel hex standoff M3 Female - Female 25mm length - 16 pieces. Link
- PCB Brass or Steel hex standoff M3 Male - Female 40mm length - 16 pieces. Link
- PCB Brass or Steel hex standoff M3 Male - Female 32mm length - 12 pieces. Link
- PCB Brass or Steel hex standoff M3 Male - Female 10mm length - 12 pieces. Link
- PCB Nylon hex standoff M3 Male-Female 8mm length - 16-20 pieces. Link
Hardware:
- Hex nut M3 (DIN 934).
- Spring washer M3 (DIN 127).
- Washer M3 (DIN 125).
- Screw M3 (DIN7985 / DIN 84 / DIN 912) 16mm length.
- Screw M3 (DIN7985 / DIN 84 / DIN 912) 10mm length.
- Screw M3 (DIN7985 / DIN 84 / DIN 912) 6-8mm length.
Other:
Step 4: Mechanics. Making Flaps.
Characters
In this project, the digit capacity of the display is 4. The display has a modular structure and can be easily expanded. You can increase or decrease the number of digits at your will.
Every digit has 36 flaps:
- 26 flaps are used for the Latin alphabet letters (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z).
- 9 flaps are used for numbers (1 2 3 4 5 6 7 8 9).
- 1 empty flap for spacing (for displaying zero I used the 'O' letter).
A flap has a top part of the current character on its front side and a bottom part of next character on its backside.
The font that I used for letters is "Steelfish rg". You can find it here
The material list
- 144 flaps.
I made flips from the 1 mm transparent plexiglass list covered with a black film on both sides. You can make them from any material that you have.
Do not forget to increase the diameter of the mounting holes in the discs of the flip carrier If you are going to use a list thicker than 1mm. For the manufacturer of flips, I used laser cutting.
144 (36 x 4) is a minimum quantity, but I strongly recommend you to make more. In my case, the ears which flap mounts to the discs of the flap-holder turned out quite weak, and I broke more than a dozen of flips.
- Self-adhesive paper.
I used multi-functional white self-adhesive paper from Lomond. A package of 50 sheets is enough. I'm sure it is quite easy to find a replacement.
Process
- Print the letters using the self-adhesive paper. The pdf file with letters at the scale of 1:1 is attached below.
Cut out the outline of the top part of the letter with scissors. For example the top part of the "A".
- Glue the top part of the "A" letter to the front side of the flip in the necessary place.
- Cut out the outline of the bottom part of the next letter. For example the bottom part of the "B".
- Turn the flip over and glue the bottom part of the letter "B".
- The "A - B" flip is ready. Repeat these steps for each character.
I can say without a doubt that it's a very laborious process.
If you have the opportunity to print characters on the flips on both sides, be sure to use it.
Attachments
Step 5: Mechanics. Assembling the Flip-holder.
The material list
To assemble one flip-holder, you need this positions:
1. Plexiglass disk 3mm - 2 pieces.
2. Plexiglass gear sleeve 3mm - 2 pieces.
3. Large plexiglass gear 3mm - 1 piece.
4. PCB hex standoff M3 Male-Female 25mm length - 4 pieces.
5. PCB hex standoff M3 Female-Female 25mm length - 4 pieces.
6. Washer M3 (DIN 125) - 12 pieces.
7. Screw M3 (DIN7985 / DIN 84 / DIN 912) 10mm length- 4 pieces.
8. Screw M3 (DIN7985 / DIN 84 / DIN 912) 16mm length- 4 pieces.
9. 36 flips from the previous step.
Assembling process
Look at the sketch (pic.1 and pic.2). The images will help you with the assembly.
- Screw the standoffs (pos.4) and standoffs (pos.5).
- Fasten the standoffs, left disk (pos.1), sleeves (pos.2), gear (pos.3) using the washes (pos.6) and 16mm screws (pos.8) as it is shown on the sketch.
- Screw the right disk (pos.1) with the standoffs using the washes (pos.6) and 10mm screws (pos.7) but do not tighten.
- Clip all flips (pos.9) between disks (pos.1) using their ears.
- Tighten the screws (pos.7).
- Make sure all the flips rotate in the holes freely without stucking.
- Stick a strip of self-adhesive paper on the flip-holder. The place with a strip sets the default position of the flip-holder (pic.7).
Step 6: Mechanics. Assembling the Left Panel.
The material list
To assemble one left panel, you need this positions:
1. Plexiglass panel 3mm - 1 piece.
2. Small plexiglass gear 3mm - 1 piece.
3. Unipolar stepper motor Nema 17 1.8deg 12V 42x42x48mm - 1 piece.
4. Digital line track follower sensor - 1 piece.
5. Aluminum Mounting Hub for 5mm Shaft with four M3 holes - 1 piece.
6. PCB nylon hex standoff M3 Male-Female 8mm length - 2 pieces.
7. Hexagon socket set screw with a flat point (ISO 4026 / EU 24026 / DIN 913) - 1 piece.
8. Screw M3 (DIN7985 / DIN 84 / DIN 912) 6-8mm length- 4 pieces.
9. Screw M3 (DIN7985 / DIN 84 / DIN 912) 10mm length- 3 pieces.
10. Spring washer M3 (DIN 127) - 2 pieces.
11. Washer M3 (DIN 125) - 3 pieces.
12. Hex nut M3 (DIN 934) - 2 pieces.
Preparation
- Remove the 4 long screws from the stepper motor (pos.3) and remove the back cover
- Make two M3 size taps on the back cover (pic.2). The approximate distance between the holes should be 30.5mm.
- Assemble the stepper motor (pos.3) back.
- If it is necessary, correct the line track follower sensor so that it can fit the panel (pos.1). I had to unsolder the pins on the sensor PCB so they wouldn't interfere. Also, I soldered the wire directly to the PCB (pic.3 and pic.4) Possibly you don't need to fix the sensor you got.
- Shorten the nylon standoffs (pos.6) so that they do not damage the motor coil (pic.5).
Assembling process
Look at the sketch (pic.1). The images will help you with the assembly.
- Fasten the line sensor (pos.4) to the panel (pos.1) using nuts (pos.12), screw (pos.9), washer (pos.11).
- Screw the nylon standoffs (pos.6) to the stepper (pos.3).
- Fasten the stepper (pos.3) with the panel (pos.1) using screws (pos.9) and washes (pos.10 and pos.11).
- Screw the small plexiglass gear (pos.2) to the mounting hub (pos.5) using screws (pos.8).
- Fix the mounting hub (pos.5) with the stepper shaft using the hex socket screw (pos.7).
- Make a few rotations of the stepper's shaft to ensure that the standoffs (pos.6) do not interfere with the stepper coil.
Step 7: Mechanics. Assembling the Right Panel.
Preparation
Cut some shafts with about 20mm length from the 5mm diameter rod.
The material list
To assemble one right panel, you need this positions:
1. Plexiglass panel 3mm - 1 piece.
2. Medium plexiglass gear 3mm - 2 pieces.
3. Aluminum Mounting Hub for 5mm Shaft with four M3 holes - 4 pieces.
4. Shaft 5mm diameter and approximate 20mm length - 2 pieces.
5. Hexagon socket set screw with a flat point (ISO 4026 / EU 24026 / DIN 913) - 4 pieces.
6. Screw M3 (DIN7985 / DIN 84 / DIN 912) 6-8mm length- 8 pieces.
Assembling process
Look at the sketch (pic.1). The images will help you with the assembly.
- Screw two medium plexiglass gears (pos.2) to the mounting hubs (pos.3) using screws (pos.6).
- Fix the mounting hubs (pos.5) with the shafts (pos.4) using the hex socket screws (pos.5).
- Insert the shafts (pos.4) into the panel (pos.1) and join the gears (pos.2).
- Fix the shafts (pos.4) on the other side of the panel (pos.1) using the mounting hubs (pos.5) and hex socket screws (pos.5).
Make sure that the gears rotate freely without stucking.
Step 8: Mechanics. Assembling the Digit.
Preparation
Cut a 360mm shaft from the 5mm diameter rod.
The material list
To assemble one digit, you need this positions:
1. Assembled flip holder - 1 piece.
2. Assembled left panel - 1 piece.
3. Assembled right panel - 1 piece.
4. Plexiglass flip limiter 3mm - 1 piece.
5. Plexiglass sleeve 3mm - 2 pieces.
6. Plexiglass sleeve 2mm - 2 pieces.
7. PCB hex standoff M3 Male-Female 40mm length - 3 pieces.
8. PCB hex standoff M3 Male-Female 32mm length - 3 pieces.
9. PCB hex standoff M3 Male-Female 10mm length or M3 nuts and M3 10mm screws (depending on the position of the digit: first, last, or middle) - 3 pieces.
10. Hex nut M3 (DIN 934) - 2 pieces.
11. Steel / Brass shaft. Length depends on the digit count. In this project length is 360mm - 1 piece.
Assembling process
Look at the sketch (pic.1). The images will help you with the assembly.
- Screw two standoffs (pos.7) to standoffs (pos.8) and hex nuts (pos.10).
- Fix the plexiglass flip limiter (pos.4) between one standoff (pos.7) and standoff (pos.8).
- Fasten the assembled stands with the right panel (pos.3) using the standoffs (pos.9) or M3 10mm screws.
- Mount the flip-holder(pos.1) on the shaft (pos.11).
- Mount two 3mm sleeves (pos.5) on the shaft (pos.11) to the left of the flip-holder.
- Mount two 2mm sleeves (pos.6) on the shaft (pos.11) to the right of the flip-holder.
- Insert the shaft to the right and left panel (pos.2 and pos.3).
- Clip the flip-holder (pos.1) with the panels (pos.2 and pos.3) using the standoffs (pos.9) or M3 10mm screws.
- Rotate the shaft of the stepper motor by hand to ensure that all of the gears rotate freely without stucking. If it is necessary, lubricate the transmission. Any lubricant for plastic or vaseline is ok.
- Сarefully adjust the limiter (pos.4) so that the current top flip doesn't fall standing upright. Do not press the flip with the limiter strongly. A significant force will break the ears on the flip.
Step 9: Mechanics. Combine All Digits.
The material list
Optional:
1. Screw M3 (DIN7985 / DIN 84 /DIN 912) 10mm length - 1 piece.
2. Aluminum Mounting Hub for 5mm Shaft with four M3 holes - 1 piece.
3. Hexagon socket set screw with a flat point (ISO 4026 / EU 24026 / DIN 913) - 1 piece.
Assembling process
Do all previous steps for each digit.
Complete the display linking digits with each other.
For convenience, the wires can be fixed with cable ties.
Optional:
The main shaft can be fixed to one of the panels (pic.2) in order to prevent rotations.
Attach the mounting hub to the edge of the shaft.
Fix it with the set screw.
Drill the 3mm hole in the panel so that the axis of the hole coincides with the axis of the thread in the mounting hub.
Fasten the mounting hub with the panel using the M3 screw.
Step 10: Mechanics. Make a Mount for the Panel With Electronics.
You should make a mount to attach the panel with electronic components.
The material list
1. Steel corner braces about 30x30mm (pic.1) - 3 pieces.
2. Screw M3 (DIN7985 / DIN 84 / DIN 912) 10mm length - 6 pieces.
3. Washer M3 (DIN 125) - 6 pieces.
4. Hex nut M3 (DIN 934) - 6 pieces.
5. PCB hex standoff M3 Male-Female with more than 30mm length - 3 pieces.
Preparation
Optional:
- If it is necessary, drill suitable 3-3.5mm holes in the braces, you have.
Assembling process
Fasten the standoffs to the braces (pic.2) using nuts and screws.
Screw assembled braces to the display panels (pic. 4, pic. 5, pic. 6) using nuts and screws.
Set the braces to the desired angle.
Tighten the fasteners.
Step 11: Electronics. Assembling the Panel for Electronics.
Electronics
To make electronics I used the "Troyka" modules (pic.2). These modules do not require soldering and allow you to prototype any device simple and fast. Notice that you do not have to use the same modules as I used. You can use any other control board and any other shields or modules.
1. Arduino mega 2560 - 1 piece.
To control the display I used Arduino Mega 2560. It has lots of digital ports and enough flash memory to store the program code.
2. "Troyka" pad - 3 pieces.
"Troyka" pads are used to join "Troyka" modules without soldering.
3. "Troyka" ESP 8266 shield - 1 piece.
The module is based on ESP12 and used to connect the internet by WiFi and extract the data from the API. This module already has a logical conversion of the voltage from 3.3 V to 5V, and it is compatible with Arduino boards.
4. "Troyka" stepper shield - 4 pieces.
It is used to operate one bipolar stepper motor. The module allows you to turn on and off the motor, to set up the direction of rotation, and adjust the motor speed. It can control a stepper motor voltage of 4.5-25 V and a current of up to 600 mA.
5. "Troyka" button shield - 2 pieces.
It is the momentary button on the PCB which fits the "Troyka" pads. I used a couple of buttons to control the display manually.
6. Wires for prototyping.
The material list
1. Plexiglass back panel 3mm - 1 piece.
2. Plexiglass front panel 3mm - 1 piece.
3. PCB hex standoff M3 Male-Female / Female-Female 40mm length - 4 pieces.
4. PCB nylon hex standoff M3 Male-Female 8mm length - the quantity depends on the type of your electronics.
5. Screw M3 (DIN7985 / DIN 84 / DIN 912) 10mm length - 7 pieces.
6. Hex nut M3 (DIN 934) - 4+ pieces. The quantity depends on the type of your electronics.
Preparation
Optional:
Drill 3-3.5mm holes in the back plexiglass panel (pos.1) to mount the electronic components that you have.
Assembling process
- Screw four standoffs (pos.3) to the back panel (pos.1) using the nuts (pos.6) or screws if you have female-female standoffs.
- For electronic modules, screw the nylon standoffs (pos.4) to the back panel (pos.1) using nuts (pos.6).
- Mount the back panel (pos.1) to the display (pic.6, pic.7) using the screws (pos.5).
- Mount the Arduino board and shields to the back panel (pos.1) and link necessary pins with wires.
- Connect the Line track follower sensors with the Arduino board.
- Connect the stepper motors with the stepper driver modules.
- Combine the motors power supply on the shields using wires and bring it outside the panel.
- Cover the electronics with the front panel (pos.2) using screws (pos.5).
Step 12: Interaction With the Weather API.
Chose the API
The mechanism is finished, and it is time to choose the weather API. I wanted the display to update the weather info every half hour.
There are lots of services in a global web announcing the weather: AccuWeather, Forecast.io, AerisWeather, OpenWeatherMap, WeatherBug, World Weather Online, e.t.c.
I chose the AccuWeather API. It has a user-friendly interface and precise documentation. It can show the weather all over the planet and almost in any city. However, it is not free. The limited but free trial for a single API key is 50 calls/day. It is enough for a half hour updates.
Obtain a Key
1. Register at the Web site. Check your e-mail box. Edit your profile and log in to the site.
2. Press "My apps" and create a new Weather App. Name the app. Set the place where the API is used to "Other" and choose the C++ programming language.
3. Open "My apps" then open the app you created and get the API Key.
It looks like (this key is not real):
UrWtYw3y5A8DaFcJfMhQmSpUsXuZw4z6B8E
Write it down and save somewhere on your computer. Do not give this key to anyone.
Find out the city ID
You should know the ID of the city in which you want to know the weather. I live in Moscow, so I needed the Moscow city ID.
1. Go to "API Reference" -> "Location API".
2. As Moscow is one of the biggest cities I choose "List -> GET -> Top Cities List".
3. Enter the number of cities at the "Resource URL".
4. Enter your API key to the "Query Parameters".
5. Send request.
6. Find an ID of the necessary city in the response.
"Version": 1, "Key": "294021", "Type": "City", "Rank": 10, "LocalizedName": "Moscow", "EnglishName": "Moscow", "PrimaryPostalCode": "", "Region": { "ID": "ASI", "LocalizedName": "Asia", "EnglishName": "Asia"
7. The Moscow ID is 294021. Write down your ID somewhere not to forget.
Test the API
Let's test the API before we use it in the XOD environment and get the current weather in Moscow.
1. Go to "API Reference" -> "Forecast API" -> "1 Hour of Hourly Forecasts".
2. Enter the city ID into the "Resource URL". For my example the URL looks like:
http://dataservice.accuweather.com/forecasts/v1/hourly/1hour/294021
3. Enter the "Query Parameters" and send the request.
4. If you do everything right, you'll get something like this in the response:
"DateTime": "2018-08-03T18:00:00+03:00", "EpochDateTime": 1533308400, "WeatherIcon": 2, "IconPhrase": "Mostly sunny", "IsDaylight": true, "Temperature": { "Value": 27.6, "Unit": "C", "UnitType": 17
That's the information we will work with in XOD.
Step 13: Display Operation Principle.
Transmission ratio
The Flip holder has 36 flips it is joined to the large gear with 36 teeth. Both of the medium gears have 24 teeth. The teeth number of the drive pinion (small gear) is 14. By dividing the number of teeth (36 / 24 * 24 / 14), we get a transmission ratio. It is 1: 2,571. This means that the complete turn of the flip-holder disk equals 2,571 turns of the drive pinion. For the 1 flip rotation, the drive pinion must make the 0,0714 turn (2,571 / 36)
The Nema 17 stepper motor has the 1,8-degree step. This means that 1 drive pinion turn is equal to 200 stepper motor steps (360 / 1,8). Multiplying 200 by 0.0714 we get the number of steps to rotate the holder by 1 flip. It is 14,285.
Display operation
The operation principle is the same for each digit. First, the flip-holder begins to rotate. It rotates until the digital line sensor detects a white strip on the disc of the holder. The rotation stops, the flip-holder is set to the default position. The program knows the current symbol because we have configured it by gluing the strip to the right place of the disk. In my case, the "A" letter is set for the default holder position.
The symbols are numbered, and their order is known to us. The program multiplies the symbol number by 14,5 and gives the desired amount of steps for the motor for a particular symbol.
For example, the default character "A" has the number 0 and the character "F" has the number 5. To switch to the symbol "F" the motor makes (14,285 * 5) 71 step. The number of steps is rounded to the nearest integer.
Step 14: Making the XOD Program. Index Node.
I decided to program the display using the XOD environment. XOD is ideal for fast prototyping.
If you've never used XOD before, I highly recommend you to read a couple of tutorials and practice before programming the device.
I published the library "gabbapeople/iot-split-flap-display" that contains the necessary nodes and patches for the display control. You can find the library description on the XOD website.
Some of the nodes were created from already existing while some were written from scratch. In XOD custom nodes are written in C++. Next, I won't describe the C++ code, but only explain the basic principle of the display operation and give a brief explanation of the nodes.
Index node
This node is responsible for controlling the stepper driver module and detecting the default flip-holder position. It does not have custom nodes inside and is made entirely of core nodes.
The "Troyka" stepper driver module that I use has 3 input pins. The "DIR" sets the direction, the "STEP" is responsible for steps, and the "EN" turns the motor on or off.
To make a step, you need to change the logical 0 on the "STEP" port to 1. The number of these changes is responsible for the number of steps. There is a suitable node "flip-n-times" in XOD that can do these changes easily.
The motor is turned on at the "EN" only while the data sequence is sent to the "STEP" pin. It is done in order to consume less energy and make the stepper motor reliable.
The "digital-read" and "defer" nodes are used to signal about the white stripe on the flip-holder. With the "not" node you can switch the logical signal of your line sensor. In my case, digital line sensor outputs "True" if the color of the surface is black, and "False" if the color is white.
Input pins:
- SHOW (pulse) - a pulse input that triggers new character show.
- RST (pulse) - a pulse that is used to reset the digit. It sets the number of the motor steps after finding the default position to 0.
- CS (pulse) - a pulse that is used to set the number of the motor steps for a specific character.
- CN (number) - a number of the character to show. It is Multiplied by 14,285 to set the number of the motor steps.
STdef (number) - a number of steps that sets the speed of the flip-holder rotation during the white strip seeking. By default is set to 15.
STt (number) - the delay between sending "0" and "1" value to the "STEP" pin of the stepper driver module. By default is 0.003 seconds.
IVAL (number) - specifies the frequency of sending "0" and "1" values to the stepper driver module.
DIR (port) - a number of the port on the controller board to which the "DIR" pin of the stepper driver module
is connected.
ST (port) - a number of the port on the controller board to which the "STEP" pin of the stepper driver module is connected.
EN (port) - a number of the port on the controller board to which the "EN" pin of the stepper driver module is connected.
CHCK (port) - a number of the port on the controller board to which the digital line sensor is connected.
Step 15: Making the XOD Program. Get-weather Node.
Get-weather node
This node (pic.2) is responsible for connecting to the Web, interacting with the API, fetching the response, and parsing the data.
- "uart-1" - the node that establishes a UART connection between the controller and the ESP 8266 AT-modem module. The "uart-1" means that the controller and the modem exchange the data using the first HARDWARE serial.
- "esp8266" - the node that is responsible for initializing and configuring the AT-modem module.
- "set-station-mode" - the node that sets ESP8266 in the station mode.
- "connect" - the node that establishes an internet connection via Wi-Fi. You should configure it entering the name and the password of the network you want to connect.
- "http-request(esp8266-inet)" - the node that is used to perform the HTTP request and to return the response. Configure it with the params:
HOST - For the AccuWeather API, the address is "dataservice.accuweather.com".
PORT - The server is listening at the "80" port number.
METH - An HTTP method. For fetching the API data it is "GET".
PATH - The path to the requested resource. You can look for the path at the AccuWeather API website or use this one with your own API key and CityID.
/forecasts/v1/hourly/1hour/294021?apikey=UrWtYw3y5A8DaFcJfMhQmSpUsXuZw4z6B8E%20&metric=true
Next two order of nodes "pass-from-sequence", "pass-untill", and "parse-integer" are used to parse the response from the server.
Parsing the weather condition
The first order parsing the server response for the weather condition number. It is called "WeatherIcon". The AccuWeather API can encode the weather description in one of the 40 variants. We start to search for the sequence"WeatherIcon":
in the server response and parse the data until the "," symbol to the integer value. The sheet with a description of the weather and the corresponding values are in the attachment.
Parsing the temperature
The second parsing sequence is for the current temperature. We start to search for the sequence
"Value":
in the server response and parse the data until the "," symbol to the integer value. Transform the output integer value to a two-digit number. Round it to a minimal integer using the "ceil" node and remove the extra zeroes using the "format-number" node.
For more clarity I used the "concat" node to add spacing and "C" characters to the temperature value and output the result in a String form.
Letter-icon-to-word node
This custom node takes the weather number and outputs the four-character abbreviation in a String form.
Attachments
Step 16: Making the XOD Program. Final.
The remaining custom nodes explanation
- The "letters-word-to-bytes" node. This node inputs a four letter word in a String format and outputs four characters in a Byte format. Each character is sent to its index.
- The "letter-zero-to-o" node. This node changes the input "0" character to the letter "O".
- "letter-to-step-1", "letter-to-step-2", "letter-to-step-3", "letter-to-step-4" nodes. These four nodes are used to determine the character number for the "indexes". Each index has its own "letter-to-step" node. That is done to remove the digit errors such as flip skipping or overrotation.
The final patch
The final XOD patch is on the picture. It consists of:
- Four "index" nodes. Each display digit has own "index" node with own parameters except "STt", "IVAL", and "STdef" constants.
- The "get-weather" node.
The "clock" and "delay" nodes before the "get-weather" node. They generate a pulse every half hour and at the boot.
The "delay" and "select" nodes between "get-weather" and "letters-word-to-bytes" nodes. It is done to display the weather condition first and the temperature after.
The "letters-word-to-bytes" node.
- Four "letter-zero-to-o" nodes.
- Four "letter-to-step" nodes.
- The RESET "button" node. I use my first button to reset the digits to the default position.
- The WORD "button" node. The second button I use to reset the last shown word.