old-fashioned milk bottles meet iot

If you remember from my last post on the subject, I’m into those old-school glass bottles of various sizes. Here’s the typical size and lid type that I’ll be talking about:

quart

The lids seem to come in a variety of colors and are probably made from ABS plastic—they work well and last a while. Everything cleans up nicely and I’ve had quite a few of these in my pantry for the last five years now.

Identification

There are times, though, when I wished that it were easier to tell what’s what. I honestly have a variety of things which kind of look the same: masa, ground corn meal, pancake batter, semolina flour, etc. They’re all vaguely yellowish. The same is true for the many flours which I buy.

My usual routine is to put a small Post-It type of note of some kind on the front of the bottle. But sometimes these fall off. I have been known to tape them on.

It would be nice if I had a way of easily identifying the contents of the bottle as well as preserving things like nutritional information or the instructions that you might find on the back of a Cream of Wheat box. I could also record the date of purchase and/or the expiration date but I’m not that fussy.

High-tech version

Today’s creativity involves the idea of self-identifying bottles. I’ve just purchased some tiny RFID tags which I hope to embed inside my own self-made bottle caps. I’ve just spent an hour designing the cap in Autodesk Fusion 360 and it’s now getting a test print to see if it fits. When the tags arrive I’ll carefully measure one and then design an internal cavity to accommodate the tag inside the cap. Given that the tag is completely embedded, it should be waterproof as well and should stand up to being repeatedly washed.

 

The usual tactic with respect to printing these with an embedded object is to create two jobs out of the part (1st half, 2nd half) and then insert the tag in between the print jobs. My own GetToDahChoppa project would be the way of chopping that. For this project it will be easier to just insert a pause command at the magic moment in the gcode file so that the printer pauses, alerting me to insert the tag and then I’ll manually resume. As long as I don’t include internal supports, this technique should work fine.

I thought I’d create a NodeJS-based server which sits on a Raspberry Pi computer which minimally includes an RFID reader. It would host a database of the RFID numbers and their corresponding information for each bottle in service.

The system should include a mechanism for simply reporting which bottle is being held up to the reader as well as several convenience features to include fetching the nutritional information given a UPC symbol. I’m guessing it would be nice to have something which actually scans UPC symbols but that’s not strictly necessary since it doesn’t take much to just type them in.

I guess I’ll have to type in the instructions or include a photograph of the box’s instructions.

Interface choices

I guess now, I’ll need to determine what kind of interface this will have. I could include a TFT panel. I think this would be the normal way of communicating things back to the user. In this way, you could click tabs on the screen if you wanted more information. I would assume that this would use Kivy as the graphical interface. It’s possible but I’d have to have somewhere near the pantry with power and the correct orientation, distance and lighting for the panel. And it must also work out with respect to the distance of the reader.

At the moment, though, I’m thinking that it might be interesting to push the report information to an Echo Dot that’s in the same room. In theory, you would hold the bottle’s top to the horizontally-mounted reader. There would be a delay of perhaps three seconds and then you’d hear Alexa say “Cream of Wheat”, having initiated an Alexa Skill of some kind. I’m guessing then that I might have to say “Alexa, read the instructions” to have her then read from another topic.

Given the way Amazon’s Lambda functions work, it feels like it will be problematic unless I host the database in the cloud otherwise the function wouldn’t easily have access to that information. I dunno, but I kind of like the idea that the database just lives on the Raspberry Pi itself.

I could use a simpler text-to-speech project from earlier, requiring a speaker on the Raspberry. The sound quality is basically similar to listening to Stephen Hawkins reading your panty list. I’ve also been successful using the Snips home assistant interface for doing something Alexa-like without the cloud. The quality of the output voice isn’t as slick as Alexa but it’s good enough.

Hot off the printer

While I’ve been thinking about all this, the first draft print has finished. It’s very nearly identical to the hand-measured original lid only that inner insert seems to be slightly too wide for the bottle. The PLA plastic I’m using is more rigid or I’ve made that wall too thick; it will need a slight adjustment and another test fit before I advance to the next step. It lacks subtle details that aren’t actually necessary on the original lid like central spokes and outer ribs.

FirstVersion

I’ll tweak the design and reprint it. And I guess I have to wait for those RFID tags to arrive in the mail before the next phase of this.

kivy, the hero of iot gui developers

Kivy – An open-source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

The Internet of Things (IoT) is the likely future of gadgets and devices that you’ll have in your homes and cars (if you don’t already) as well as technology that you wear. As a minimal criteria, these things use the cloud to gather and store information. In a way, even smartphones fall into this category if you think about it. Amazon’s Echo device is a good example.

For many of us who self-identify as “makers”, we use small computers with similar capabilities and we create these type of gadgets. Often when we’re coding software in this space, the Python language is the usual choice for the task.

Until now, we’ve not had many options for displaying graphical menus on such tiny screens other than the full “Desktop” GUI of some Linux-like operating system which didn’t really work, to be honest.

Introducing Kivy

A relatively new technology is the Kivy library. Imagine being able to describe the many screens you’d find in an application, whether it’s a smartphone or the touchscreen of a printer or even a watch. Then Kivy takes care of the rest for you, rendering those screens using a graphics engine behind-the-scenes. It even manages clicks and other gestures, getting these to fire off portions of your code.

Kivy comes equipped with an impressive collection of pre-defined screen widgets as well as the ability to create your own custom types. And you get all this for the low, low price of free (unlike its $5K+/year—priced competitor Qt).

I’ve had the pleasure of working on an almost daily basis with Kivy over the last two months and I must say that I’m still just as fond of it now as the day I originally learned of it.

If you’re a coder and you know Python, I would suggest that you add Kivy to your toolbelt. You’ll find that it’s easy to use and worth the effort you put into it.

rpi-update => bricked raspberry

The Internet is full of advice. This is especially the case in the world of Raspberry Pi tutorials. The problem is that sometimes you get an anti-pattern with respect to upgrading the Pi’s firmware and/or operating system: people are confused and they’re giving the wrong advice. And then this same wrong advice is repeated over and over.

Two Upgrade Paths and Only One Is Correct

There are two paths available to people so that they may upgrade their Raspberry Pi. One is for a tiny fraction of the coders out there, those who actually create the Raspbian operating system itself. And then the other path is for everyone else.

Incorrect:
sudo rpi-update

Correct:
sudo apt-get update
sudo apt-get -y upgrade

Why is This?

Unfortunately, the people who wrote the Raspbian operating system included the tools they themselves use to develop it. Just because it’s there as a command line tool, that doesn’t mean that most of us were supposed to use it.

Granted, people will take the fewest steps to get somewhere. If they think that they can save a few characters with what looks to be a simpler command, they’ll try to use it. If things don’t figuratively blow up in their face, they assume it’s good and they’ll give this advice to others.

What’s the Difference?

When you run the sudo apt-get -y upgrade version, you’re pulling the latest code from the stable master branch of Raspbian. That sudo rpi-update command instead pulls from the development branch known as next. It’s a great way of trashing your Ethernet and wi-fi driver stack so that you can no longer get to it remotely, turning your Raspberry Pi into a brick.

brick

keeping your pi cool

An average computer’s operating system maintains some logistics about the cpu, like its input voltage, temperature and the like. The Raspberry Pi single board computer is no exception and will even scale back its speed if it determines that its internal temperature is getting too high. That’s a good thing but another approach is to proactively cool the cpu with a fan when it’s approaching that threshhold.

pi-temp.png

Since I’m creating a cube-like chassis to hold four of these Raspberry Pi 3 computers, I’ll soon need this functionality. So I’ve just created a new repository with JavaScript code to return the cpu’s temperature in fahrenheit/celsius as a string or a number. One could then programmatically turn on/off a fan using the GPIO pins using this information.

Here’s that repository:  raspi-temp

3d cover for the pi noir camera

Using the (included) industrial-grade Autodesk Fusion 360 software, I was able to design a part for my Robo C2 printer. It’s a cover and mount for the Raspberry Pi NoIR v2 camera (8MP resolution @ $27). I picked up several cheap suction cups (@ $0.99) from Ace Hardware yesterday and used a digital caliper to carefully measure the distances all around. I’ll sand it a little to make it smooth; the photos below is what it looks like after removing the raft and supports (throw-away extras to make everything print correctly). The jaggies inside the suction cup slot I’ll leave since they’ll grip tightly. I’ll likely also keep some of the jaggies in the fitting between lid and base for the same reason.

I’ll still need to receive the longer cable from Adafruit for this to work so I haven’t snapped down the parts firmly yet. In the meantime, I might create a ribbon clip with a second suction cup (editing the money clip from an earlier post).

If you’d like the STL files for the part now, let me know and I can shoot you the URL for those but I’ll eventually write up a step-by-step tutorial on the full upgrade to adding the video feed capability.

IMG_0116IMG_0117IMG_0118IMG_0119IMG_0120IMG_0121IMG_0122

100posts

the robo 3d c2 printer

For months now, I’ve been wanting a 3D printer to create plastic parts and I’m guessing that I just made the best choice by buying the Robo C2.

robo

First Impressions

First of all, it’s an attractive printer in the same way that EVE (from the WALL•E cartoon) was cute.  Perhaps you can see the resemblance?

eve

Second—and you guys should know by now how I love them—this printer is driven by a Raspberry Pi 3 computer inside!  I hope to clone the microSD card in that computer and go to school on their efforts to hack an even better printer out of it.

Third, the product is open-sourced and crowd-funded.

Fourth, they’re a local company.  Their office is maybe a 20-minute drive from where I live in San Diego.  Given that most people would have to purchase this online and have it shipped, they wouldn’t get to see it in action like I just did.

Fifth, it includes an iOS app which allows you to control this and any other Octoprint-enabled printer.

Sixth, at 20 microns, it looks to have the best resolution of any of the printers I saw at Frye’s Electronics and most of those had a price tag above $1400 to reach the 50 micron resolution level.

Finally, it looks like it comes with a one-year license for Autodesk Fusion 360 which appears to be a very nice program for designing.

Research and Past Experience

I spent a fair amount of time before purchasing this by researching 3D printing, the types of plastics, the pitfalls to overcome, etc.

This particular printer doesn’t have a heated bed (the place where the project is made) so it may not do a great job with ABS plastic without a lot of trickery.  The standard voodoo that is necessary is to get inventive with the bed covering so that the project adheres nicely, doesn’t skip around and further, doesn’t warp due to uneven heating.

So for an unheated bed, the PLA type of plastic is the suggestion here and I’ve purchased an additional two rolls of the stuff to get things started.

Interestingly-enough, a few years ago I worked in a large plastic manufacturing plant so I have a little experience making plastic of the rotomolded variety.

caveman

In this industrial-sized version, colorized plastic powder is measured and put into aluminum molds on a steel frame wheel.  And this wheel then is inserted into a very large 700°F oven.

But for the consumer variety, you spend most of your time in a computer-aided design program, send a job to the printer and then wait hours (usually) to see how it turned out.  This ought to be interesting.

Projects

I have a few projects in mind for this.  I snagged a Robo Drone Kit while I was at Frye’s to give me a project which should produce some reasonable results.

dronekit

I hope to design and print an enclosure for the e=mc2 project from earlier.  Although it’s difficult, I hope to make this a clear enclosure ultimately.

I’d like to work up a design for a heated bed for the Robo C2 since it sounds like this would make ABS-related print jobs more successful.  I think I’d also like to test new bed materials since the field of 3D printing is still new and inventiveness is required here.

Given that the Robo C2 has a Raspberry Pi computer inside with OctoPi software running on it, I should be able to modify the design, add things onto the printer and do notifications, for example.  I could add an internal webcam to it, for example.

And then finally, I think I’ll spend some time on post-print finishing techniques to see what I can do in this area.

Results

Here’s the first printout from the Robo C2 after some upgrades and dialing in that critical z-adjustment.  Obviously, it’s a money clip.  It’s light blue but the red background makes it look gray otherwise.  It’s very smooth for a 3D-printed project and amazingly so for the $699 price tag on the printer.  The small, flat piece is called a “raft” and is meant to make things stable during printing, btw.

tommy can you hear me?

Okay, so this week’s invention involves me being uncharacteristically-cheap. If you usually read about the gadgets I buy, you should know that I’m seriously into making things and using a variety of tools that I need to get these projects done. I’m happy to buy something if it’s worth the cost.

For these monthly talks I’ve been giving, I wanted to have a hands-free option for the Sennheiser FM transmitter. Because when you’re giving a talk and you’re also typing on the computer it just makes sense that both hands need to be free to do that. And yet, the Sennheiser has a propriety 1/8″ jack that makes it difficult to shop anywhere but their website for accessories.  And their cheapest headset is still hella expensive (~$180) and it’s just a standard headset with a standard microphone with a propriatary plug.  <_<  So I decided to try to build an entire rig instead.

The Gear

Of course, I’m starting things with a Raspberry Pi 3 at the moment but will likely port this over to a Raspberry Pi Zero W when I get things working.

raspberry-pi-3

I just picked up a digital USB microphone from Radio Shack (since they’re closing almost all the stores here in San Diego) so that was a mere $10 and has great quality in a tiny package.

mic

At REI, I snagged an FM radio so that I could do the development and listen in on the transmitted signal.

midland

The Sennheiser at the venue looks like this.  At the last monthly talk I took a photo using my phone so that I could record their tuning for their setup.

sennheiser

You can’t see the hand-held microphone on a cable from this stock photo but it’s kind of a pain, as it is right now.

Progress

So far, things are looking pretty good. I’m able to record from the microphone using the alsa-utils arecord program. I’m able to convert the output WAV file into something suitable for re-transmission. And I’m able to broadcast the signal from a GPIO pin on the Raspberry on a selected FM frequency. I believe I can make a longer antenna that should work out.

What’s missing at the moment is a way to (correctly) daisy-chain each of the commands together so that things will continuously transmit, say, upon startup.

arecord -D plughw:1 -f S16_LE -r 48000 - | ./pifm - - | sudo ./rpitx -m RF -i - -f 87900

Something like that, anyway. Any yet, it doesn’t seem to work like this.  The various, raw “-” hyphens as seen throughout are supposed to represent STDIN/STDOUT for streaming commands from one to the next. Many times this works as expected, albeit with the odd hyphen showing up here and there.

Anyway, things like this take a lot of hacking at the problem to get it solved. Perserverance usually wins a game like this.

Update

And of course the solution was a slight tweak to the earlier attempt.

arecord -D plughw:1 -f S16_LE -r 48000 /dev/stdout 2> /dev/null | ./pifm /dev/stdin /dev/stdout | sudo ./rpitx -m RF -i /dev/stdin -f 87900

the fun never ends

Pretty stoked about my recent orders from the glorious interweb-of-stuff yesterday. Because, obviously, five Raspi’s are never enough for one coder.

Raspberry Pi Zero W

w00t. It’s a single-core version of, say, the Raspberry Pi 3 as if it were stolen, driven to a chop-shop in east Los Angeles and then people ripped off things like the RJ-45 port, the four full-sized USB ports, the header, half the RAM, etc. So it’s definitely stripped-down by comparison.  Looks like the HDMI connector and the two USBs are now their tinier counterparts. I don’t see an audio jack. It still has Bluetooth.

The ‘W’ model (up from the Zero) now includes embedded wi-fi so this ought to be killer. Best of all, it only costs $10 compared to $35 for the Raspi3. Too bad it’s twice the price of the Zero, however. And at 2.6″ x 1.2″ it’s smaller than the ones I’ve had to-date.

Raspberry Pi Zero W

zero-wireless

What will I do with this? It may very well go into the aquarium project I’m working on.

NeoPixel Quarter-Ring 60 LEDs

I also ordered four quarter rings of NeoPixel(s) to build a lighting rig for the ecosystem-pi project.

NeoPixel

The intention is to apply realistic lighting to a closed-system aquarium project throughout the day, adjusting the total lighting to compensate for the measured CO2 levels inside. Basically, the more light, the more plant growth, the more O2 produced and the more CO2 consumed in the process. There becomes a point where too much CO2 is bad for the shrimp so you don’t want to stress them out. And then too little CO2 stresses out the plants.

Digital CO2 Sensor

I was able to find a CO2 sensor for the Arduino which could be tweaked for use in a Raspberry PI project. This particular model also includes relative humidity and temperature for better logging.

COZIR Ambient carbon dioxide sensor with RH and temp

CO2_RHT-ambient_sensor_large

The Project

So far—since I don’t have any sensors, LED lights and such yet—I’m stuck with the GUI design for the interface at this point and making sure that the shrimp are happy.

ecosystem-pi.png

Everything in the interface is mocked-up right now but it ought to be fun to get the Raspberry talking to the sensors and adjusting the lighting from programmatic control. A fair bit of research has been done so far in the areas of aquarium and plant health.

But the two shrimp seem happy and have cleaned completely the two plants of their week’s worth of algae in three day’s time.

despicable me—themed supercomputer

I gave a talk on Tuesday to an eager group of 155 attendees at the monthly SanDiego.js meetup on the topic of “Supercomputing in JavaScript”. I had an opportunity to show the new Raspberry Pi 3 supercomputer which I’d built and took it through its paces.

I think they mostly loved the audio events for assembling the minions and sending them to bed (shutting off the remote nodes). There was just enough time to also show the obligatory “Hello, Minions!” demo program to exercise the Message Passing Interface. I received a wide variety of questions and compliments from the group. And of course afterward, everyone who owned a Raspberry Pi came over to discuss their own projects, which was cool.

Here’s the PowerPoint presentation from that talk, in case you’re interested.

e-mc2 repository with step-by-step instructions

does that make me a pi baker?

I discovered an awesome tool for cloning micro-SD cards like those used in the Raspberry Pi 3 computers for the project I’m working on.  It’s called ApplePi-Baker and it’s doing a fantastic job of speeding up that process.  Too bad it doesn’t work on operating systems other than OS X.

I’m guessing that it’s using the underlying/poorly-documented drive devices on the Apple like /dev/rdisk1 rather than /dev/disk1 (subtle, I know), but it’s blazingly fast by comparison and it seems to work.  And when I say “work” I mean:  you don’t have to go research all the many ways of using the dd command, for example.

Note that you’ll want a few available gigabytes on the destination drive you’re backing up to.  But the program has several compression options.  For example, backing up a 16GB image to a ZIP file only needed about 3.5GB when finished so it’s good when your space is limited.

It’s a little scary at first since it boldly asks for your Admin password as it gets started, as combined with the fact that it isn’t digitally-signed with an authorized Apple Developer key.  That said, you should be able to trust it since it does what it says it does and nothing else.  Note that after you download it, you can’t immediately run it.  You’ll need to open Finder, go to Downloads and then Ctrl-click it and choose Open the first time, then click the Open button.  Having done this once, you may then drag it to your Applications folder and then run it normally after that.