Saturday, December 30, 2017

Friday, December 8, 2017

The summary:
- get a Raspberry PI
- get a General Class FCC license (if you don't have one)
- buy the WsprryPI hat
- install the SW from GitHub
- be amazed by your contact report (map above and video below) without ever talking to anyone.
-----More detail:
There has been an amateur radio (ham) curiosity rattling around in my brain, but the urge was not enough to act on it. Then I heard about WSPR on the Embedded.fm podcast. WSPR stands for Weak Signal Propagation Reporter. Basically there are WSPR beacons that transmit with very low power (100mW for my rig) to WSPR receivers located around the world. If a WSPR receiver picks up your WSPR beacon signal the communication is logged. It's used to help study radio frequency propagation and it's fun. Take a look at the propagation map on WSPRnet.org. It is amazing the distances these very low power HF signals travel.
---
We then learned that to transmit as a WSPR beacon on the HF bands a General Class FCC Amateur Radio license was needed. That provided the motivation to get our "ticket". The sample tests did not seem difficult and we were pleased to find that learning Morse Code (CW) was no longer required. Fast forward a few weeks and we are graciously entrusted by our Federal Government to be an amateur radio operator. Cost: $15. So now what....
----
First we did what all new hams do and buy a cheap HT radio, but that's not important here....

-----

Back to the WSPR beacon... There are many WSPR protocol transmitters that can be purchased. We went with the 20m WSPR-Pi kit from TARP.org.

The TARP.org kit was chosen for a few reasons: 1st) we understand the RasPI and had a spare. 2nd) the 'kit' plugs right onto the RasPI GPIOs. 3rd) it seemed really simple.
-----
And, really simple it was (kinda). We downloaded the software that runs the WSPR transmitter from GitHub and.... it didn't compile. No worries because after installing a new, fresh, clean OS on the RasPI everything installed as planned. Next was step was to screw on two ~18 feet wires into the transmitter antenna terminals and throw those wires on the floor. The README gave us what was needed to run the software from the terminal command line. Five minutes later and we already had several transmission confirmations. Beer was consumed!!!

A comment of CAUTION: Don't route the antenna or wires to the antenna directly over the RasPI. When the WSPR beacon transmits the RF interference can cause a reboot. Moving the position of the antenna should corrrect.
-----
Here is a 24 hour animation of our contacts:

-----
And here is the WSPR beacon signal as it appears on our Tektronix MSO5 scope:

-----
In our short exposure we have gotten a lot more from the ham radio hobby than expected. Long "ragchews" probably will not be our thing, but there are so many other facets. For example, we're currently building a Yagi antenna with the goal of communicating (briefly) through a passing satellite or capturing a SSTV image from the ISS. Anyone that has been curious about the hobby should take another look. There are many other things to explore (beacons, digital modes, telemetry, satellites, moon-bounce, meteor scatter, remote control, APRS, JT65, fox hunting, amateur TV, etc.) than talking on the air and that makes it interesting.
-----
73s!

Monday, September 4, 2017

In our modern world, high bright LEDs can be purchased cheaply to provide low current draw auxiliary lighting to any vehicle. Then it is only a simple matter of connecting the LED to 12VDC and head down the road enjoying your new found wattage. However, there is no fun in the easy way. Follow the instructions below to build your own custom high bright LED driver.
-----
OBJECTIVE: A high bright LED for installation on a Kawasaki KLR650 motorcycle with six programmable modes:

-----
To keep the project simple, an Ardunio Nano is used to control the Gate Voltage (Vgs) of a MOSFET. When Vgs is HIGH the MOSFET switches on and the high bright LED turns on. By using Pulse Width Modulation (PWM) on the Arduino the brightness of the high bright LED can be easily controlled.
-----
You will need the parts in the schematic. All are readily available from Amazon or a host of electronic parts distributors. Of course, the 12VDC power source is provided by the vehicle.

---
On the bench the rig will look and function something like this:

----
The schematic leaves out some details that could be helpful. To control the MODE selection and the STROBE effect we used a handlebar mounted switch. I also drilled a small hole to mount the STATUS LED into the handlebar switch. With coded flashes, the STATUS LED lets the rider know the current mode of the rig. Pressing the GREEN button selects the next mode. Move the turn signal switch to "R" to turn on the STROBE effect. The image below provides some real world connection details. If you get the same handlebar switch we recommend buzzing out the wires first to verify them because the unit came with no diagram and low cost manufactures often change these details.

----
After you use the Arduino IDE to download the source code provided below into your Ardunio Nano you will need to mount to high bright LED. We got a mounting bracket from eBay. In the end it came out pretty nice.

-----
Here is a video of the rig running through all the modes. The quick strobe at the beginning is a wake up self test. The high bright LED swamps out the camera light sensor and doesn't provide a good indication of the actual effect. One note: It turns out Apple has a patent on the Breathing LED pattern (well, for a sleep indicator anyway). Use the "breathing LED" portion of the code with caution or, I guess, risk a cease and desist order.

-----
Here is the Arduino source code for the rig. Good luck!
//------------------------------------------------------------------------
/*
KLR650 Aux LED Driver
July 2019
WhiskeyTangoHotel.Com
Ardunio Nano (should work with other Arduinos)

Program controls a IRF510 MOSFET to drive a High Bright LED Array
(I recommend a heat sink on the MOSFET, but it should be fine without it)
A button switch selects between modes
A switch sets the LED to fast strobe mode
*/

digitalWrite(Status_LED, 0); // 0 turns the LED OFF
digitalWrite(FET_Drive, 0);
delay(Flash_delay);
stobe_on_button (); // check to see if strobe button is still pressed HIGH
} // endif strobe_button HIGH
} // end of strobe_button function

Thursday, August 24, 2017

-----
We live in great times. There was once a day when the only way to determine if the cat feeder needed more kibble was to actually look at it with your own eyes like some Neanderthal. Thankfully technology and the magical world of IoT has changed all of that.
----
For this project we use a WiFi enable ESP8266 and a STMicro VL53L0X ToF Sensor mounted to a breakout board. If you don't find a need to measure feline food consumption the project still provides Arduino code that can be extremely useful for your other IoT projects:

All of the above services are free but; of course, you will need to establish an account if you do not have on.
----What's happening?
The ESP8266 runs in Arduino mode (source code below) in an endless loop. Every hour it polls the VL53L0X ToF Sensor mounted on the lid of the cat food feeder.

-----
Since we know how many centimeters the food is from the ToF sensor at full and at empty we are able to scale those values and report/log "percent full" status. Those values are posted to a Google Drive Spreadsheet and to AT&T's M2X machine to machine servers for logging. If the food level is considered CRITICALLY LOW a SMS message goes out to our mobile device. Just to increase the geek factor, CRITICALLY LOW alerts are also displayed on our Pebble watch.
----
The Google Drive Spreadsheet looks like this:

-----
Here is the bad ass AT&T M2X machine to machine server graph (note the increase after we filled the feeder):

-----
The IFTTT SMS alerts are sent if the rig determines food levels critically low:

// Define and set up some variables
float Range_inches; // How far the sensor is from the food at time of reading. Sensor is on roof of feeder.
float Min_level = 5.0; // Distance in inches before low food alarm level. Food is far from sensor on feeder roof
float Max_level = 0.5; // Distance in inches from sensor for full feeder level. Food is close to sensor on feeder roof
float Percent_full; // How full in xx.x% is the food based on the Min/Max_levels defined above
float Caution_alarm = 35.0; // at xx.x% food level is considered low. String Status YELLOW
float Critical_alarm = 25.0; // at xx.x% food level is considered critically low. String Status RED
String Status = "***_Starting_with_Caution_at:_" + String(Caution_alarm) + "%_and_CRITICAL_at:_" + String(Critical_alarm) + "%"; // Update to Out of Range, NORMAL, LOW, CRITICAL, etc. "spaces" will error IFTTT Webhook; use "_"
int Run_number; // how many times the sensor has been read

// Output pins
const int led = 2; // Blue on board LED is on PIN2 for this NoderMCU 1.0 ESP8266. Blink it between reads

// Program control variables
int Seconds_between_posts = 60 * 60; // how often to post the results of the sensor read. NOT EXACT due to post delays, Sensor reads, LED flashing, etc.
int logging = 1; // If 1 then log to cloud. Any other value (0) turns it off. ESP8266 "Start/Restart" message is always logged.

void setup(void){ // This is run once.
pinMode(led, OUTPUT); // set up the onbaord LED pin as an output.
Serial.begin(115200); // turn on the serial monitor for debug

The micro:bit is a simple, rugged, easy to program microcontroller aimed at the education market and you get a lot for your money. The unit is programmed with a browser interface. That means no huge development environments to install on your hardrive making the time from unboxing to "Hello World" literally minutes. The simplest way to push code into the micro:bit is with the JavaScript Blocks editor. However, Java and Python can also be used.

With three mouse drags we created a program to have a servo motor track the tilt angle of the micro:bit. It doesn't get much easier.

-----

-----

If you are wanting to introduce someone to the magic of programming, basic electronics, and blinky lights this is a low cost/low risk way to make it happen.

Sunday, June 11, 2017

How fast can a Fidget Spinner spin? Well, it depends on what spins it. Let's use compressed air.

That sounds fast, it's actually scary to hold!!! But how fast?

-----

To make the measurement we used a simple LED as a sensor. A bright light shines down onto the LED. The arms of the Fidget Spinner block the light as they move over the LED creating electrical pulses.

-----

The sensor LED is connected to a Tektronix MDO4104C to measure the pulses. The scope (along with a few thousand other features) allows an engineer to quickly study waveform measurements with cursors. After a little math we get our answer; well over 10,000 RPM.

Monday, May 22, 2017

-----
It is hard to believe, but it was over five years ago that we created a Tweeting CatDoor using the Electric Imp. Basic hobby IoT was much harder back then. The Electric Imp, being a commercial grade product, was rock solid. It only needed to reboot twice during it's entire service. That said, a lightening strike may have gotten the best of it.
----
Basic hobby IoT is easier today thanks to project sites like HackaDay, etc.

A look into our spare parts box prompted some changes: The Electric Imp gets replaced by a Raspberry Pi ZERO and WiFi dongle (we didn't have a spare ZERO-W laying around). The original magnetic reed switch implementation goes solid state and gets replaced with a A3144EUA Hall Effect Sensor. The concept is still the same as the original; a magnet is placed on the door and when Zena or Kelso use the door a magnet swings past the stationary sensor triggering a GPIO event.

As shown in the wiring diagram above, the build is simple. The python code straightforward.

For the python code below you will need you create your own Twitter App and establish:

- Consumer Key (API Key) and Consumer Secret (API Secret)

- Access Token and Access Token Secret

These Keys and Tokens are, of course, changed in the python code below for obvious reasons. Also, to save space the 'database' of tweets listed in the code is reduced.

Monday, March 6, 2017

-----
Seems to be a common request: "How do I control my Amazon Echo remotely?" As to why this needs to be done is somewhat of a mystery, but evidently; done it must be...

First off; this is a hack. Even hackers being the hacker types they are will think it's a hack and those hackers will be right.
-----
Take a look at the diagram above. Basically what is happening is a Raspberry PI with a speaker plugged into it is commanding the Amazon Echo via a text-to-speech program.

The user logs into their home network via OpenVPN from anywhere in the World.

Navigate via VNC, etc. to a RasPI with a speaker placed next to an Amazon Echo.

-----
Others have done the hard work, but you will need to install some software:

If you don't have OpenVPN running, PiVPN makes this really easy on the Raspberry PI (and other platforms). This *could* be optional if you only wanted to use the hack from inside your LAN or opened up a PORT on your router. If you do decide to open up a PORT on your router for the whole wide world be aware of the risks.

Install the text-to-speech program 'festival' on the Raspberry PI with the command:

$ sudo apt-get install festival festival-freebsoft-utils

Plug a speaker into the Raspberry PI and place it next to the Amazon Echo.

Log into that Raspberry PI and issue a 'festival' text-to-speech command to control the Amazon Echo. For example:

Friday, January 6, 2017

The 'brain' is the ESP8266 uC. It is available with on board WiFi and plenty of I/O for smaller projects. All this for well under $10USD with programming options for NodeMCU, MicroPython, and the Arduino IDE.
-----
There seems to be an unstoppable drive in the hacker DIY community for web based garage door openers and we were compelled to respond. The garage door opener we have opens/shuts from a push button switch that basically creates a short to connect two terminals on the garage door opening unit. That allows easy implementation because all that is required is a ESP8266 controlled relay wired across those two terminals to create a switch closure.

In addition to activating the door any activity is logged to a Google Sheet via the IFTTT.com Maker Channel. This is handy to track all activation usage and ESP8266 server restarts.
-----
The main components are the ESP8266, a relay module, a BS170 N-Channel MOSFET.

-----
Simple. Connect the 'stuff' as shown in the schematic:

and it will look something like this:

----
Use the Arduino IDE to load the source code below into the ESP8266 then wire the Normally Open (NO) side of relay you are controlling to the two terminals on the garage door opener that active the motor when 'shorted' together.

A few comments on the application:

Control works from Android, iPhone, PC, etc. Basically any browser. In the source code below if a device can open "http://192.168.0.28/long_confusing_URL_to_activate_relay" it will activate the garage door.

There is a "TEST" URL in the source code (http://192.168.0.28/) that confirms the ESP8266 is online but does not activate the door.

Set a static IP for the ESP8266 in your WiFi router. Otherwise it may be assigned a different local IP if the ESP8266 or WiFi router is restarted.

Use long/complex URLs. That way those that are connected to your router
don't have a 'obvious' URL to activate the rig or one they can remember
if you demo it.

We only wanted control of the door when connected to the host WiFi
router locally (LAN) and not from anyplace on the planet. If you want extended control to the WWW open a port on your
router, but be aware of the concerns. We wanted to limit use only to those
authorized to connect the WiFi router locally (LAN). Plus, we didn't want to
risk accidentally activating the door from a remote location.

The source code has separate IFTTT.com Maker Channel triggers to log events. We could use one Maker Channel trigger and just pass different GETPOST variables. However, creating multiple Maker Channel triggers would easily allow usage tracking on individuals by assigning each one a unique trigger name. (/ZenaActivate, /KelsoActivate, etc...)

Any time the door is activated or the ESP8266 is restarted (power outage, etc) a Google Sheet is updated to log the event as shown below.

-----
The Arduino IDE source code is:

/*
* Garage Door Opener via Web Browser and log to IFTTT.com
* ESP8266 NodeMCU Board using Arduino IDE
* WhiskyTangoHotel.Com DEC2106
*
* Blue on board LED is active LOW on GPIO2 (D4 on silkscreen)
* Relay to control Garage Door is active HIGH on GPIO5 (D1 on silkscreen)
*
* Opening 192.168.0.28/long_confusing_URL_to_activate_relay is called. Every effort is made to keep the relay off
* so the door does not close/activate by accident.
*
* A 'test' message is display on browser to see if server is up by calling root at:.
* 192.168.0.28/ This WILL NOT ACTIVATE THE RELAY. Only tests the server
*
* The 'meat' is at 192.168.0.28/long_confusing_URL_to_activate_relay. This will send a msg to the browser AND open/close the door.
*
*/

int randNumber; // Random# generated just to show a change in the screen. Help to verify updated page call.

void handleRoot() {
// This is called if 192.168.0.28/ is requested. The root.
// The 'meat' is at /long_confusing_URL_to_activate_relay.
// This is just here to test the ESP8266 connectivity of the WiFi network without moving the relay
// Show a message and flash the on board LED.
randNumber = random(1, 10000); // Random number just to show a change on the webpage at reload.
server.send(200, "text/plain", "Testing ESP8266. Response is: " + String(randNumber));
digitalWrite(led, 0); // Active LOW. Turn On board LED On
delay(2000);
digitalWrite(led, 1); // Active LOW. Turn On board LED Off
}

server.on("/long_confusing_URL_to_activate_relay", [](){
// This is called when 192.168.0.28/long_confusing_URL_to_activate_relay is called
randNumber = random(1, 10000); // Random number just to show a change on the webpage at reload.
server.send(200, "text/plain", "Relay activated @ESP8266. Code: " + String(randNumber));
digitalWrite(led, 0); // Active LOW. Turn On board LED On
digitalWrite(relay, 1); // Relay ON