Silicon ChipArduino “ThingSpeak.com” ESP8266 data logger - September 2017 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Editorial Viewpoint: A rapid shift to electric vehicles could be disastrous
  4. Feature: Commemorating Cassini's demise and... by Ross Tester
  5. Feature: Commemorating Sputnik’s birth by Ross Tester
  6. Project: Fully adjustable, 3-way active loudspeaker crossover Pt.1 by John Clarke
  7. Feature: This month: Melbourne’s turn for Electronex Expo
  8. Feature: The unclear future of radio broadcasting in Australia by Alan Hughes
  9. Feature: Digital Radio Mondiale (DRM): what’s it all about? by Jim Rowe
  10. Project: Dead simple radio IF alignment with DDS by Nicholas Vinen
  11. Serviceman's Log: When a GPS loses its way by Dave Thompson
  12. Feature: LTspice Tutorial Part 3: Modelling an NTC Thermistor by Nicholas Vinen
  13. Project: Arduino Data Logger Part 2 by Nicholas Vinen
  14. Project: Arduino “ThingSpeak.com” ESP8266 data logger by Bera Somnath
  15. Feature: El Cheapo modules Part 9: AD9850 DDS module by Jim Rowe
  16. Vintage Radio: The 3-transistor Philips MT4 Swingalong by Ian Batty
  17. PartShop
  18. Product Showcase
  19. Market Centre
  20. Advertising Index
  21. Notes & Errata: Arduino Stereo Audio Playback and Recording Sheld / 12V DC Cyclic Pump Timer / New Marine Ultrasonic Anti-fouling Unit / Induction Motor Speed Controller / Building the RapidBrake

This is only a preview of the September 2017 issue of Silicon Chip.

You can view 59 of the 112 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.

Items relevant to "Fully adjustable, 3-way active loudspeaker crossover Pt.1":
  • 3-Way Adjustable Stereo Active Crossover PCB [01108171 RevD] (AUD $12.50)
  • 3-Way Adjustable Stereo Active Crossover prototype PCB [01108171 RevC] (AUD $5.00)
  • 3-Way Adjustable Stereo Active Crossover PCB [01108171 RevE] (AUD $20.00)
  • Set of four 8-gang potentiometers with knobs for the 2/3-Way Active Crossover (Component, AUD $55.00)
  • SMD parts for the 3-way Adjustable Active Stereo Crossover (Component, AUD $30.00)
  • 3-Way Adjustable Stereo Active Crossover simulation file (Software, Free)
  • 3-Way Adjustable Stereo Active Crossover PCB pattern (PDF download) [01108171] (Free)
  • 3-Way Adjustable Stereo Active Crossover front & rear panel artwork (PDF download) (Free)
Articles in this series:
  • Fully adjustable, 3-way active loudspeaker crossover Pt.1 (September 2017)
  • Fully adjustable, 3-way active loudspeaker crossover Pt.1 (September 2017)
  • 3-way Active Crossover for speakers, Part 2 (October 2017)
  • 3-way Active Crossover for speakers, Part 2 (October 2017)
Items relevant to "Dead simple radio IF alignment with DDS":
  • Micromite LCD BackPack PCB [2.8-inch version) [07102122] (AUD $5.00)
  • PIC32MX170F256B-50I/SP programmed for the Micromite-based radio IF alignment with DDS [DDSIFAlign.HEX] (Programmed Microcontroller, AUD $15.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • AD9833 DDS module with programmable attenuator (Component, AUD $25.00)
  • CP2102-based USB/TTL serial converter with 5-pin header and 30cm jumper cable (Component, AUD $5.00)
  • Micromite LCD BackPack V2 complete kit (Component, AUD $70.00)
  • Matte/Gloss Black UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $5.00)
  • Clear UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $5.00)
  • Gloss Black UB3 Lid for 2.8-inch Micromite LCD BackPack (PCB, AUD $4.00)
  • Firmware (HEX) file and BASIC source code for the Micromite-based Radio IF Alignment [DDSIFAlign.HEX] (Software, Free)
  • Micromite LCD BackPack PCB patterns (PDF download) [07102121/2] (Free)
  • Micromite LCD BackPack/Ultrasonic sensor lid cutting diagrams (download) (Panel Artwork, Free)
Items relevant to "LTspice Tutorial Part 3: Modelling an NTC Thermistor":
  • Software for the LTspice Tutorial, Part 3 (Free)
Articles in this series:
  • LTspice – simulating and circuit testing, Part 1 (June 2017)
  • LTspice – simulating and circuit testing, Part 1 (June 2017)
  • LTspice Part 2: Simulating and Testing Circuits (August 2017)
  • LTspice Part 2: Simulating and Testing Circuits (August 2017)
  • LTspice Tutorial Part 3: Modelling an NTC Thermistor (September 2017)
  • LTspice Tutorial Part 3: Modelling an NTC Thermistor (September 2017)
  • LTspice Simulation: Analysing/Optimising Audio Circuits (May 2018)
  • LTspice Simulation: Analysing/Optimising Audio Circuits (May 2018)
Items relevant to "Arduino Data Logger Part 2":
  • Arduino Data Logger shield PCB with stackable headers [21107171] (AUD $5.00)
  • Arduino Data Logger shield PCB [21107171] (AUD $2.50)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • GY-68 Barometric Pressure/Altitude/Temperature I²C Sensor breakout board (Component, AUD $2.50)
  • Elecrow 1A/500mA Li-ion/LiPo charger board with USB power pass-through (Component, AUD $25.00)
  • Elecrow 1A Li-ion/LiPo charger board with USB pass-through (Component, AUD $35.00)
  • DS3231-based Real Time Clock & Calendar module with mounting hardware (Component, AUD $6.00)
  • Firmware (Arduino sketch) file for the Arduino Data Logger (Software, Free)
  • Arduino Data Logger shield PCB pattern (PDF download) [21107171] (Free)
Articles in this series:
  • An Arduino Data Logger with GPS (August 2017)
  • An Arduino Data Logger with GPS (August 2017)
  • Arduino Data Logger Part 2 (September 2017)
  • Arduino Data Logger Part 2 (September 2017)
Items relevant to "Arduino “ThingSpeak.com” ESP8266 data logger":
  • DHT22/AM2302 Compatible Temperature and Humidity sensor module (Component, AUD $9.00)
  • Firmware (Arduino sketch) and libraries for the Arduino ThingSpeak.com Data Logger (Software, Free)
Items relevant to "El Cheapo modules Part 9: AD9850 DDS module":
  • Software for El Cheapo Modules: AD9850 DDS (Free)
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.

Logging data to the ’net using Arduino This circuit and software show how you can easily log data to the cloud from a remote location, using an ESP8266-based Arduino module. By Bera Somnath ThingSpeak.com is a website supporting open source software on the “Internet of Things”. It’s basically a repository for remotely logged data that you can access to download your sensor data at any time. This circuit and software show how you can log data to it at a remote location easily, using an ESP8266-based Arduino-type module and retrieve it over the internet later. The ESP8266 is a chip which combines a powerful ARM processor with a WiFi transceiver and antenna. We’re using a WeMos D1 R2 which is compatible with the Arduino IDE but instead of an Atmel ATmega processor, it uses the ESP8266. It’s a low-cost device that’s readily available and contains everything you need to communicate over WiFi. The parts required for this sample project can be acquired for under $20 and the result is a battery-powered device which measures its local temperature and humidity and then uploads them periodically to ThingSpeak.com You can view the logged results at any time using your PC. Setting up an account Before using ThingSpeak you need to sign up for an account and “open a channel” for your logging device. To do this, you need a working email address. Once registered, you can create as many channels as you need. Simply go to https://ThingSpeak.com and follow the instructions to register and set up a channel. Each channel has a channel ID, a “write” API key and a “read” API key. Note these down as we will need them later. Each channel can contain up to eight streams of data. You can then assign names to these streams. Our example 92  Silicon Chip will log temperature and humidity from a DHT-22 sensor, so name the first two “temperature” and “humidity”. Configuring the WeMos board Fig.1 shows how we connect the DHT22 sensor to the WeMos board, along with a lithium rechargeable battery to power it and a small OLED display so we can see the current status. If you were to position one or more of these modules remotely, having gotten them working, you wouldn’t need to connect the display. Communication with the DHT22 is over a single-wire bus and this data pin is connected to digital I/O pin D5 of the WeMos module. The OLED display is driven via an I2C serial bus and this is wired to the hardware SCL (clock) and SDA (data) pins, D1 and D2, of the WeMos board. Both modules run off the same 3.3V supply as the WeMos module. Not only does the WeMos ESP8266 board have onboard WiFi, saving you the hassle of connecting a shield for this task, as noted earlier, its processor is faster and it also has more memory. We got ours from AliExpress for less than $5. Having installed the latest version of the Arduino IDE on your computer (if you didn’t have it already), you will need to enable support for ESP8266based boards. Open up preferences in the IDE and under “Arduino Board Manager URLs”, enter: http://arduino.esp8266.com/stable/ package_esp8266com_index.json Hit OK, then go to Tools → Boards → Board Manager, type in “esp8266” in the search box, click on the entry which appears below and then click on the “Install” button. This will result in around 160MB of compilers and associated files being downloaded and installed on your computer. You can now go to the Tools → Board menu and select the “WeMos D1 R2 & mini” entry from the drop-down list. You will then need to install three The data logger was built using a small breadboard for the extra parts with the Li-ion battery sitting underneath the WeMos board. Otherwise, most connections were made using flying leads. siliconchip.com.au Arduino libraries: DHT, OneWire and thingspeak-arduino. All three are supplied in the download package from the Silicon Chip website, which also includes the sketch itself. Then install these libraries using the Sketch → Include Library → Add .ZIP Library option, if you didn’t have them already. You will then need to open up the sketch and modify it so that it can connect to your WiFi network and your ThingSpeak channel. Change the ssid[] and pass[] strings to suit your WiFi network and the myChannelNumber and myWriteAPIKey strings to match those you noted earlier when setting up your ThingSpeak account. You can then compile/verify the sketch and it’s ready to be uploaded to the WeMos board. Having wired up the circuit as shown, with the battery disconnected, plug the WeMos board into your PC via USB, ensure the Arduino IDE is configured to use the correct port and then upload the sketch. It should spring into life straight away. Once working, you can add more sensors later, which can be logged to the six spare streams in your channel. The software The code is broadly divided into a few parts. The first few lines include the relevant headers, then create instances of the WiFi, DHT, OLED and ThingSpeak.com objects. The setup function initialises these objects by calling the begin() method then inside the main loop, it retrieves the temperature and humidity from the sensor and then transfers the data to ThingSpeak. com at thirty-second intervals. The entire code is less than 70 lines, including the comments. If you eliminate the OLED-related lines, fewer than 30 remain. If you look at the code, you will see the following lines: ThingSpeak.writeField( myChannelNumber, 1, h, myWriteAPIKey); delay(15000); // ThingSpeak will only accept updates every 15 seconds. ThingSpeak.writeField( myChannelNumber, 2, t, myWriteAPIKey); delay(15000); // ThingSpeak will only accept updates every 15 seconds. Fig.1: block diagram showing the connections required to and from the WeMos module. The OLED module isn’t required for it to run, and is used more as a convenience during set-up and debugging. tion calls add a pause of fifteen seconds between each transmission. Once you declare a channel “public”, it will have a URL which is accessible to all. Just by clicking that URL, anybody can view the channel. Otherwise, for a private channel, you have to log on to see that channel’s output. Power Consumption While active, the unit draws around 80mA but most of this is the WiFi chipset. To reduce overall power con- sumption, the WiFi interface is put to sleep when not needed, reducing idle power consumption to 22mA, giving an average of around 30mA. If the optional OLED display is used, that adds another 40mA. Without the OLED display, the device can run for hours on a small LiFePO4 cell. We recommend you use this type of rechargeable cell since its normal voltage range is close to the 3.3V that SC the WeMos board requires. An example shot showing what kind of data you can expect to see when the software is up and running. These are responsible for uploading the sensor data to your ThingSpeak. com channel. The intervening funcsiliconchip.com.au September 2017  93