Silicon ChipRaspberry Pi Tide Chart - July 2018 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Don’t be ripped off by your smart meter
  4. Feature: The farm of the future . . . Part II by Ross Tester
  5. Feature: Revolutionary: the Philips Compact Cassette by Ian Batty
  6. Project: Super Clock now shows your electricity tariff by Tim Blythman
  7. Serviceman's Log: Valve repairs are not for the inexperienced by Dave Thompson
  8. Review: The latest Raspberry Pi – the Model 3 B+ by Tim Blythman
  9. Project: Raspberry Pi Tide Chart by Tim Blythman
  10. Project: How’s your memory? Build the Event Reminder by John Clarke
  11. Project: 800W (+) Uninterruptible Power Supply (UPS) Part III by Duraid Madina and Tim Blythman
  12. Feature: El Cheapo: 500MHz frequency counter and preamp by Jim Rowe
  13. Vintage Radio: The 6-transistor Motorola 66T1 by Ian Batty
  14. Product Showcase
  15. PartShop
  16. Market Centre
  17. Advertising Index
  18. Notes & Errata: AM Radio Transmitter
  19. Outer Back Cover: Hare & Forbes Machineryhouse

This is only a preview of the July 2018 issue of Silicon Chip.

You can view 40 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • AgBots – robots working on the farm of tomorrow! (June 2018)
  • AgBots – robots working on the farm of tomorrow! (June 2018)
  • The farm of the future . . . Part II (July 2018)
  • The farm of the future . . . Part II (July 2018)
Items relevant to "Super Clock now shows your electricity tariff":
  • PIC32MX170F256B-50I/SP programmed for the Tariff Super Clock [SuperTariffClock.hex] (Programmed Microcontroller, AUD $15.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • Micromite LCD BackPack V2 complete kit (Component, AUD $70.00)
  • Firmware (HEX) files and BASIC source code for the Micromite-based Tariff Super Clock [v2] (Software, Free)
Items relevant to "Raspberry Pi Tide Chart":
  • Raspberry Pi 2.8-inch Touchscreen Display Adaptor PCB [24108181] (AUD $5.00)
  • 2.8-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $25.00)
  • Software for the Raspberry Pi Tide Chart (Free)
  • Raspberry Pi 2.8-inch Touchscreen Display Adaptor PCB pattern (PDF download) [24108181] (Free)
Items relevant to "How’s your memory? Build the Event Reminder":
  • Recurring Event Reminder PCB [19107181] (AUD $5.00)
  • PIC12F617-I/P programmed for the Recurring Event Reminder [1910718A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware (ASM and HEX) files for the Recurring Event Reminder [1910718A.HEX] (Software, Free)
  • Recurring Event Reminder PCB pattern (PDF download) [19107181] (Free)
Items relevant to "800W (+) Uninterruptible Power Supply (UPS) Part III":
  • 800W+ Uninterruptible Power Supply control shield PCB [11106181] (AUD $5.00)
  • Arduino Sketches (.ino) and library for the 800W+ Uninterruptable Power Supply (Software, Free)
  • 800W+ Uninterruptible Power Supply control shield PCB pattern (PDF download) [11106181] (Free)
  • 800W+ Uninterruptible Power Supply front panel artwork (PDF download) (Free)
Articles in this series:
  • 800W (+) Uninterruptible Power Supply (UPS) (May 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) (May 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part II (June 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part II (June 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part III (July 2018)
  • 800W (+) Uninterruptible Power Supply (UPS) Part III (July 2018)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)

Purchase a printed copy of this issue for $10.00.

Raspberry Pi Tide Clock and Information Screen Using the new RaspberryPi Ra spberryPi 3 B+ – by Tim Blythman Over the years, we’ve had numerous requests for Tide Clocks. Although seemingly quite trivial, it’s not an easy feat to forecast the tides (and that’s all anyone can actually do). . . but here it is. A s you might guess from the title, it’s not the only thing this project does. Tide Clock The idea of a Tide Clock may not immediately be appealing for someone who lives away from the coast, but that has not stopped us from receiving requests for such a device. Even if you are not nautically inclined, you might use a Tide Clock to know whether it is safe to go swimming in the sea baths or exploring rock pools . . . or even if there will be any beach to lie on when you get there The advantage of this Tide Clock over others that may have been suggested in the past is that they depend on complicated mathematical algorithms. These only apply to specific locations (and that may, over time, become inaccurate). This one always has access to the latest tide information. We’ve had suggestions for a Tide Clock to use the movement from an analog clock to show the relative phase of the tide, but we feel that this would not give as much information as we can show on the screen we are using. You might have guessed through our use of a Raspberry Pi 3B+ that we aren’t calculating the tides, but sim60 Silicon Chip ply fetching this data from the internet, specifically, the Bureau of Meteorology website. While this almost seems like cheating, we feel that it is the only way to consistently, accurately and easily provide tide information for a wide range of locations across Australia. We’re using the Python programming language, and although you don’t need any expe- The Raspberry Pi 3 B+ which we used for this project.This project doesn’t rely on any of the new features of the Pi 3, so you should also be able use the Pi 2 if you already have one. rience with Python to complete this project, having some exposure to programming (even in other languages) might help you with understanding Australia’s electronics magazine how it all works. Although it is based in Australia, www.bom.gov.au/australia/tides/ also provides tide information for many locations outside Australia, such as in Antarctica and Melanesia. Raspberry Pi 3B+ Element14 has provided us with a sample of the new Raspberry Pi 3B+, and this is what we have used for this project. As far as we can see, there are no specific features of the Raspberry Pi 3B+ that we are using for this project that would preclude earlier version of the Raspberry Pi being used but we have not yet tested it on any. Given the fact that the Pi 3B+ is the latest and now most easily obtained, you might as well use it rather than an earlier version if you need to buy new. The Raspberry Pi 3B+ does not look substantially different to the 3B, although you might notice the two shiny metal cans on the board standing out the most. These are the more obvious upgrades – the latest version of the Pi now sports 5GHz Wifi and a 1.4GHz processor speed. Less obvious, is that there is also a header for PoE (Power over Ethernet) on the board. This requires a separate siliconchip.com.au Above: the final Raspberry Pi Tide Clock. It consists of the Raspberry Pi 3 B+ module, the SILICON CHIP Raspberry Pi to LCD Breakout Board (as shown inset top right), which makes connection to the LCD very much simpler, along with the 2.8-inch TFT Touchscreen LCD module (see parts list). At lower right is our prototype, using a breadboard instead of the breakout board – obviously this involves lots of inter-connecting cables. PoE HAT, but sounds like a useful addon if a project requires power to be provided to it in a hard-to-reach place. The LAN has also been updated to Gigabit Ethernet, although this is limited by the fact that it is still connected via the internal USB bus, giving a maximum throughput of 300Mbps. Information Screen Because a Tide Clock might be of limited interest to those living away from the coast, we have added another feature to turn this project into something even more useful. It arises from nother request we had recently for a “readout” for the Water Tank Level Meter from the February 2018 issue. Because the ThingSpeak website also provides a portal for information to be accessed via the internet, this data can also be displayed. So why haven’t we called it a ‘Water Tank Level Meter Readout’? Apart from being quite an ungainly name, the Information Screen can be easily adapted to any numeric data that can be uploaded to a ThingSpeak feed. We recently saw that someone had adapted their hamster’s exercise wheel to upload data to a ThingSpeak feed, and this is just one of the many thousand publicly accessible feeds that are out there. How it works As we’ve already mentioned, the Raspberry Pi 3B+ is displaying the data it receives from the internet. What we’re using for the display is the same small, economical touchscreen LCD panel that is used in the Micromite LCD Backpack projects. We built our prototype with jumper The ThingSpeak website is a great way to record data logged from sensors. Our Water Tank Level Meter from February 2018 shows how even an Arduino board can upload data to ThingSpeak. Being ‘in the cloud’ allows multiple devices to access the data too. siliconchip.com.au Australia’s electronics magazine wires, but have also designed a breakout board to allow the Pi and display to be assembled into a compact, freestanding unit. The Pi fetches its data by using a carefully formulated web address. A small program in the Python language decodes this data into numbers and times which it can use to create graphs and other text information which it displays on the screen. When operating in Tide Mode, the Pi retrieves about four days of data at a time (two in advance and two in the past). When operating continually, the Pi only needs to refresh its data every day or so, as the tide data is quite minimal as only the high and low tides and times are actually recorded. The Pi uses a sine curve approximation to interpolate the intermediate tide heights, which is about the best simple approximation that can be done without requiring more information. Of course, this is not completely accurate so we cannot advise using the Tide Clock for navigation purposes. In fact, the BOM has a similar warning about the data which we are drawing from, but in our experience, the readings we are getting are no more than 10cm different from other sources of tide information. The interpolated tide heights are graphed, with a vertical line in the middle of the graph indicating the current time to the nearest hour. Information about the next high tide and low tide are also extracted from the data and displayed on the screen, along with a clock based on the Pi’s July 2018  61 The Tide Clock display shows a lot of information. The current day, date and tide conditions for the next twenty four hours are shown, as well as next high tide, next low tide and even the time. The tide conditions at Fort Denison are close and accurate enough for our location on the Northern Beaches. current internal time. Due to the clock, the display is updated every minute, although you would struggle to see any change minute to minute. The ThingSpeak interface operates in a similar fashion, downloading the data from two ThingSpeak “feeds” and then displaying it in a graph, along with a legend and axis labels on each side, and a time scale at the bottom. What ties all these parts together is a small menu screen, which is displayed when the Pi starts up. From here, either the Tide Clock or ThingSpeak screen can be activated. These pages are actually separate Python programs, so can be customised to suit your preferences. For example, if you want to monitor the tide in two separate location, then two separate programs preset to those locations can be saved and loaded by the menu. The final step in making it all work is to activate the menu program as a service under the Raspbian operating system, so that the menu starts up when the Pi is powered up. This means that the Pi can run without a monitor, keyboard or mouse. Thus the Pi can be left as a standalone display on your desk. If you do actually use your Pi as a desktop computer (eg with a monitor, keyboard and mouse) or similar, you can still use all these functions, as the Python program simply runs in the background, and the screen runs independently of any monitor. 62 Silicon Chip The above photo of the LCD screen shows data from the ThingSpeak channel from the February Water Tank Level Meter article. The horizontal and two vertical scales can be adjusted, as can the update frequency. The title and axis labels are drawn from information in the ThingSpeak channel. Display connections The hardware construction is not particularly involved, You can either assemble the interface PCB we have designed or go for the free-wired approach with jumper leads. Although we have included a spot for a real-time clock IC, it isn’t necessary for this project, as the Pi will need internet access to fetch the data it needs, and if that is the case, it should have no trouble updating its internal clock via NTP. If you are fitting the RTC IC, you will also need to install the 4.7kW resistors above the IC (near pin 1) and the capacitor below the IC as well. There are also extra steps involved in config- Fig.1: the wiring between the Raspberry Pi 3B+ and the LCD can easily be done with prototyping jumper leads if you like. Because some of the pins on the Raspberry Pi go to two pins on the LCD, this is much easier to do with the LCD attached to a breadboard. Australia’s electronics magazine siliconchip.com.au uring the RTC which are beyond the scope of this article. The minimal construction requires the 2x20 way female header to be mounted underneath the PCB, and the other two female headers to be mounted on top. Attach six of the spacers and six of the M3 x 6mm machine screws to the intermediate PCB, leaving the bottom left hole vacant. Note that some spacers go on top (to line up with the LCD) and some on the bottom (to line up with the Raspberry Pi). Through the bottom left hole of the LCD, place an M3 x 20mm machine screw and run the seventh spacer onto this, as this hole lines up directly with that in the Raspberry Pi. Screw three more machine screws into the remaining holes in the top of the LCD. Thread the final spacer onto the end of the M3 x 20mm machine screw on the back of the LCD, then attach the Raspberry Pi to the back of the PCB using the four remaining M3 x 6mm machine screws. Alternatively, if you do not have the PCB, you can wire it up using Fig.1. We found it easier to plug the LCD into a breadboard because some of the wires (for the SPI signals) are routed to more than one pin on the LCD. Fig.2: check that the contents of the /home/pi/InfoScreen folder looks like this after you have copied the files from the .ZIP file. There will also be an “infoscreen.service” file in the /home/pi folder. Software Just like any project that runs on a computer, no matter how small, this project depends heavily on software. We aren’t going to go into the detail of setting up an SD card, as you can quite easily buy a NOOBS (New Out Of the Box Software) card which greatly simplifies the process of setting the Raspbian operating system. We’ll assume you have the Pi up and running under Raspbian with a keyboard, mouse and monitor attached for test purposes, and a working internet connection via Ethernet or WiFi. The display uses the SPI interface, so the first thing is to ensure that the SPI interface is enabled. This can be found under the Preferences>Raspberry Pi Configuration menu option, then by clicking on the interfaces tab and ensuring that the SPI enable option is checked. Restart if necessary. The required software doesn’t need much work toinstall it. Using the File Manager, navigate to the /home/pi folder and extract the contents of the downloaded .ZIP to here. All but one of the files needed will siliconchip.com.au Fig.3: the Python Shell window and the MainMenu.py program laid over it. Note the version (2.17.13) which shows that we are not using the newer Python3. This is due to its incompatibility with the display library we are using. be in the /home/pi/infoscreen folder, the exception being the “infoscreen. service” file in the /home/pi folder. Fig.2: InfoScreen Folder – the ZIP file also includes some library files to control the display. These come from https://github. com/BLavery/lib_tft24T, and also include some great examples if you want Australia’s electronics magazine to experiment further with the display. There may be more files than what is shown here if we add features later. The Python programming language is included with Raspbian, and can be found under the “Programming” menu. Make sure to choose “Python 2 (IDLE)”, as the later version is incompatible with the display library we July 2018  63 that the menu and other information screens will run as programmed. Fig.3: Python Window – pressing F5 at this stage will start the MainMenu. py program, and you should see the screen initialise and display four menu items. Try touching one of the items to check that the individual screens load properly. Tapping on the screen will cause that screen to exit and return to the menu. You may not specifically want to use the locations we have set as default, and you are probably not interested in the Water Tank in our ThingSpeak channel. Fortunately, it is quite easy to change these to suit your preferences. Turning the tide Fig.4: the Tide ID parameter should be taken from the ‘Tide Locations IDs. txt’ file and put into the Tide program to allow it to download the correct information. This data was collated from the page source of www.bom.gov.au/ australia/tides/ Fig.5: a screen grab of the ThingSpeak website for the Rain Water Tank project from February 2018. We’ve highlighted the information we need to transfer to the python program to allow it to access our data. Note that this will only work on public feeds. are using. Note that we’ve had to make some small changes to the library file to make it work with recent versions of Python (the image libraries are now imported “from PIL”). The copy in the “infoscreen” folder is modified to work “out of the box”, while the zipped “lib_tft24T-master. 64 Silicon Chip zip” version is exactly what we have downloaded from Github. Choose the “Open” option from the “File” menu, and navigate to the “/home/pi/InfoScreen” folder, which should be visible in the “/home/pi” folder which is displayed by default. Open the “MainMenu.py” program. At this stage, we can run and test Australia’s electronics magazine The BOM tide information is available for many locations around and outside of Australia, as you can see from their website www.bom.gov.au/ australia/tides/ Using the map tool, find the location nearest to you. Note that the nearest location may not provide the exact tide conditions at your location, although we have set our location to “Sydney (Fort Denison)”, we find it is very close to our conditions on the Northern Beaches about 15km away. The BOM has given each of these locations a code which is not easy to discern from the website, and it is this code which the Raspberry Pi uses to generate a web address to download the necessary data. To create a custom tide location, we are going to edit and make a copy of the tide program to suit. Open the “TideChart.py” file and save it with a different name (in this case, we’ve used “TideChartLE.py” so we know this file points to Lakes Entrance in Victoria). You’ll see the “location” variable near the top of the file. This is what needs to be changed. Fig.4: Tide ID – open the “Tide Location IDs.txt” file and find the name of your location in the list. Copy the location code, paste it into the new copy and save the file. Press “F5” to run the modified file and test that it works and downloads the correct data. The name that appears at the top of the screen is retrieved from the BOM siliconchip.com.au website, so if it is correct and the tide graph appears, everything is working as it should. You can press Ctrl-C from the Python Shell window to stop the running program. You can create multiple versions for different locations and give them each a different name. If you only want to use one location and don’t have a ThingSpeak channel, name the file “MainMenu.py” (overwriting the existing file), and it will be loaded at startup instead of the menu file. If necessary, the tide minimum and maximum heights as displayed on the graph can be changed with the maxtide and mintide variables. Displaying ThingSpeak If you are adding a ThingSpeak feed to your Raspberry Pi Info Screen, then there are a few more steps to configure it too. You’ll need to know the ID of the channel and the numbers of the fields which you want to display. The ID is part of the URL you use to view the channel on a browser, so you might find it in the address bar too. Fig.6: the highlighted items can be edited to customise this program to suit your channel and preferences. Fig.5: ThingSpeak fields – from the overview page of the channel (eg https://thingspeak.com/channels/329619 for our Water Tank), look for the field numbers as shown by the arrows. We call the two feeds channel “a” and “b”, so we define their corresponding feeds as shown in the program. Fig.6: ThingSpeak Program – here is where the vertical graph ranges (“amin”, “amax”, “bmin” and “bmax”) can be set, as well as the number of vertical divisions shown (“divisions”). The “hourspan” and “hourdivision” variables also dictate how far back the graph goes in hours from the present and how this is broken up on the graph. As for the tide program, save the changes with a different name and press “F5” to check that the program does as you expect. Make changes by pressing CtrlC from the Python Shell window to stop the running program and resave if necessary. You can also exit by tapping the screen. If all you wish to ever display is a single ThingSpeak channel, then you can do the same trick as for the tides, siliconchip.com.au Fig.7: the MainMenu.py program simply checks touch panel and activates other programs as required. It should be edited to suit the menu choices you wish to use. and name the program “MainMenu. py” to run by default. Menu please As you might expect, the Menu program also needs to be customised to suit any changes you have made to the individual displays. If you are only running one screen, then you will have overwritten the existing “MainMenu.py” file, and don’t need to do this step. If you are running multiple screens, Australia’s electronics magazine open the “MainMenu.py” file. Fig.7: Menu Program – there will be two locations that need to be edited for each screen. The first is the line at the top, which contains a list of “friendly” menu names. These should be set to something easily understandable, but not more than about twenty characters. Note the last option is to shut down the Pi – if you do need a fourth option and have another way to cleanly perJuly 2018  65 form a shutdown (eg attached mouse, keyboard and monitor), then this can be replaced too. The three lower lines indicated contain the names of the programs which were saved earlier, including the full file path. If you have only changed the name, then that is all that needs to be change, ensuring that the “.py” extension is correct. As for the other programs, it can be tested by pressing F5. If the program you have added does not start, check that the filename is correct. Boot setup If everything is working so far, and you would like the display to automatically jump into the menu when the Pi starts up, then we need to make a few more changes to make that happen. What we need to do is set up the MainMenu.py program to act as a service which runs in the background. To do this, we have created a short text file called “infoscreen.service” (in the .ZIP download) which needs to be installed and activated. Open a terminal window (this is a black icon in the toolbar). If you have extracted the folder as described above, this file will exist in the home folder. We need to copy it with this command: sudo cp infoscreen.service /lib/systemd/system and make it executable: sudo chmod 644 /lib/systemd /system/infoscreen.service The following command lets the system know that a new service has been added: sudo systemctl daemon-reload After which the service can be enabled (that is, set to start at boot): sudo systemctl enable infoscreen. service The service can be stopped (for example if you want to manually run the programs or test some changes): sudo systemctl stop infoscreen. service And then restarted: sudo systemctl start infoscreen. service We’ve also included a “terminal 66 Silicon Chip Australia’s electronics magazine Parts List – Raspberry Pi Tide Clock 1 Raspberry Pi 3B+ with Raspbian installed on SD card [Element14 part number 2842228 or Altronics Z6302C] 1 Raspberry Pi to LCD adapter PCB [SILICON CHIP Online Shop part number 24108181] 1 2.8-inch TFT Touchscreen LCD module with SD card socket [SILICON CHIP Online Shop part number SC3410] 1 20 x 2 female header 1 14-pin female header 1 4-pin female header 8 M3 x 12mm tapped spacers 13 M3 x 6mm machine screws 1 M3 x 20mm machine screw commands.txt” file so that you can copy and paste the above commands directly into the terminal window. Restart the Raspberry Pi to test that everything works as expected. You can make changes to the programs while the screen is running but they will not take effect until the next reboot. So the start/stop method is a much quicker way of making and checking changes. Another screen Other tweaks that might be made are to the colour scheme- some of these are set by variables near the start of the program and some by variables in the screen.py library. They are expressed as (R,G,B) triplets, with intensities from 0-255. For example, pure red is (255,0,0). As you might imagine, with a connection to the internet, there is a vast amount of information that can be collated and displayed. Another screen we are working on will download weather forecasts and display them – you might see this in a future download. If you are a keen Python programmer (or even have some experience in other languages, particularly JavaScript, as many websites have data available in the JSON format), you could write your own programs to get data for display. Further reading: www.bom.gov.au/australia/tides/ http://nicolehorward.com/2018/04/23/ SC project-floofball/ siliconchip.com.au