A Web API For Your Pi

There are many ways to attach a project to the Internet, and a plethora of Internet-based services that can handle talking to hardware. But probably the most ubiquitous of Internet protocols for the average Joe or Jane is the web browser, and one of the most accessible of programming environments lies within it. If only somebody with a bit of HTML and Javascript could reach a GPIO pin on their Raspberry Pi!

If that’s your wish, then help could be at hand in the form of [Victor Ribeiro]’s RPiAPI. As its name suggests, it’s an API for your Raspberry Pi, and in particular it provides a simple web-accessible endpoint wrapper for the Pi’s GPIO library from which its expansion port pins can be accessed. By crafting a simple path on the address of the Pi’s web server each pin can be read or written to, which while it’s neither the fastest or most accomplished hardware interface for the platform, could make it one of the easiest to access.

Security comes courtesy of Apache password protected directories via .htaccess files, so users would be well-advised to consider the implications of connecting this to a public IP address very carefully. But for non experts in security it still has the potential to make a very useful tool in the armoury of ways to control hardware from the little single board computer. It’s not the first try at this idea as we’ve seen a PHP example early in the Pi’s lifetime as well as one relying upon MySQL, but it does seem to be a simpler option than the others.

Micropython And C Play Together Better

Python is a versatile, powerful language but sometimes it’s not the best choice, especially if you’re doing work in embedded systems with limited memory. Sometimes you can get away with MicroPython for these cases, but the best language is likely C or assembly. If you’re really stubborn, like [amirgon], and really want C and Python to play well together, you can make use of his new tool which can bring any C library to MicroPython.

As an example of how this tool is used, a “Pure MicroPython” display driver for ILI9341 on the ESP32, which means that everything was implemented in MicroPython. [amirgon] wanted to see how the Python driver would compare to one that’s already been written in C, and use it to showcase MicroPython binding. This tool also automatically converts structs, unions, enums and arrays to Python objects, and provides a means to work with pointers which is something that Python doesn’t handle in the same way that C requires.

[amirgon] hopes that this tool will encourage the adoption of Micropython by removing the obstacle of missing APIs and libraries in MicroPython. Since most libraries for systems like these are written in C, a way to implement them in Python is certainly powerful. We featured one use case for this a while back, but this is a much more generic fix for this coding obstacle.

Image via [Frank Stajano]


Ask Hackaday: How Would You Build This Flight Tracker For Kids?

You’ve got to hand it to marketers – they really know how to make you want something. All it takes is a little parental guilt, a bit of technical magic, and bam, you’re locked into a product you never knew you needed.

This prototype flight tracking nightlight for kids is a great example. Currently under development by Canadian airline WestJet, the idea is to provide a way for traveling parents to let kids know how long it is until Mommy or Daddy gets home from their trip. The prototype shows a stylized jet airliner with Neopixel lighting in the base. A pair of projectors in the wings shine an animated flight path on the child’s darkened bedroom ceiling, showing them when the wayward parent will return. Get past the schmaltz in the video below, and perhaps get over your jealousy of parents with kids who still eagerly await their return, and it’s actually a pretty good idea.

Now for the ask: how would you go about building something like this? And more importantly, how would you make it work for any plane, train, or automobile trip, and not just a WestJet flight? A look at the “How it will work” section of the page shows several photos of the prototype, which suggests the hardware end is dead easy. A Raspberry Pi Zero W features prominently, and the projectors appear to be TI’s DLP2000EVM, which we’ve featured before, mounted to a riser card. The Neopixels, a 3D-printed case, and the superfluous flashlight fuselage would be pretty easy, too.

On the software side, a generic version that tracks flight from any airline would need an interface for the traveler to define a flight, and something to check an API like FlightAware’s, or similar ones for whatever mode of transportation you’re using.

Seems like a pretty straightforward project. WestJet claims they’ll have their Flight Light ready sometime this summer; think we can beat them to it?

Continue reading “Ask Hackaday: How Would You Build This Flight Tracker For Kids?”

A Farewell To YouTube Sub Counters Set To Break With API Change

Of all the things you never would have guessed you’d need just ten years ago, a YouTube subscriber counter would probably rank highly. You would have guessed that the little hits of dopamine accompanying each tick upward of a number would be so addictive?

As it turns out, lots of people wanted to keep a running total of their online fans, and a bewilderingly varied ecosystem of subscriber counters has cropped up. All of them rely on the API that YouTube exposes for such purposes, which as [Brian Lough] points out is about to change and break every subscription counter ever made. In the YouTube sub counter space, [Brian] is both an enabler – he built an Arduino wrapper to fetch YT sub counts easily – and a serial builder of displays for other YouTubers. The video below shows a collection of his work, many based on RGB LED matrix display, like the one used in his Tetris-themed sub counter. They’re all well-built, nice to look at, and sadly, destined for obsolescence sometime in August when the API changes.

The details of the API changes were made public in April, and for the subs count it amounts to rounding the count and displaying large counts as, for instance, 510k as opposed to 510,023. We’re confident that [Brian] and other display builders will be able to salvage some of their counters with code changes, but others will probably require hardware changes. Thanks, YouTube.

Continue reading “A Farewell To YouTube Sub Counters Set To Break With API Change”

Measure Your YouTube Importance

How do you hack your motivation? Do you put red marker Xs on a paper calendar every day you exercise? Do you use an egg timer to sprint through dozens of emails? Do you lock all the doors and shut off your data to write some bulletproof code? If you are [Hulk], you build a YouTube Desktop Notifier showing his YouTube subscribers and views. This is his ticket to getting off the couch to make a video about just such a device. There is something poetic about building a mechanism to monitor its own success making a feedback loop of sorts. The Hackaday.io page follows the video, so anyone who wants to build their own doesn’t have to scribble notes while pausing the video which is also posted below the break.

The hardware list is logical, starting with a NodeMCU module programmed through the Arduino IDE. Addressable 7-segment displays show the statistics in red, but you can sub in your preferred color with the back-lighting LEDs. It should be possible to share the CLK pins on the displays if you are important enough to need more digits. [Hulk] already outlined a list of improvements including switching to addressable backlights and adding daily and monthly tracking.

Monitoring online values without a computer monitor is satisfying on a level because it shows what motivates us, whether that is Bitcoin or the weather.

Continue reading “Measure Your YouTube Importance”

Building A Simple Python API For Internet Of Things Gadgets

It’s no secret that I rather enjoy connecting things to the Internet for fun and profit. One of the tricks I’ve learned along the way is to spin up simple APIs that can be used when prototyping a project. It’s easy to do, and simple to understand so I’m happy to share what has worked for me, using Web2Py as the example (with guest appearances from ESP8266 and NodeMCU).

Barring the times I’m just being silly, there are two reasons I might do this. Most commonly I’ll need to collect data from a device, typically to be stored for later analysis but occasionally to trigger some action on a server in the cloud. Less commonly, I’ll need a device to change its behavior based on instructions received via the Internet.

Etherscan is an example of an API that saves me a lot of work, letting me pull data from Ethereum using a variety of devices.

In the former case, my first option has always been to use IoT frameworks like Thingsboard or Ubidots to receive and display data. They have the advantage of being easy to use, and have rich features. They can even react to data and send instruction back to devices. In the latter case, I usually find myself using an application programming interface (API) – some service open on the Internet that my device can easily request data from, for example the weather, blockchain transactions, or new email notifications.

Occasionally, I end up with a type of data that requires processing or is not well structured for storage on these services, or else I need a device to request data that is private or that no one is presently offering. Most commonly, I need to change some parameter in a few connected devices without the trouble of finding them, opening all the cases, and reprogramming them all.

At these times it’s useful to be able to build simple, short-lived services that fill in these gaps during prototyping. Far from being a secure or consumer-ready product, we just need something we can try out to see if an idea is worth developing further. There are many valid ways to do this, but my first choice is Web2Py, a relatively easy to use open-source framework for developing web applications in Python. It supports both Python 2.7 and 3.0, although we’ll be using Python 3 today.

Continue reading “Building A Simple Python API For Internet Of Things Gadgets”

Slack On The SNES Via Satellite

We love seeing hardware and software from bygone eras getting a new lease on life through modern hacks, as longtime readers can surely attest to. Why leave this stuff to rot in a closet somewhere when it can be pushed into service today? Granted it might not always be the most efficient way to accomplish a task in the 21st century, but at least you’ll net some precious Internet Points for originality.

As a perfect example, take a look at this project which lets you read Slack messages through a Super Nintendo game. If your first thought was that such a thing would involve an unreasonable amount of effort and hoop jumping…then you would be correct. [Bertrand Fan] really had to think outside the box to make this one happen, and even admits a bit of imagination is required on the part of the end-user to use it. But it’s undeniably an original approach, so we hereby bestow the customary Internet Points unto him.

So how does this work, and where do the satellites come in? The key is in a fairly obscure Japanese SNES peripheral called the Satellaview, one of Nintendo’s early attempts at creating an online content delivery system for their consoles. Games designed with Satellaview support would be able to pull down new content from regular satellite broadcasts, not too bad for 1995. This means that if you have the hardware, and happen to own a satellite, you can push your own content into an unmodified SNES. No problem, right?

Alright, [Bertrand] didn’t really use a Satellaview modem plugged into an actual SNES. Plus we’re fairly sure he doesn’t have his own satellite network to broadcast Slack messages with anyway. But it turns out some SNES emulators have support for a virtual Satellaview modem, and there’s even software out there that will let you create new content “downloads” for the system’s included game: BS-X: The Story of The Town Whose Name Was Stolen. All he had to do was connect the dots.

[Bertrand] started by stripping the user interface out of SatellaWave, an open source tool for creating Satellaview content, so that it only need to be provided with an XML file of the content to be “downloaded” by the virtual satellite modem. Using the Slack API, he then came up with way to pull the last 10 messages from a server and push them into his modified version of SatellaWave. Each time somebody posts a new message his software kicks in to produce a new satellite download which automatically gets picked up by the SNES emulator and pops up in the game.

If this is still too practical for you, you can always go all in and run Slack on your Commodore 64.

Continue reading “Slack On The SNES Via Satellite”