First Experiments with RGB and ESP32

The past few days, I’ve been experimenting with both RGB LEDs and ESP32. I’ve never worked with either before, so I wanted to get some experience with the basic functions before I dove into the more complex task of building the hamstercage lighting.

My first experiment was trying to get the RGB LEDs working. I have a strip of 60 WS2812 RGB LEDs, which are one of the apparently two common types of RGBs. The WS2812 distinguish themselves by having some manner of IC included in the strip, so that there’s a single data line in along with the power and ground, making coding quite easy. The other most common RGB strip also includes a clock signal, so that still seems fairly elementary. To get this working, I hooked it up to my Arduino Uno clone, added the FastLED library, and loaded up the first couple of examples. Everything pretty much worked without a hitch, which was great. About the most complex part was that the examples mostly used pre-defined colors (::red, for example) whereas I potentially want to use a whole host of RGB values. However, one quick online search and that was already solved.

ESP32, however, was a little more tricky than that. My first very practical problem is that the breakout board is just slightly too big for my breadboard. I can only just about fit it on one, leaving a single row of headers for additional pins. Nevertheless, that’s all we need to test the single RGB strip. The bigger issue was trying to figure out the pin-outs of this board. There seemed to be a number of potential pinouts provided online, and they just didn’t seem to work for me. In fact, nothing worked until I switched to a different example – I guess I must have messed something up in the example, causing all my other issues! Once I fixed that, the pin-out diagrams seemed to make sense again, so that was one hurdle taken.

However, somewhere in this testing, I seemed to have messed up one of my ESP32-WROOMs. I’m not too sure what’s going on, but it’s no longer registering on the USB port. However, I’d bought three of the chips (potentially for three separate parts of the cage, though I appear to not need that), so a secondary one took its place. I’m noticing that the problematic ESP32 has a rapidly blinking LED, which may be a hint to its condition. If I press the boot and enable buttons at the same time, I can upload a program again, but as soon as it’s reset, the chip seems stuck again and the LED is back to blinking rapidly. It’s possible that while I was probing the board with my multimeter, I may have shorted something, I’m assuming. However, for now this will remain a mystery.

Having tried out the basics of RGB LEDs and the ESP32, and being able to light the LED strip with any RGB value, I have two of the three fundementals ready to work on my hamster cage project. The last one is a way to control the lights. The most basic option is to provide some physical controls at the cage. This is quite sensible, as there’s no need to control the lights unless we’re at the cage doing something. The second option is to use Blynk. Blynk is some manner of visual app development program that has interface possibilities with ESP32 chips built-in. It seems like an easy way to make an app, but it also comes with a rather limiting fremium model that I’m not a fan of. We have the features that it offers right now, but how long before those become premium features? The last option is to personally write some manner of HTML interface. I’ve looked into it, and making an elementary one doesn’t seem too complex. The most difficult parts (having a slider for the RGB colors, for intance) are already worked out in basic java snippets available on countless forums. I like the home-made aspect of that, though it may make the controls a little less polished.

I’m not too sure what route I’ll end up taking but whichever route it will be, my next step has to be to control the color of the LEDs live in some form or another.

Exploring ESP32

I recently got three ESP-WROOM-32 Dev Boards in from AliExpress, in anticipation of my next electronics project. A few months back, we built our Syrian hamster a large cage, based on a video by ErinsAnimals (see below for the tutorial we followed).

ErinsAnimals video tutorial on how to build a three-tiered hamster cage, which we built for our Syrian hamster Latte.

Now, this cage is amazing. Before this, we had a terrily small cage for the hamster, which meant she showed all manner of bad behavior. She was stressed and dissatisfied, and needed larger living space. When we moved apartments, we also wanted to give her a more fitting place to live. The cage is amazing, but due due its size, it also blocks quite some light inside. Tracy thought it’d be a cool idea if we could install some LED lighting inside. At its simplest, it is just for us to have light inside to ease cleaning. Potentially, however, we could use RGB lights to even simulate a day/night-cycle for Latte. She gets some from the natural light in our room, of course, but because the cage is built out of wood pieces, it also blocks a lot of light.

So, the lighting part is for me to solve. I figured to have a look at ESP32 uC to see if that can help me solve this problem. It has WiFi capabilities, which would mean I could somehow figure out how to control the lights from our mobile phones, or have it check the time or perhaps lighting values, or something along those lines. I bought three of these from AliExpress, to give me the most flexibility. If I end up with the most expensive solution, I’ll wire up each section of the cage individually; however, it should be quite possible to control the entire cage with just one controller (though Tracy does not want any wires available for Latte to nibble on).

My first challenge will be to figure out how I can program this thing. I see online that there are options to use the Arduino IDE to program the thing, which is likely to be the easiest route. Apparently, the microUSB connector on the board allows me to communicate with it via UART. I also noticed that the board has some familiar pin functions (MISO, MOSI, SCLK), which seem familiar to how I used AVRDUDE to program the ATtiny. However, AVRDUDE is focused on the AVR uC family, so I don’t quite know yet how to approach this. So, step one is learning how to communicate with this board. Step two will be getting a standard blinky example working (Ahh, blink, the “Hello, world!” of the electronics hobby). I look forward to learning more!