<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by SwitchDoc Labs on Medium]]></title>
        <description><![CDATA[Stories by SwitchDoc Labs on Medium]]></description>
        <link>https://medium.com/@switchdoclabs?source=rss-f1162e041d7d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qx_euf1uF_iXt2_q.png</url>
            <title>Stories by SwitchDoc Labs on Medium</title>
            <link>https://medium.com/@switchdoclabs?source=rss-f1162e041d7d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:14:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@switchdoclabs/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rule the World with GPIO Pins!]]></title>
            <link>https://medium.com/@switchdoclabs/rule-the-world-with-gpio-pins-c1bb97772cca?source=rss-f1162e041d7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1bb97772cca</guid>
            <category><![CDATA[arduino-uno]]></category>
            <category><![CDATA[esp8266]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[SwitchDoc Labs]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 20:28:07 GMT</pubDate>
            <atom:updated>2018-02-21T20:30:43.207Z</atom:updated>
            <content:encoded><![CDATA[<p>Today’s we are going to talk about GPIO Pins, the way to conquer the world. Well, at least to run the world. I always like to start out with a science joke. This neutron walks into a bar and sits down at the bar and he asked the bartender, well I’d like a beer how much? And the bartender looks at him and says, no charge …</p><p>Back to our topic, GPIO Pins. GPIO stands for General Purpose Input Output. And today we’re going to talk about what are GPIO Pins, and what are some of the real uses. How to read values and some of the things you might want to control with GPIO Pins.</p><p><strong>But first let’s start out with, what is a GPIO Pin?</strong></p><p>They are General Purpose Input Output and are pins on various processors that aren’t dedicated to anything. They’re designed for you to do input or output single bits.</p><p>A GPIO Pin is a single bit either input or output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/0*qUJfsc4m0dVK_dYM." /></figure><p>Let’s talk about the kind of output pins you have. But first, let me give you just a feeling about how many people have GPIO Pins and what they’re used for. Here’s our famous Raspberry Pi. There are about 20 GPIO Pins up here. These GPIO Pins, operate 3.3 volts. More about that later. That’s on a Raspberry Pi. In an Arduino type product, you have even more GPIO Pins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*hJH1dAeP_kk0uAU5Wm_JLw.jpeg" /></figure><p>This is an Arduino Uno. And a lot of these pins here are General Purpose Input Output, even the pins down here which connect to the 10-bit Analog/Digital Converter that we talked about in our last blog. Those can also be used as General Purpose Input Output Pins. So there’s a lot of input-output on Arduino.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*EzBr4-YZJdj3t7u7." /></figure><p>Here’s a board containing an ESP8266, another very popular chip. This is programmed like an Arduino in most cases, but it has a lot more memory than an Arduino. But unfortunately, it’s very, very short of GPIO pins. There’s only about maybe two or three that are available on this chip at all for use in General Purpose IO. Once you take away the serial port, once you take away the I2C interface, you’ll only have a couple of pins on there, and that’s not too cool. But anyway, we’ll come back to that now. But General Purpose Input Output pin first, let’s talk about Output. In the digital world, we have a signal above about 2.5 volts, it’s a 1 one is below 2.5 volts is 0, so I’m just going to call them 0’s and 1’s even though they’re different.</p><p>There are a new ESP8266 like chip out called the ESP32 which adds a second computer core and a whole bunch more GPIOs. We will talk about that chip in the near future.</p><p>On a Raspberry Pi, as I mentioned a 1 will go up to about 3.3 volts. A 0 will be down near the ground, somewhere near 0 volts. On an Arduino, it’ll go to 5 volts and then go down to 0 volts. By the way, that means that these GPIO Pins aren’t really good to connect directly between an Arduino and a Raspberry Pi because you have 3.3 volts on one end and 5 volts on the other end, you could blow up the input-output pins on a Raspberry Pi. It is tougher to do an Arduino, but you can still do it. So when you connect directly from an Arduino or Raspberry Pi, you need to plan for that. Anyway, an ESP8266 is also a 3.3-volt device so you can connect directly to a Raspberry Pi but not to an Arduino.</p><p>So we have to worry a little bit about what is a 1, what is a 0 on these parts. 5 volts, 3.3 volts. That’s the difference. Now, if I set the bit inside by using software to a 1, it’ll output that high voltage and that becomes a 1. Now you can do all sorts of these things with these bits. Well, it’s just one bit. Well, we’ll talk a little later about just the type of things you can do with these bits. Now let’s talk about Input. Input is a little trickier. Now, as I said above about 2.5 volts is 1, below 2.5 volts is 0. And that’s kind of the way the circuitry works. Not quite, but it’s pretty close to being that. Halfway between your power voltage and your ground voltage. So 3.3 Volt (like the Raspberry Pi) might be a little lower than 2.5 volts at a 1. if you’re at 5 volts its about 2.5 volts.</p><p>If the signal is a 1, if a digital output is outputting a 5 volts, let’s say, or 3.3 volts on the Raspberry Pi, your circuitry, will read it as a 1, which means 1, 0, 1, 0. That’s reading the input.</p><p>When you actually use an input on a GPIO, sometimes you have an output device that will only pull it down. It’s called an Open Drain and it’ll only pull something down. But it lets the input float if the device isn’t turned on. Well, you have to deal with that because if you let it float, you don’t know whether it’s going to end up being a 1 or a 0. These things just happen. It can be a function of the humidity or temperature. And it will change.</p><p>They move around, they float. That’s why it’s called floating these voltage levels will float. So what you do is put a Pull Up Resistor that might pull it up to 5 volts (or 3.3V for a Raspberry Pi), and then when the open drain turns on and pulls it down to 0, it’ll take that voltage all the way, very close to 0 hence a 0 digital value.</p><p>So we have Input, we have Output, we can do things with these Inputs and Outputs. In our last lecture, we talked about how we can turn an analog signal to a digital signal. Here we’re really talking about just reading digital signals in. But we can do some very interesting things with that. So let’s talk about what you use GPIO Inputs and Outputs for. Well, the simplest thing you ever think of is if you ever bring out an Arduino or a Raspberry Pi, you might do what we call a hardware “Hello World”. And what that is, is you make an led blink on and off. You do that by setting your pin to 1, 0, 1, 0. So you can turn it on and off, that’s using output. What about an input? You can hook up a switch out there that has that nasty little pull up to 5 volts or 3.3 volts.</p><p>Then you hit the button and it shorts, it takes it to ground, which makes it a 0 volt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*lsdRamQSzppBnHD4." /></figure><p>Now turns out, do you know mechanical switches bounce? They will read 1, 0, 1, 0, 1, 0, 1, 0 over maybe a hundred milliseconds. That’s a long time to a processor running 16,000,000 instructions a second. So we’ll talk about that in another lecture. But you can read switches. You can drive LED’s. You can do all these sorts of things by writing out, reading into your unit.</p><p>Basically, GPIO’s allow you to connect with the real world. That’s why we called people that hook up Raspberry Pi’s that they’re doing physical computing. They’re making the computers do something out in the real world. Whether it’s turning off a switch, whether it’s turning on an LED, whether it’s controlling a relay that turns the lights on your house or lights up a Christmas tree. All these things can be done with your little computer driving those GPIO Inputs and Outputs.</p><p>This really makes these little computers very flexible. We talked about controlling relays, controlling LEDs. So let’s talk about some of the other things you can use these for. This is a relay, it happens to be a Grove Connector, but it’s driven by a GPIO. The relay is on with a 1 and off with a 0. Now, this is actually called a Latching Relay and you end up using 2 GPIO Pins. One to turn it on and then one to turn it off and it stays latched, it stays on, stays off. Even if you turn the voltage off. So you know, that’s a special kind of relay, but it’s still really cool if you energize a relay with just a GPIO Pin, you can draw quite a bit of current, more about current in the future.</p><p>But these GPIO Pins can’t put out very much current, 5, 10, 15, 20 milliamps. You’re not going to drive something that needs a 1000 milliamps out of a GPIO. You have to put some kind of amplifier on it. So 1 bit that’s not very interesting. Well, how do we get around that? Well, we’ll come back to that in a moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*W7Ep96QZu_HWh73s." /></figure><p>But first, let’s talk about this. Some of you guys may recognize this. This is actually an Ultrasonic Distance Detector and it works by using one Output GPIO and one GPIO Input. And how it works is you take the output and set it up to a 1 and then you’re listening to the Input and depending because your computer is so fast, you can measure the time interval.</p><p>It took the distance to get from here one point to another, in this case, sound from one point to another. You’ve got the distance that can be measured. You can use this for robots, you can use it for people detection, all sorts of different things. 2 GPIO Pins, one Output to send a pulse out and one Input to read when that pulse comes back. When you have the time between those two things. You’ve got the distance. Now, what about some other devices. You guys have probably heard about Serial Devices? Serial Devices only use one Input, but you transmit sequences that are timed so you try 1, 0, 1, 0, 1, 0, and you do that in a certain way you know it’s a byte of data. So you’re using one Input, one Output on a serial device, but you can send lots and lots of information by using the timing to send 1, 0, 1, 0, 1, 0, and so on, and then you can receive data back the same way.</p><p>You’ve got a couple of issues with that. For one thing, you need to know when the bytes start, not so much with the bytes quit, but we need to know when the bytes start. That’s called Framing and it’s beyond our talk today, but there’s a number of very easy ways to do that. And so we can communicate lots of information through these serials. Speaking of serial signals, you know USB right? USB stands for Universal Serial Bus. There’s only one Input, one Output. Actually it’s bi-directional, but in any case, there’s one Input, one Output, and it serial sending data in and out that way. Just like a GPIO Pin except it’s done very cleverly so you can get a lot of data across that. One of the things we talked about was this little device here, this ESP8266 that doesn’t have very many Input/outputs on it, which means you can’t do as many fun things with a little device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/0*O6Nu93uy71uuYtnz." /></figure><p>Well, there are solutions to this. Here’s a particular device. This is called a GPIO Extender, and you can stick this on a Raspberry Pi, an Arduino or an ESP8266. This is a product we sell at SwitchDoclabs.com and this adds 8 GPIO signals to your device. You can hook up to a Raspberry Pi, an Arduino or even the ESP8266 that only has a few different GPIOs on it. These GPIO’s take a little more programming, but you can Interrupt. There is a scary word Interrupts. We’ll have to have a talk about Interrupts in the very near future, but you can make these interrupt your processors so when one of them changes you know what it is. You have to use what’s called an I2C Bus here, which is a bus that’s used to connect back and forth to various sensors and devices more on that in the future.</p><p>You could have just as many GPIO’s as you want on any device by using one of these little extenders. Let’s summarize. GPIO stands for General Purpose, Input, Output. All the processors you use to have at least a few, a Raspberry Pi and an Arduino have a lot of General Purpose Input Output that you can design your circuits and you can read your sensors off of. Very much like our friend, the little Ultrasonic Detector that you can put it in your little robot and you can use a GPIO to drive those. You can use GPIO’s to drive LEDs. You can use GPIO’s to read data, serial and others coming back from other devices like the Ultrasonic Detector, but there are hundreds of other devices that can do that too.</p><p>So why do we want GPIO’s? Because we want to control the world and that’s always a good thing.</p><p>At least I think it’s fun. I like GPIO’s, I use them a lot. Granted I do a lot of LED’s and make pretty lights and everything. But I also use it in robots. We use Ultrasonic Detectors in robots all the time. We use all sorts of different pulses. And then there’s something called a LiDAR. What’s a LiDAR? Well, it’s a Laser Ultrasonic Detector basically, but it’s using light instead of sound. But you’re still measuring the time it takes light to get out and back. You’re probably not doing that with your 16 megahertz processor, but they have a processor built in that’s fast enough to measure those distances or a piece of hardware. So you get data back in serially to you saying, there are all sorts of stuff out there. That’s how they build self-driving cars by the way. They use LiDAR, they’re kind of like really fancy ultrasonic devices.</p><p>That’s it for our GPIO talk today. Now go out and conquer the world!</p><p>Don’t forget to grab our FREE tutorial on how to connect your Raspberry Pi to communicate with Amazon Alexa! <a href="http://www.switchdoclabs.net/raspberrypialexa">www.switchdoclabs.net/raspberrypialexa</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1bb97772cca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secrets of OurWeather — Complete Weather Kit]]></title>
            <link>https://medium.com/@switchdoclabs/secrets-of-ourweather-complete-weather-kit-5625f63ae65e?source=rss-f1162e041d7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5625f63ae65e</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[makers]]></category>
            <category><![CDATA[weather]]></category>
            <dc:creator><![CDATA[SwitchDoc Labs]]></dc:creator>
            <pubDate>Fri, 29 Sep 2017 16:11:26 GMT</pubDate>
            <atom:updated>2017-09-29T16:11:26.344Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*Ep6vYgz-xkuJK8KP." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5OrFs-iFoiguQnRb.jpg" /></figure><p>This is the first of a series of “behind the scenes” postings on the OurWeather WeatherKit. Today, we will give an overview of the core of the OurWeather kit, the WeatherPlus board.</p><p>OurWeather is a weather kit designed for STEM Kids from 8 and up. It is a simple to assemble kit containing all the parts to make your own weather station. No soldering required!</p><p><a href="http://store.switchdoc.com/ourweather-complete-weather-kit/"><strong>Go to Page</strong></a></p><h3>See the details of the OurWeather Complete Weather Kit</h3><p>The WeatherPlus board behind the OurWeather Kit is a pretty cool board and is designed to be modified by the user. We supply the source code (using the Arduino IDE) and you can use <a href="http://www.switchdoc.com/inexpensive-ftdi-cable-for-arduino-esp8266-includes-usb-cable/">an inexpensive FTDI cable</a> to connect to and reprogram the OurWeather kit.</p><p>The WeatherPlus board contains a number of really special features to support the OurWeather kit. It has a <a href="http://www.switchdoc.com/2016/02/tutorial-intro-to-grove-connectors-for-arduinoraspberry-pi-projects/">Grove I2C connector</a> for adding additional sensors, an on board WiFi ESP8266 computer programmable in the Arduino IDE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*iIVHtV-HKyHtNU1w." /></figure><p>There are a number of LEDs on the board to show what is going on with the board. This really helps in debugging your connections as well as seeing what the OurWeather software is doing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*7_zNzt-jE31lkODW." /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5625f63ae65e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial — Guest Blog — Using SunControl WatchDog Timer on OurWeather]]></title>
            <link>https://medium.com/@switchdoclabs/tutorial-guest-blog-using-suncontrol-watchdog-timer-on-ourweather-9ae605551839?source=rss-f1162e041d7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ae605551839</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[makers]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[weather]]></category>
            <dc:creator><![CDATA[SwitchDoc Labs]]></dc:creator>
            <pubDate>Fri, 29 Sep 2017 16:06:00 GMT</pubDate>
            <atom:updated>2017-09-29T16:06:00.465Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/333/0*gJgf7FbwuQtgS0n4.png" /></figure><h3>Tutorial — Guest Blog — Using SunControl WatchDog Timer on OurWeather</h3><p><strong><em>Editors Note: We were tickled to receive another guest blog by Larry Bonnette. He did a great job on building this Solar Powered </em></strong><a href="http://store.switchdoc.com/ourweather-complete-weather-kit/"><strong><em>OurWeather Kit</em></strong></a><strong><em> and by adapting the GroveWeatherPi solar panel kit to the </em></strong><a href="http://store.switchdoc.com/ourweather-complete-weather-kit/"><strong><em>OurWeather Kit</em></strong></a><strong><em>. This blog post talks about how to use the WatchDog Timer on the new </em></strong><a href="http://store.switchdoc.com/suncontrol-advanced-solar-controller-charger-sun-tracker-data-gathering-grove-header/"><strong><em>SunControl</em></strong></a><strong><em> board with the OurWeather Kit. While this article is specifically about the “Arduino Like” WeatherPlus board, you can apply the same techniques to a Raspberry Pi Based system like GroveWeatherPi.</em></strong></p><h3>What is OurWeather?</h3><p><a href="http://store.switchdoc.com/ourweather-complete-weather-kit/">OurWeather</a> is an ESP8266 based connected weather station containing 7 different sensors that will teach about electronics, software and the weather.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*doJJXtWdZKpzh0j7." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*sAIkYZ0KiEJWkDx2." /></figure><p>It contains all the sensors and wires to make a fully functional, WiFi weather station. No software programming is required, it works right out of the box. However, if you want to change the way OurWeather works, add your own software or do something entirely different, we have the Open Source software available.</p><p>And what is one of the coolest features of OurWeather? <strong>Building the kit requires NO SOLDERING. It uses Grove Connectors.</strong> It is all plug and play based building, with a full step-by-step photograph based instruction manual. It is a safe and educational way to learn about weather, electronics and science topics.</p><h3>What is SunControl?</h3><p>The <a href="http://store.switchdoc.com/suncontrol-advanced-solar-controller-charger-sun-tracker-data-gathering-grove-header/"><strong>SunControl Solar Power Controller Board</strong> </a>for Raspberry Pi, Arduino and Cell Phone Charger is a 4th Generation Solar Charging and Sun Tracking Board designed by and manufactured by SwitchDoc Labs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*-CYRZDhIKxH9MDXx." /></figure><p>You can use this board to <a href="http://www.switchdoc.com/2017/07/suncontrol-prototypes-fully-functional-grove-raspberry-piarduino/">power, measure and control your Solar Power projects</a>. It incorporates a number of outstanding features in a very compact, inexpensive single fully assembled and tested PC Board. SunControl is customizable with your software and hardware. It’s even used on <a href="http://www.switchdoc.com/2017/06/project-curacao2-part-11-it-lives-deployment-and-initial-results/">Project Curacao2</a>.</p><h3>Using the SunControl WatchDog Timer — Larry Bonnette</h3><p>I have a Switchdoc.com “OurWeather” weather station set up at our RC flying field in New Waverly Texas.</p><p>You can see it here: <a href="http://tri-countybarnstormers.com/weathsta.htm">http://tri-countybarnstormers.com/weathsta.htm</a></p><p>It works pretty well but every so often it stops working. Iit is a 20 mile drive from my house to the field and sometimes I just can’t find the time to go out there to reset it.</p><p>Using an external watchdog timer may remedy the problem.</p><p>Switchdoc has a dual watchdog timer for sale. But, I am controlling my solar system with SwitchDocs newest board called the “Sun Controller-Advanced Solar Controller”.</p><p>The SunControl board has a watchdog timer built right into it (circled in red).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*-yaePttPseqnvYMW." /></figure><p>A watch dog timer is a simple timer that runs independently of a circuit (in our example the WeatherPlus board is the circuit). The watch dog timer runs for a set amount of time (say 60 seconds). When the 60 seconds has elapsed, it resets the WeatherPlus board. The timer is kept from continuously timing out by embedding code in the software to periodically reset the timer so it never times out. This is called “patting the dog”.</p><p>The theory is, that as long as the WeatherPlus board is running code (and resetting the timer) It does not need resetting. If the WeatherPlus stops running code. The timer will time out and the WeatherPlus will be reset.</p><p>The watch dog timer on the SunControl board has jumpers that allow you to change the time out value of the timer. You can choose a timeout value from 1 second to 64 seconds. Just ground the appropriate pin. I chose to operate the timer using the 64 second setting (no jumpers grounded). But, I added a jumper pin to the board so that I can test the timer at 30 second intervals. Grounding this pin sets the timeout to 30 seconds. There is a handy red LED (circled in red) that blinks when the timeout occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*3LCDNJHzwDLlWVKh." /></figure><p>I tested the watchdog by grounding the indicated pin. Every thirty(ish) seconds the LED blinked indicating a timeout.</p><p>OK, the timer works. But, will it reset the WeatherPlus board? How do I hook it all up?</p><h3>What is the WeatherPlus Board?</h3><p>The heart of the OurWeather Weather kit is the <a href="http://store.switchdoc.com/weatherplus-all-in-one-weather-station-controller/">SwitchDoc Labs WeatherPlus board.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/0*Yr4ccVXznDzTOTHm." /></figure><p>The major features of the WeatherPlus Board are:</p><ul><li>– Provides an excellent controller for a Weather Station hooked up to Raspberry Pi or Arduino</li><li>– Includes Arduino and Raspberry Pi Software</li><li>– Supports SwitchDoc Labs WeatherRack Wind Vane / Anemometer / Rain Bucket</li><li>– Contains I2C BMP280 Barometer/Temperature</li><li>– Includes DS3231 RTC/EEPROM</li><li>– Directly powers Raspberry Pi / Arduino</li><li>– Works with Raspberry Pi (3.3V) GPIO and Arduino (5.0V) GPIO</li><li>– Works with 3.3V and 5.0V I2C bus</li><li>– All onboard devices are 3.3V</li><li>– Supports I2C Lightning Detector MOD-1016</li><li>– Supports I2C AM2315 Temp/Hum Sensor</li><li>– Supports I2C Optional 32KB FRAM</li></ul><p><a href="http://www.switchdoc.com/wp-content/uploads/2016/03/WeatherPlus_Current_Spec.pdf">Here is the specification for the WeatherPlus board.</a></p><h3>Back to the WatchDog Timer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*CrgNLAT_n3Jsv0a9." /></figure><p>The WeatherPlus board is an Adruino (like) board and it has a reset pin on JP17. If you pull this pin low (ground it), It will reset the WeatherPlus board.<br>To test this, I connected the output of the watchdog timer to the RST pin on the WeatherPlus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*d1eibis97BLanaPK." /></figure><p>The watchdog timer output is the pin on JP7 marked RESETN. There are other pins that activate during a timeout but the only one that goes low is the RESETN pin on JP7. I powered the WeatherPlus from the SunControl board using the USB connectors on both boards.</p><p>I turned on the power to the SunControl board and in 30 seconds the red (watchdog) LED flashed and the WeatherPlus board reset.</p><p>Cool!</p><p>We now know that the watchdog works, and that it can reset the WeatherPlus board. But, we need to figure out how to “pat the dog” so that the WeatherPlus board does not keep resetting.<br>We need a pin on the WeatherPlus board that is free and we need to connect that pin to the watchdog timer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*2RYXbSDJp2QpIOTY." /></figure><p>I looked at the documentation for the WeatherPlus board and found that GPIO #2 on JP18 is free. So, I will use that pin to “pat the dog”.<br>Where do we connect the GPIO #2 pin ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/0*JKlykYP1qBL_xB54." /></figure><p>We connect it to the “Done” pin on JP5 on the SunControl board.</p><p>The “Done” pin wants to see a pulse going from a low to a high. This will reset the timer (before it times out).<br>The code I use is:</p><pre>#define RESET_WATCHDOG 2 //To the Watchdog timer input on JP5 “done” on the SunControl board<br> void ResetWatchdog() //Watchdog timer routine toggles pin #2 from low to high and then back to low<br> {<br>    digitalWrite(RESET_WATCHDOG, HIGH);<br>    delay(200);<br>    digitalWrite(RESET_WATCHDOG, LOW);<br> }</pre><p>I am using Switchdocs version 023 code and I placed the code above at about line 470 in the SDL_ESP8266_WeatherPlus.ino file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*UdIEgltOhk_wF6vx." /></figure><p>I added:</p><pre>pinMode(RESET_WATCHDOG, OUTPUT);<br>   digitalWrite(RESET_WATCHDOG, LOW);<br>   delay(200);</pre><p>just under the Setup(); line (around line 535). This ensures that the pin is set to “OUTPUT” and starts at a LOW setting. I then pat the dog (at line 539).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*O_JDVKXpnNfM2iTl." /></figure><p>I then “sprinked”</p><pre>ResetWatchdog();</pre><p>Throughout the code.</p><p>Specially at:<br>Line 539, 986, 1000, 1024, 1169, 1287, 1366, 1440, 1530, 1564 and 1695<br>The point is to make sure that the “dog” gets attention often enough so that the watchdog timer does not fire.</p><p>Is the above overkill ? Maybe, but it seems to be working.</p><p>I will report back on the reliability improvement. Less 20 mile trips to reset! More airplane flying!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ae605551839" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>