Using Gmail With OAUTH2 In Linux And On An ESP8266

One of the tasks I dread is configuring a web server to send email correctly via Gmail. The simplest way of sending emails is SMTP, and there are a number of scripts out there that provide a simple method to send mail that way with a minimum of configuration. There’s even PHP mail(), although it’s less than reliable.

Out of the box, Gmail requires OAUTH2 for authentication and to share user data, which has the major advantage of not requiring that you store your username and password in the application that requires access to your account. While they have an ‘allow less secure apps’ option that allows SMTP access for legacy products like Microsoft Outlook, it just doesn’t seem like the right way forward. Google documents how to interact with their API with OAUTH2, so why not just use that instead of putting my username and password in plaintext in a bunch of prototypes and test scripts?

Those are the thoughts that run through my head every time this comes up for a project, and each time I’ve somehow forgotten the steps to do it, also forgotten to write it down, and end up wasting quite a bit of time due to my own foolishness. As penance, I’ve decided to document the process and share it with all of you, and then also make it work on an ESP8266 board running the Arduino development environment.

Continue reading “Using Gmail With OAUTH2 In Linux And On An ESP8266”

Statistics And Hacking: A Stout Little Distribution

Previously, we discussed how to apply the most basic hypothesis test: the z-test. It requires a relatively large sample size, and might be appreciated less by hackers searching for truth on a tight budget of time and money.

As an alternative, we briefly mentioned the t-test. The basic procedure still applies: form hypotheses, sample data, check your assumptions, and perform the test. This time though, we’ll run the test with real data from IoT sensors, and programmatically rather than by hand.

The most important difference between the z-test and the t-test is that the t-test uses a different probability distribution. It is called the ‘t-distribution’, and is similar in principle to the normal distribution used by the z-test, but was developed by studying the properties of small sample sizes. The precise shape of the distribution depends on your sample size. Continue reading “Statistics And Hacking: A Stout Little Distribution”

Feed Your Cat The Modern Way

Feeding the cat should be a moment of magic, in which you bond with your adorable pet as she rubs seductively against your ankles. As you place the saucer of tender and moist meaty chunks on the floor, she bounds the length of your kitchen, excited expression on her little kitty face, and tail in the air.

If Hackaday made television adverts for cat food, we’d have it nailed. But our everyday reality involves the cute-as-heck Hackaday moggy turning into a persistent little pest when she decides it’s feeding time. [ThinkSilicon]’s friends had exactly this problem, with their furry friend’s preferred timing coming early in the morning. His solution? An automated cat feeder (translated) that dispenses kibbles from a hopper into the lucky mouser’s feeding dish.

The mechanical part of this endeavour is pretty straightforward, a servo moves a sliding piece of plywood with a hole cut in it across the bottom of a hopper full of cat food. Move the slide, dispense food down a chute to the waiting happy cat. Behind the scenes is an ESP8266 and a NodeMCU web service, through which feeding time can be either scheduled, or dispensed at will.

A happy cat means a happy owner, especially in the very early morning. Until that is the newly-sated creature decides to spread the love, jumping onto the owner’s bed in thanks and breathing cat-food-breath into their face. You really do have to love ’em!

We’ve shown you many cat food related projects in the past, including this Arduino take on the same idea. But why take the effort to trigger it yourself, when the cat can do it for you.

Count YouTube Subscribers With This Red Play Button Award

Professional YouTubers live and die by the number of subscribers they have. It seems like a brutal way to make a living to us, but to each his own. Still, if you’re going to do it, you might as well do it right, and keeping track of how you’re doing with this Play Button Award subscriber counter might make sense. Or it might drive you nuts.

YouTuber [ibuynewstuff] has reached the vaunted 100,000 subscriber mark, the number required to earn the Silver Play Button award. Sadly, 100k is the bare minimum needed to get YouTube’s attention, and tales of waiting for months for the award to arrive are not uncommon. [ibuynewstuff] worked around the issue by 3D-printing his own temporary play button badge. Mounted to a picture frame with an ESP8266 and an 8 x 80 LED display behind a diffuser, [ibuynewstuff] can keep track of his progress toward the Gold Play Button award at 1,000,000 subs. Hopefully, his Silver award will arrive before then.

Want to replicate this but would rather have something a little more permanent than a plastic play button? Try casting your own Copper Play Button award.

Continue reading “Count YouTube Subscribers With This Red Play Button Award”

ESP8266 Home Monitor Is Stylishly Simplistic

It’s often said that “Less is More”, and we think that the chic ESP8266 environmental monitor posted by Thingiverse user [bkpsu] definitely fits the bill. Dubbed “Kube”, the device is a 3D printed white cube with an OLED display in the center, which [bkpsu] says was designed specifically for the approval of his wife. Weirdly, she didn’t like the look of bare PCBs on the wall.

Multiple Kubes allow for whole-house monitoring.

Inside, things are a little more complex. The Kube uses the NodeMCU development board, and a custom breakout that [bkpsu] designed to interface with the display and sensors. For temperature and humidity monitoring, the Kube is using the ever-popular DHT22, and [bkpsu] mentions that he has future plans for things like motion sensors and direct control of RGB LED strips. All the data collected by the Kube is piped into openHAB via MQTT.

On the very detailed Thingiverse page, [bkpsu] gives background information on his design goals for the project, tips for printing out a high-quality case, a parts list with Amazon links, and pinout information for getting it all wired up. The PCB is even available on OSH Park for those who want a Kube of their own.

Even with all the stick home monitoring and automation products on the market today, many hackers simply can’t bring themselves to buying a turn-key commercial product. But we think with the results hackers have been getting rolling their own solutions, they just might be on to something.

Repair Job Fixes Compressor, Gets It Online

We’ll never cease to be amazed at the things people try to put on the Internet of Things. Some are no-brainers, like thermostats, security cameras, and garage door openers. Others, like washing machines and refrigerators, are a little on the iffy side, but you can still make a case for them. But an IoT air compressor? What’s the justification for such a thing?

As it turns out, [Boris van Galvin] had a pretty decent reason for his compressor hacks, and it appears that the IoT aspect was one of those “why not?” things. Having suffered the second failure of his compressor’s mechanical pressure switch in a year, and unwilling to throw good money after the $120 that went into replacing the first contactor, [Boris] looked for a cheaper and more interesting way to control the compressor. An ESP8266 dev board made interfacing the analog pressure sensor a snap, and while he was at it, [Boris] added a web interface with a nice graphical air pressure gauge and some on-off controls. Now he can set the pressure using his phone and switch it off in the middle of the night without going outside. That’s an IoT win right there.

No air compressor? No worries — build your own from an old fridge. The non-IoT kind, preferably.

Eavesdropping With An ESP8266

In the old days, spies eavesdropped on each other using analog radio bugs. These days, everything’s in the cloud. [Sebastian] from [Hacking Beaver]  wondered if he could make a WiFi bug that was small and cheap besides. Enter the ESP8266 and some programming wizardry.

[Sebastian] is using a NodeMCU but suggests that it could be pared down to any ESP8266 board — with similar cuts made to the rest of the electronics — but has this working as a proof of concept. A PIC 18 MCU samples the audio data from a microphone at 10 kHz with an 8-bit resolution, dumping it into a 512-byte buffer. Once that fills, a GPIO pin is pulled down and the ESP8266 sends the data to a waiting TCP server over the WiFi which either records or plays the audio in real-time.

[Sebastian] has calculated that he needs at least 51.2 ms to transfer the data which this setup easily handles, but there are occasional two to three second glitches that come out of the blue. To address this and other hangups, [Sebastian] has the ESP8266 control the PIC’s reset pin so that the two are always in sync.

Continue reading “Eavesdropping With An ESP8266”