Neopixel Stoplight

3D Printed Neopixel Stoplight

I had been looking for a STL of a stoplight to print for about a year now. I wanted to use the colors of the stoplight to signal to my younger kids when it was ok to wake up in the morning, and when it was time to go back to sleep. My ideal was that I could use Node-Red running on the home server via MQTT to regulate when the stoplight changed colors. Thingiverse’s search is horrible and you could spend days there and not actually get what you are looking for so I never found one that would work. The other day I was searching for some reference STLs of something and accidentally came across a STL for a stoplight. Not one, but three (two remixed from the other).

The first one looked great, good size and decent design. Except it was designed for LEDs and an ATTiny to drive its sequence. The second was a remix of the first. The third was another remix that extended the back casing. The remixes made things easier to print but still relied on LEDs and an ATTiny of sorts. This was a great starting point for me. I have no problems modifying STLs for my purposes. I like to use Tinkercad, not very good with Fusion 360. I downloaded the files and started my own remix. I took elements from all three versions of the stoplight.

I modified the back case to allow a Lolin v3 to be able to mount to it. Then I had to create a cover for the Lolin. I took the front from the original thing, I preferred its one piece to the remixes four piece but I filled in the slot for the little switch. I used the LED panes/covers from the original, unmodified. This was great, I had a front and back a cover, LED panes and the inlay to hold the LEDs. So I printed it all out and went to work. First things first, I tested the LEDs. Like I thought, the LEDs I have are not the super bright ones and running off of the Lolins 3v they just didn’t have enough brightness to shine through very well. No super bright LEDs but I do have some WS2812 neopixels. I hooked one up to test and yes they were perfect. So I modified the LED inlay to hold three neopixels.

I wanted to be able to control the stoplight via MQTT from my server running Node-Red. I used the neopixel example from Adafruit and the default Pubsubclient example for an ESP8266. Mashed the two together and I was able to change the colors on the fly with no problems. I showed off the stoplight to a friend of mine and he loved it. He wanted one for himself, but he doesn’t have a server or anything that runs MQTT. No problem, the Lolin can handle web GUIs. A quick google for a web server on an ESP turned up a nice little tutorial on how to turn on and off GPIO pins from a web GUI. BAM! I took that code and mashed it up with the neopixel code I already had an I was able to get a nice little web page displayed to change the colors of the stoplight. This is awesome.

View Post

Neopixel Notifier

Neopixel Notifier

I was looking for solutions to make a notifier to for various projects. I while back I made something similar with a small OLED screen but this time I wanted something more “wife friendly” so I set out. I had a few neopixel WS2812 RGB LEDs laying around and some NodeMCU ESPs. I went with a NodeMCU board for simplicity of micro USB power already onboard but you could use any ESP for this project and it should work.

So I started searching how to cobble them together and I found https://www.reddit.com/r/esp8266/comments/5f8x8t/mqtt_and_neopixels_with_the_arduino_ide/

Which led me to https://github.com/joshhodgson/ESPNeopixelMQTTDriver… which led me to here https://goo.gl/KdtWUz.

This was perfect. I took the ESP8266 and connected it via MQTT to subscribe to a topic for changing the colors of a WS2812 (neopixel). All you do is send RBGW code (255000000000 is red for example) via the topic.

The code works great, after changing the topics and such. But its not up to my liking. So here is my re-coded version. I basically made it easily editable, add all the variables to the top.

Now I can slap an ESP and the neopixel in something for notification. I just have to remember what each color means and I will let Node-Red send the changes when needed. Fucking awesome. I can use this for temperature, rain, mail delivery, change the color if someone has ever pressed the doorbell that day…its endless. Only downfall is one alert overrides the previous color (is that really a downfall?) so the alert is “over-written”. So if you are going to use it for say timing on something or modes of the day or what have you, single project use, then it should fit the bill.

I happened to have to have a 3D printer and came across a really nice model of a lamp (Bioh Lamp) that I decided would work perfect as a notifier. After I made some modifications and added NodeMCU standoffs it worked perfectly. Don’t get me wrong it took a few tries to get the spacing right and I tried a few approaches before using the NodeMCU so the older standoff for centering the WS2812 is still there. Unfortunately the author has is locked up pretty tight and used the Creative Commons – Attribution – Non-Commercial – No Derivatives license so I cannot share it.

I used an old Apple iPod USB cable and chopped it up wired it to the boards. Also repurposed an old iPhone charger to use as the power supply. Perfect!

 

Code below.

View Post

ESP-01, MQTT and an OLED (SSD1306)

OLED ScreenIt took me about a week to get this going. There are still a few kinks that need to be ironed out, or worked around. But I wanted to get this out there before I forgot about it. I could not find a sketch for using an Arduino or ESP with an OLED and MQTT. Not one that didn’t just display data from a connected sensor., that is not what I wanted. I wanted to be able to send messages to the OLED screen via MQTT. I spent quite a while looking for it and I couldn’t find anything. About a week or two ago I finally broke the wall that was keeping me from sending and receiving MQTT message on an ESP. So I took that code and the working code from the Adafruit OLED sketch and made a baby.

I was able to produce a sketch that will simply display any text received via MQTT. Perfect. I plan on using this cobbled together with Node-Red. That way I can have one screen and send multiple sensor readings to it with minimal coding and parts. There are a few things I still need to figure out. For example I can’t get the screen to clear. Perhaps thats what the OLED reset pin was for? But my OLED only has four pins; SDA, SCL, Vcc and Ground. No reset. What to do? I think that is actually the only thing I need to work out. The Adafruit code will wrap your text to new lines, so make a note of that. I have gotten around clearing the screen by injecting spaces via MQTT. Its a little more effort in Node-Red for now until I get that down. But it works. It doesn’t matter how you get there as long as you get there right?

I Program the ESP via the Arduino IDE, if you don’t know how to set that up take a stroll down Google lane. Tons of help there on that topic. As it stands in the code below, once powered up the OLED should flash the Adafruit logo until a message is received then it will display the message until a new one is received. Simple. The default topic is “inTopic”, and the default OLED font size is 1. I have tried a font size of 2 but no higher. I also stumbled upon this library here. Much smaller and designed just for text. May try that in the future, but if it ain’t broke don’t fix it.

Items Required:
(1) ESP-01 (mine is a standard ESP-01 from eBay)
(1) OLED I2C Screen (I used a 0.96″ 4pin OLED also off eBay)

IDE Library Requirements:
Wire
Adafruit GFX
Adafruit SSD1306
ESP8266WiFi
PubSubClient

Some places that helped
https://learn.adafruit.com/monochrome-oled-breakouts/arduino-library-and-examples
https://github.com/adafruit/Adafruit-GFX-Library
https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts
https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives
https://github.com/knolleary/pubsubclient

This was the tutorial that helped me get what I have going. I couldn’t get the OLED to work quite right until I came across this post. I used it as the base for what I have.
http://randomnerdtutorials.com/guide-for-oled-display-with-arduino/

This page helped but not until I specified the SDA, SCL pins for the ESP. I couldn’t get the display to work properly and do what I wanted.
http://randomnerdtutorials.com/esp8266-0-96-inch-oled-display-with-arduino-ide/

And the code (below): [See the comments for updated code]
View Post

MPU6050 on an ESP8266-01 via MQTT

Update 3/16/17: I added code at the end of the post for dual MPU6050s
Update 2/2/18: Added images of possible wiring examples for ESP-01 and NodeMCU

Another milestone for me. I’m on a fucking roll! I found an Arduino sketch that takes an MPU6050 on an ESP8266-01  and spits it out data via MQTT. I have been looking for this and trying to accomplish this for months. My end goal is a clothes washer and dryer monitor for the family. There are sketches out there for laundry monitors but they don’t have what I need, mainly multiple users…I digress. So I found the script and it works, but some of it was it Italian which made it confusing for me and it did clumped all the sensor data into just two categories; accelerometer or gyroscope. I need more detailed information so I hacked it up a bit and it works!!

I commented out some stuff that was not needed (it all works for me YMMV), and I split all of the sensor data up into their own MQTT topic. So you get topics for AcX, AcY, AcZ and GyX, GyY, GyZ. This allows me to just use the sensor that works for the washer or dryer. Made it really easy once I plotted the data to a line graph.

Code below:
Originally taken from here

View Post

Send and Receive MQTT data

MQTT

I made a post last year on how I was finally able to get the ESP to send MQTT data. I had forgotten all about that when I was able to flash the chips again, so I started digging for how to do it. I basically came across the same code somewhere else (can’t remember where), but this time I was able to get send and receiving to work. Decided to share. Once uploaded to the ESP you can see the printed results in the buffer window (I use ESPlorer). Code is below.