NeoPixel CAN-Bus Module with local control

As part of my current project to add NeoPixels to the cabin of my car – as an upgrade to an old run-around vehicle, I had various ideas. One of these was to have pixels in multiple locations in the cabin, for example, next to the rear doors on each side, as well as in the current location of the current, sad old yellow light, in the centre of the cabin. These pixels should be controllable from a central location, on the front dash of the vehicle, or above the rearview mirror, as well as have local control.

CAN-BUS seemed the logical way to have central control over all of these, and as far as local control goes, I don’t necessarily want to go messing with the 20-odd-year-old wiring of the car, it is problematic already, and my interference could just potentially make things worse. ( living in super humid SE Asia takes its toll on the wiring, and local auto-electricians make more than a mess than fix anything – while still maintaining their “standard” of high-quality pricing for an ultra-low quality job – thus scrap that right from the beginning)

I have thus decided on a three-pushbutton approach, White light, on and off, Red light on and off, and increase/decrease intensity ( I really want the red cabin lights, as it helps to preserve night vision as opposed to white)

This project is not thus a less complicated version of this,
which is the main controller PCB, minus a few components, for example:
No Buck converter – just a single LDO regulator
No Supply OR-Ing logic, as there will be only a single supply
No Battery charger, and for that matter Boost converter.

The board still uses the ATTiny1616 microcontroller ( I had a few in stock, and since I don’t need a lot of power for this, they are ideal).

CAN-BUS support is provided with an MCP2515 and supporting circuitry.
All GPIO’s on the ATTiny1616 and MCP2515 are broken out for easy access, so it is possible to really hack this board into anything needed within reason.

The NeoPixels VCC line is also controlled via a P-MOS switch, to keep them totally switched off until actually needed, thus saving a few milliamps of battery power.

Note that no connectors were fitted yet, as I am still testing the firmware of this PCB,

The Schematic

I have decided to include the schematics as downloadable .png files. just click on the images for a high-resolution picture that you can download to your device.

Manufacturing the PCB

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to who will do his/her best to resolve your issue as soon as possible.

Find out more here

Assembly and Testing

Assembly is easy, if you use a stencil. The ATTiny 1616 QFN package will give you a hard time without a precise way to apply just the right amount of solder paste to the pads.

Testing

As far as testing goes, I am busy with the final firmware of this board.
I will however go over a few things:

The UPDI programming header functions as expected, using my own programmer, and the Arduino IDE.

A standard blink sketch works as expected ( LED is on PIN_PA3)
This is also the SPI SCK pin.

The CAN BUS hardware functions as expected ( Using the MCPCan library)

A small NEOPixel strip ( 8 pixels ) connected to the module and controlled with the Adafruit NeoPixel library functions as expected – Note here that you HAVE to enable power to the pixels by pulling PC0 ( PIN_PC0) HIGH to enable the P-MOS Switch. The Pixels themselves are connected to PIN_PA6.

The 3 pushbutton switches function as expected, and are connected on PIN_PC1 to PIN_PC3, each with an external 10k pullup resistor.

I shall update further progress on the project as it becomes available. I am currently working on firmware, as well as designing a suitable enclosure to be CNC cut from acrylic.

Powering the modules in the actual vehicle shall also require some clever thinking, as I do not want them draining the car battery – I am thinking about either using the existing door-open switches or maybe an interface from the ignition to only power them when the ignition is switched on.

NeoPixel strip with built-in LDO

Neopixels are interesting. They can be almost any colour that you require, are usually quite easy to configure, can require a fair bit of current if used in sufficient quantities, and can be quite fragile when soldering—not to even talk about resoldering them onto a different PCB. My biggest pain with these versatile little LED modules is that they seem to only operate on 5v DC.

This may be fine in many environments, but for my current project, using them as replacement lighting modules for the cabin lights of my car, that 5v requirement will mean a lot of additional wiring. So I decided to just use the 12 DC that is already conveniently present in the car, and add an LDO regulator to the strip – yeah, I know, this may be nothing new, and yes, I am aware of the current limitation issues of LDO regulators.

What is on the PCB?

Well, in this case, it is a quite straight-forward answer. 12 NeoPixels, a 5v LDO regulator, and some capacitors. The LDO regulator can provide a constant current output of 800mA and 12 Neopixels with a maximum current draw of 60mA each, will require 720mA, so everything seems to be ok in the current department. I am also never going to run them at maximum current either, as they will be way too bright!

Two 5-way header pins provide the standard Power, ground, data in and data out connections – note that I have still provided a 5v input, just in case I want to reuse these in another application, where 12v is not available…

Schematic

The 12 Neopixels are daisy-chained from pixel 1 to pixel 12, with a 100nf capacitor over the power rails of each pixel.

An AMS1117-5.0 LDO regulator provides voltage regulation down to the required 5v DC. This means that the maximum input voltage can be as high as 15v DC ( remember that most of this will be disposed of as heat by the regulator – I have provided an on-pcb heatsink, but recommend that the input voltage be limited to 12 DC at a maximum – to not over-drive the regulator )

The two 5-way headers provide connections for power, ground and signals. There are from pins 1 to 5:
VIN: 12v DC maximum down to 7.2 v DC
VCC: 5v DC only
DIN: Data In
DOUT: Data out
GND: Ground connection

Using the strip

The NeoPixel strip will work with all common NeoPixel libraries, including Adafruit NeoPixel. One word of caution though – NeoPixels are never truly switched off; even when not lit up, the chip inside the pixel still consumes about 1 mA of current. While this may not seem like a lot, it quickly adds up, and can potentially drain a battery-operated system completely in a few hours if you use a lot of them.

It is thus considered good practice to completely remove the input voltage from the pixel power pins when not in use. I am currently experimenting with a way of doing this via a Mosfet and transistor combination that will be controlled from the same microcontroller that drives the strip. Yes, you end up using another gpio pin, but you also potentially save a lot of power; in my book a good trade-off, since gpio pins on microcontrollers are plentiful these days, and we rarely use all of them anyway…

The circuit comprises a simple NPN transistor ( BJT type) that drives the gate of a P-MOS mosfet, acting as a switch, that, when switched on, provides power to the NeoPixel strip.

Manufacturing the PCB

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to who will do his/her best to resolve your issue as soon as possible.

Find out more here

Assembly and Testing

This PCB’s assembly is straightforward and can be done without a stencil, using a very fine-tipped soldering iron, or, in my case, with a stencil and hotplate to reflow solder the components all at once.

Be careful never to heat a single pin on the NeoPixel chip for longer than about 2-to-3 seconds. The wires inside the chip are super super tiny, and the excessive heat can cause damage to them, leaving you with a pixel that does not work.

The stencil that I used for assembly

18650 Cell Boost Converter

As part of an ongoing project, this tiny boost converter was designed to be used to power some of my projects, as well as become a part of a much-needed add-on circuit to the single-cell 18650 charger PCB that I designed a while ago.

I received a lot of very useful comments from readers about the circuit below ( the single-cell 18560 Lipo charger). Most of these comments were related to adding a boost converter to the circuit, to add a little more versatility to the circuit.

I never just add something though, and as such, this boost converter prototype was designed to test out the components and design before incorporating it into the main design. That way, I can iron out any problems before adding it to a bigger circuit.

The boost converter is based on the MP3423GG-Z, from MPS. I have decided to stay very close to their recommended application notes, so the circuit is stock standard. Another way to ensure that performance is what I want it to be, and also, to be frank, because I don’t believe I need to make any changes to the manufacturer-recommended circuit.


Some other comments suggested the use of “ideal diodes” at the output , in order to be able to daisy-chain the chargers. That will be addressed in a later post this month, as I am also currently testing out one of the many “ideal diode” integrated circuit chips available – in this case the MAX40200.

Being a “prototype” I did not bother with adding proper connectors to this version, as it will only be used for a short while. Soldering the supply and output wires directly to the PCB will thus be sufficient for the time being.

Design and Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to who will do his/her best to resolve your issue as soon as possible.

Find out more here

Assembly

This PCB really would benefit from having a stencil available when you assemble it by hand. The MP3423GG-Z is super tiny, so having a guide to apply just the right amount of solder paste to the pads will go a long long way to make sure that there is no reworking needed.


All of the other components are quite manageable, being only a couple of 0805 and 0603 resistors, and an inductor. I reflow soldered everything at the same time with a hotplate. It is worth noting that I did have to remove and replace the MP3423GG-Z once during the reflow process… tiny solder bridges formed between some pins, but carefully lifting it up with a pair of tweezers, and placing it onto the pads again got rid of those completely.

We may be tempted to “leave it off the board, wait for the solder to flow and then place the component onto the molten solder…” I am not too sure about the thermal stresses that that method may or may not induce in the component… so, I prefer having it heat up slowly with the rest of the components/ and then make a quick adjustment if needed… Comments on this anyone?

Testing and final thoughts

Testing the boost converter went without any problems. It delivers a stable 5.15v DC at the output, from an input voltage of 3.3v to 4.2v. I did not test it lower than that yet… Current output seems quite stable, and the voltage does not fluctuate under load ( I tested with 2 LED COB lights, each drawing 600mA, connected in series – thus 1.2A — That is definitely the maximum current that I intend to draw from this device, although it is rated at 3A

Ripple current seems to be within the 100mV stated in the datasheet.

In summary, I believe the device performs the intended duty that i set out to design. The assembly is a bit tricky due to the small size of the MP3423GG-Z, as well as my “not-so-good” eyesight. All that aside, I am ready to advance to the next phase of the overall project – revision 2 of the Single Cell 18650 Lipo Charger.

AI-Thinker AiPi Eyes S1 – Something interesting…


Ai-Thinker is definitely in my opinion one of the more interesting Chinese Electronics companies out there. Most of us will be very familiar with their NodeMCU ESP8266 as well as ESP32-S modules as well as Dev boards.

They also produce the very popular Ra01 and RA02 Lora modules…

What is less known about them is that they have a very active R&D department. Over the last few months, more than 8 months to be accurate, I believe that there seems to have been quite a dramatic change happening. Many RISC-V-based chips and modules started appearing on the AI-Thinker website, and I have also been fortunate to get my hands on a few of them.

The latest of these, the AI-M61-32S, is another one of these. The chip seems to be based on the BL-616 or BL-618 from Bouffalo Labs ( No spelling error there)

Information outside of China, and in English seems to be very sparse at the moment, but it does seem like there is a lot of potential here…

Let us take a closer look at the AiPi-Eyes-S1

The board is a very neat, but dense double-layer SMD assembly, with interfaces for a touch-screen, camera, speakers and microphones as well as USB ports and a firmware flashing port.

The kit also comes with an impressive number of peripherals, including a beautiful touchscreen, a small camera, speakers and microphones.

What are my thoughts?

As stated above, I find the kit very well designed, in the sense that it looks good.
The screen has very good resolution, and there seem to be enough peripherals to test out something… Why am I saying something?

1) According to the schematic, the screen and camera share GPIO pins, and can thus not function together – a definite minus point for me there.
2) There are NO free GPIO pins, and those that may be, very difficult to access – think small connectors etc
3) The demo program seems to cover some of the basic functionality of the chip, but not too much…

Let’s take a look at software support

At the time of writing, the kit has been sitting on my desk for just over 2 months. English documentation, beyond a quick guide to get the demo software running, is limited, if nonexistent.

The Touch Screen API is downloadable, but will take quite a while to decipher – It will be worthwhile though.

I have also received news from AI-Thinker that there is limited Arduino IDE support for the AI-M61-32S available. I don’t know to what extent, and will definitely explore that further in the future.

Further than that, there are links and examples for setting up some sort of API/SDK from Bouffalo Labs on the Ai-Thinker Website. Support documents seem once again to be sparse as far as English is concerned.

In conclusion

I see potential in the future for this new chip ( the AI-M61-32S ) or let’s just call it the BL-616 or BL-618 already. Ai-Thinker repackaged it into the popular ESP32-S form factor, so they seem to be hoping that it could be used as a drop-in-replacement for that.

Being RISC-V based, it is however still extremely new, and with all the various RISC-V standards currently out there, it will surely take some time to mature.

The development of an Arduino core to support it, is definitely a step into the right direction, if and only if, compatibility with existing libraries etc can be assured. That will definitely allow Makers and other hobbyists to start using the chip

As far as the AiPi-Eyes-S1 kit is concerned, well…
Full marks for aesthetics – it really does look good. As far as practical use or being fit for a particular purpose goes – not so much.

The board was clearly designed as a showcase of possible uses for the AI-M61-32S only. It was clearly not meant for use as a development board.

So, would I buy one right now? a definite NO on that. In the future, yes, maybe, providing that:

1) Documentation and information are updated and made easily available.
Slapping the words ” open source ” onto something does not mean that you can skimp on documentation. It is “open source” because the schematics are freely available, datasheets are available, and libraries and IDE support are available free of charge. “open source” does not mean to give someone a space shuttle, and not include the manuals, or at least a link to where to buy the manuals etc…

Xiao ESP32S3 Media Device Prototype

I use a lot of ESP32 modules in my projects, mainly because of the integrated WiFi and BT, but also due to their small size. There are however usually quite a few external components required, and sometimes, that can be a bit of a turn-off.

Having access to quite a few XIAO modules from SEEED studio, and with support for the ESP32S3 recently being added to ESPHome, my other goto for projects, I decided to create a simple prototype based on the SEEED XIAO ESP32S3. this module offers several attractive features, of which its small size is definitely a big plus. Add to that that it also has battery charging circuitry and quite a lot of flash memory, and it seemed like a winner…

Not that it doesn’t have issues of its own, the biggest being that you have to power it from 5v, and the absolutely super tiny flash and reset buttons.

Cost-wise, they are only slightly more expensive than the native ESP32 module, which, by the time you have added the external components, does not amount to any difference anymore.

I also wanted to test out some power-supply circuitry, so this seemed like a good project to combine those in as well.

What exactly is the project about?

It is a testbed for three(3) different things, with the first being the XIAO ESP32S3, with I2S sound as an ESPHome media device. That part, while working, is in my view not perfect yet, as ESPHome does not seem to be able to utilise the 8mb of PSRam available on the XIAO for use with the I2S Audio, yet anyway…

The second is having my, by now almost common, dc buck converter circuit directly on the PCB. I want to test that, in order to make sure that there are not too much noise being generated that could influence the ESP32S3, or, most importantly, the I2S module. A while ago, I built a custom I2S shield, and unfortunately, the power capabilities, or let’s be frank, the lack of sufficient power, turned that project into a big disappointment at any volume other than almost below 2%…

This will thus also serve as a way to revamp that idea, but with better power capabilities and more available current.

The third part is a direct result of the XIAO’s 5v power requirement. I reused my LM317G variable voltage circuit to provide power to the module. In my view, it would have been so much nicer if I could just supply 3v directly to the XIAO…

This also brings us to the battery charging capability. I would have loved to use that, but,
1) It seems that the battery voltage is internally stepped up to 5v and then back to 3.3v for the ESP32S3. comment anyone?
2) The available output (3.3v) does not provide a lot of current – surely not enough to drive an I2S module, does it? more comments, anyone?
3) I am unsure of any internal isolation in above mentioned charging circuit, thus, I was not willing to connect my own boost converter to the battery and use that to power external components…

So, until I get definite answers on these three, I won’t be bothering with powering the circuit from the battery… unless it is a big 12v one

So what is on the PCB?

3D Render of the PCB

As mentioned above, I had a few goals with this prototype. Let us take a quick look at the board and its components.

Starting bottom left, we have the DC input area. Here I chose to provide both a DC Barrel Jack, as well as a screw Terminal. Both can be used, but I believe the screw terminal will add a bit more flexibility in an actual installation inside an enclosure.

To the right of those, we have a 7-way header. This provides access to D7 to D10 on the XIAO, and, in my case, is labelled for use with the I2S module and a DHT11 sensor. ( you can of course use it for something else as well). The DHT11 header is on the far right in this picture.

At the centre-left, the components around U1 forms the DC-DC buck converter. This is set to supply 3.3v at a maximum current of 3A.

To the right of that, around TP1, is a jumper to that supplies the XIAO with 5v from U2 ( the LM317G ). It is important to note that you should leave this jumper disconnected at first power-up, and then adjust R9 while measuring between GND and TP1 to get a voltage of exactly 5v on TP1. This will prevent you from damaging the XIAO module. Once that is set, power down, and place a jumper on the center and right side pins. Make sure to NOT adjust R9 again with this jumper in place.

Center-right is the star of the board. The XIAO ESP32S3 Module ( marked U3)
Note the cutout for the USB-C connector at its top.

A reset button, marked RST, and two headers, one for I2C and another with additional GPIO pins completes the PCB.

Note that the XIAO ESP32S3 makes use of an external antenna on a short UFL connected cable. Make sure to attach this BEFORE you power up the board for the first time.

Manufacturing

Since I have made use of a SEEED Module, I sent this to SEEED Studio for manufacturing.

Seeed Studio’s Fusion service seamlessly marries convenience with full-feature capabilities in one simple platform. Whether you are prototyping or looking for a mass production partner or based on open source product customization requirements and other design manufacturing services, Seeed Studio Fusion service is catered to your needs starting with a simple online platform. https://www.seeedstudio.com/fusion.html

Assembly and Testing

I chose to assemble this project on my own. There was some issue with component availability, and since I have most in stock myself, decided to save time and do it myself.

Little did I know that I will be severely handicapped by a broken wrist a few weeks later. That little incident forced me to use my non-dominant hand, and resulted in an almost 3-hour-long assembly operation! All did however go well, and everything works as expected.

Testing went well, and after verifying all the voltages and connections, I uploaded some previously prepared ESPHome code to the board.

Due to the fact that this is still an early prototype, as well as some issues with ESPHome, I wont be releasing the firmware just yet. That will however happen in the near future.

Stereo I2S Shield – The next iteration…

Last month I started working on a Stereo I2S Audio shield for my ESP32-S development board. Those of you that saw that post will remember that I made some mistakes on the initial prototype, and had to repair it with a few “greenwire” connections.


The prototype shield also required the use of commercial I2S modules to be plugged into it, making for quite a cumbersome first iteration.

Stereo I2S shield stacked onto esp32-S dev board

I decided to do something about that, as the long-term use of this particular shield, as internet radio, with a further “dream” of using it as a remote media player for use from Home Assistant, is moving along well, with progress on the firmware being made slowly but surely.


I decided that, since the Audio Chips seem to be quite easily available, and are modestly priced, getting rid of the plug-in modules, and placing the chips directly on the shield seemed like the next logical step. I also broke out the gain pins of each chip and made provision for easily changing said gain with a jumper, individually for the left and right channels of the I2S Audio shield.

I decided to keep the logic level conversion circuit, as it worked well, as well as provided another layer of protection to the ESP32-S that drives the whole shield. ( These have recently been discontinued by AI-Thinker, but the Espressif version is still begin manufactured and supported).

The power supply section of the board remains the same as the previous version, with a dedicated 5v regulator feeding the Audio section, and a 3v regulator the logic level converters. (I may change this in future, as the ESP32-S board can easily supply the 3v required without overloading the regulator on the CPU board.

Current issues that are carried over from the initial prototype still remain though. The two I2S Audion chips seem to be QUITE power-hungry, pulling almost 2A of current from a 12v supply, with a modest volume of 10 out of a possible 100. This has been reduced down from an earlier 4A to 6A when using a different pair of 4ohm 3W speakers.

This is also one of the reasons for the separate voltage regulators on the shield.

Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Assembly

This project once again called for a stencil, as the QFN packages of the Audio chips are super tiny, with super tiny tracks and pads. A high-quality stencil definitely goes a long way in ensuring that just the right amount of solder paste is added to each pad. This also reduces the requirements for reworking a board with hot air to fix any solder bridges that might have formed.


The quality of a stencil says a lot about your PCB manufacturer, and in my case, I am extremely happy to say that PCBWay definitely delivers quality. Having used their services for close to 3 years now, I have not received a single faulty PCB or stencil at all. Yes, some PCB’s has had errors, but those were all MY errors. Design errors, not manufacturing errors.

Let us return to the assembly of this PCB, shall we…

As usual, the PCBs arrived very well packaged, and after a quick inspection and some random tests with a multimeter, It was time for solder paste and placing components, while listening to a piece of relaxing music… my way of relaxing…


After about 20 minutes of intense concentration, we have a PCB with all of the components correctly placed onto their respective pads, ready for reflow soldering.


I did things differently this time, by placing the QFN Audio chips in their positions at the same time as all the others. ( I usually drop them in place when the solder is in a liquid state, but with these, I was confident in the stencil, and as these chips were quite a bit more expensive than my usual projects [ over 3 USD each ], I wanted them to slowly get up to temperature, and spend as little time as possible at temperature as well. )


Reflowing was a success, and after inspection, no solder bridges were found. A detailed diagnostic with a multimeter with fine-tipped needle probes confirmed that there were no short circuits or bridges, and I could thus continue with the rest of the assembly – the various through-hole components, being mostly header pins, switches and a DC barrel jack socket.

The speaker wires were soldered directly to the PCB, due to the fact that being a prototype, I did not see the need to raise the cost even more by adding connectors onto a board that may not be used very long if it turns out that there is a problem somewhere.

Testing

The next stage was testing, using the software provided in the initial Stereo I2S Shield post. All went well, but, as mentioned above, I encountered the same high current draw issue, which resolved itself ( in a manner of speaking ) after I reduced the initial startup volume of the unit, and limited the maximum volume in the software.

I can now continue with firmware development, and sort out things like the rotary encoders for the volume and station selection, as well as look at adding an i2c display, and possibly a sd-card for stored music files.

Conclusion

The project is getting along quite well, and this iteration of the prototype did not have any design faults or errors. I am extremely impressed with the reliability of my PCB manufacturer, as their consistent quality products allow me to focus on design, and trust that whatever comes back from the factory will be exactly as I designed it.

While there are still quite a few issues to sort out on this project, I am confident that in the end, it will all turn out the way that I want it to.

ESP32-S in Arduino Form Factor

The ESP32-S is, at least in my opinion, one of the most versatile microcontrollers available to the Maker at this moment. It ticks almost all of my boxes for features required in a microcontroller, with a lot of gpio’s, WiFi, and Bluetooth, as well as a lot of storage space for code.

I do however have an issue with it, which I usually get around by designing a custom circuit board with a specific purpose. This is great for a project, but as most projects do not start on a custom-built circuit board, I am usually required to use a breadboard module. This is where my problems start. These modules are cumbersome to fit on a breadboard, to say the least, taking up a lot of space, and leaving very little space to connect to its pins with anything else.

Some of these modules do not even fit on the breadboard, making it necessary to hang one side off the breadboard or use two breadboards with a gap in the middle. I am quite sure many people can relate to this problem.

My second issue is that when you have done your breadboarding, and want to go to a permanent project, which does not always need a dedicated PCB, you are now required to either live with things on a breadboard, scary to say the least or have a “spider” with many modules and wires, in a box or partly on protoboard etc…

My Solution, the ESP32-S DEV Board, in Arduino Uno form factor

My solution

You can get your own copy here

While not the most elegant, personally I really like the size, and layout of the humble Arduino Uno, with its standardised pinouts, and a large number of addon shields available for the platform. This made me think, sure, there are already ESP32-based boards in this form factor available commercially, but why not make my own instead, as well as a few of my most used modules in a standardised shield form, to make my life just that little bit easier?

The picture above shows my attempt, with most of the GPIO broken out onto female header pins (except for the 6 gpio that are connected to the internal flash chip on the module).

The Blank PCB ( front )
PCB- Back

The PCB explained…

Power:
The board can be powered in two ways, either via the VIN pin ( at an optimal 7.0v DC – the LDO regulator can handle up to 15v, but I personally find that to stress it a bit hard ), which will use the onboard LDO voltage regulator to provide the needed 3.3v or from an external 3.3v PSU, which can provide a bit more current if needed…

There are also plenty of 3.3v and ground connections on the two 20-way headers to connect to other sensors.

Strapping Pins
All the required strapping pins are pulled up or pulled down, as per the datasheet, to 3.3v or ground respectively.

GPIO Pins
All GPIO pins are clearly labelled on the silkscreen to make it easier to use.
I did however not stick to the Arduino labelling convention, as I don’t always use the Arduino IDE, and the actual GPIO numbers are in my view, more useful then.

Flashing code to the board

It will be quite obvious that I did not include any USB-to-serial converter on the board, the reason for this being that, in my opinion,
1) it wastes space on the board
2) it is not actually necessary, as we can upload with an external uart adapter, or use OTA ( which I actually do most of the time )
3) In an actual project, that USB port is going to attract problems, especially if you give it to someone else to use…

A simple Arduino OTA sketch is available in the examples section of the Arduino IDE. It is easy to use and modify and does not need a lot to make it useable with your own sketch…

Antenna Cutout

As recommended by the manufacturer , I have chosen to place the chip inside a cutout on the top of the PCB, with no tracks nearby.

Figure 17: Keepout Zone for ESP32 Module’s Antenna on the Base Board

Although this is not the ideal “best position”, I found that this position worked well with previous designs, and have thus kept it at that.

General comments

As this board is mainly designed for prototype development, I did not bother with dedicated power connectors etc. I did however add proper wide tracks for all the power connections, an on-PCB-heatsink for the voltage regulator, as well as proper ground planes on both sides of the PCB, connected together with via-stitching where needed.

It is also very important to note that this is a 3.3v device. If you need to use sensors or peripherals that operate at other voltages, you will have to use external level converters.

Some assembly pictures

Schematic

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

You can get your own copy here

PCBWay

ATMega328 I2C Base Board

In this planned to be a short post, I will quickly take a look at a scaled-down version of the ESP-12E I2C Base Board. This one in particular has only two slots, without the dedicated ESP-Card slot.

The main reason for this PCB is that the original version was designed for easy prototyping and projects where enclosure space will not be an issue. This is especially true in the case of the actual project that this will be used in, as there are quite a lot of other, very bulky components, that all need to be fitted into a relatively small enclosure.

What is on the Board?


The board contains two 2×20 Pin Male Header slots, providing 12v, 3v, Ground and access to the I2C bus, as well as additional GPIO’s as provided by the module plugged into the slot. I have also decided to provide breakout access to these IO’s on the actual PCB.

This is a feature that was not yet implemented on the original prototype.
Additional Ground connections, as well as an I2C expansion port, used to interconnect to other Base Card modules were also added.

It is also important to note that the I2C bus is powered by 3v. Interface modules should take this into consideration ( mine does ).

Power is provided by an MP1584 Buck converter module.

What has Atmega328p to do with it?

I called it ATMega I2C Base Module due to the fact that I plan to design a custom ATmega328P prototype card specifically for this unit, with all possible IOs broken out to header pins. I found that this style of prototyping suits my development cycle quite well, as I really dislike using breadboards and wires.

As I try to reuse a certain PCB or design it to be as general purpose as possible, having access to ready-made modules that can be slotted into a base and programmed, really saves a lot of time.

Schematic

Manufacturing

Over the past eight years, PCBWay has continuously upgraded their MANUFACTURING plants and equipment to meet higher quality requirements, and now THEY also provide OEM services to build your products from ideas to mass production and access to the market.


The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

If you would like to have PCBWAY manufacture one of your own, designs, or even this particular PCB, you need to do the following…
1) Click on this link
2) Create an account if you have not already got one of your own.
If you use the link above, you will also instantly receive a $5 USD coupon, which you can use on your first or any other order later. (Disclaimer: I will earn a small referral fee from PCBWay. This referral fee will not affect the cost of your order, nor will you pay any part thereof.)
3) Once you have gone to their website, and created an account, or login with your existing account,

4) Click on PCB Instant Quote

5) If you do not have any very special requirements for your PCB, click on Quick-order PCB

6) Click on Add Gerber File, and select your Gerber file(s) from your computer. Most of your PCB details will now be automatically selected, leaving you to only select the solder mask and silk-screen colour, as well as to remove the order number or not. You can of course fine-tune everything exactly as you want as well.

7) You can also select whether you want an SMD stencil, or have the board assembled after manufacturing. Please note that the assembly service, as well as the cost of your components, ARE NOT included in the initial quoted price. ( The quote will update depending on what options you select ).

8) When you are happy with the options that you have selected, you can click on the Save to Cart Button. From here on, you can go to the top of the screen, click on Cart, make any payment(s) or use any coupons that you have in your account.

Then just sit back and wait for your new PCB to be delivered to your door via the shipping company that you have selected during checkout.

Using a Rotary Encoder

As part of an ongoing project, I recently designed an expander card for my ESP-12E I2C Base. I am referring to this device( Atmega 328P Base PWM Controller Card). At the time of writing that article, I have not released any of the code for the project. This is a very short post, showing one possible way to implement a rotary encoder onto that particular device. (It can also be adapted for other devices, of course)

Arduino Style Code for using a rotary encoder

// Constants and Variables
const int encFWD = 8;
const int encREV = 7;
int aState;
int aLastState;
int encDir;
int encTurned = LOW;
int encLastState;
int encValue = 0;
int lastEncValue;
const int encInc = 10;

unsigned long lastEncDebounce = 0;
unsigned encDebounceDelay = 50;
const int encBtn = 9;
int encButtonState;
int lastEncBtnState = LOW;
int EncBtnValue = LOW;
int encBtnState;

void setup() {
  //Rotary Encoder
  pinMode(encFWD,INPUT_PULLUP);
  pinMode(encREV,INPUT_PULLUP);
  pinMode(encBtn,INPUT_PULLUP);
  // Init the pins in UNPUT Pullup Mode
  encTurned = LOW; // Flag for encoder

  encLastState = digitalRead(encFWD);
  //Serial
  Serial.begin(115200);
  //Status LED on D13
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
}

void loop() {
  lastEncValue = encValue;
 //Handle the Encoder Push Button
 encBtnState = digitalRead(encBtn);
 if (encBtnState != lastEncBtnState) {
    lastEncDebounce = millis();
 }
 if ((millis() - lastEncDebounce) > encDebounceDelay) {
    if (encBtnState != encButtonState) {
        encButtonState = encBtnState;
        if (lastEncBtnState == LOW) {
          EncBtnValue = !EncBtnValue; // Toggle the button Value
        }
    }
 }
 lastEncBtnState = encBtnState;
 // Handle the Rotary Encoder Dial
 aState = digitalRead(encFWD);
 if (aState != aLastState) {
    if (digitalRead(encREV) != aState) {
       if (encTurned == LOW) {
          encLastState = encTurned;
          encTurned = HIGH; // Set Flag
// Setting this flag will get rid of double value entries caused by contact
// bounce inside the encoder. I found it easier to implement this way
// as opposed to using software debouncing as with the button

       } else {
          encTurned = LOW; // Set Flag low
// This will ensure that the value is increased only once per "click"
       }
       if ((encValue < 300) && (encDir == 0)){
          if ((encLastState == LOW) && (encTurned == HIGH)){
            encValue = encValue + encInc;
            encDir = 1;
          }
       }
      
    } else {
      if (encTurned == LOW) {
        encLastState = encTurned;
        encTurned = HIGH;  
      } else {
        encTurned = LOW;
      }
      if ((encValue > 0) && (encDir == 0)){
          if ((encLastState == LOW) && (encTurned == HIGH)){
            encValue = encValue - encInc;
            encDir = 2;
          }
      }
    }
    encLastState = encTurned;
}
aLastState = aState;
encDir = 0;
// Print Some Status
if (encValue != lastEncValue) {
  Serial.print("Encoder Value Changed from ");
  Serial.print(lastEncValue);
  Serial.print(" to ");
  Serial.println(encValue);
}
digitalWrite(13,EncBtnValue);



}

I hope that this will be useful to somebody.

Fix Driver Issues with CH340G on Ubuntu 22.04 LTS ( and possibly other Linux Distro’s)

Having recently upgraded to Ubuntu 22.04 LTS ( After the local power-company managed to destroy my HP ML350-G6 server, with a UPS installed, with a power surge or something – still no answers — 🙁 ) on a new more modern Desktop computer, I found some intermittent issues with my ESP32 / ESP8266 and Arduino boards… The Serial port would not work at all ( on devices with CH340G chips )…

A quick online search found the following, link to the original article here,

Instructions for Ubuntu 22.04 LTS x86_64

Get the currently installed kernel version:

sudo apt-get update -y
sudo apt-get install neofetch -y
neofetch

I think it came with Kernel: 5.13.8-...

Install latest kernel (GUI solution):

sudo add-apt-repository ppa:cappelikan/ppa
sudo apt-get update -y
sudo apt-get install mainline -y
sudo apt autoremove -y

Run mainline and select the latest kernel (I tried, as of 16/05/2022, kernel version: 5.17.8-051708-generic)

After installation and reboot, run neofetch again and check if the latest linux kernel is loaded.

Install build tools (if not installed already):

sudo apt-get update -y
sudo apt-get install build-essential dwarves dkms make cmake -y
sudo apt autoremove -y

Install and fix CH34x drivers:

As per the guide here in sparkfun and https://github.com/juliagoda/CH341SER

git clone https://github.com/juliagoda/CH341SER
cd CH341SER
sudo make clean 

# The Makefile looks for vmlinux in a certain location (check that cat Makefile)
# we need to move that
# https://forum.proxmox.com/threads/kernel-module-not-found-when-compile-skipping-btf-generation.100974/
cp /sys/kernel/btf/vmlinux /usr/lib/modules/`uname -r`/build/

sudo make
sudo make load
lsmod | grep ch34*

# NOTE: if other/prev ch34x drivers are loaded (and you know they were not working), then you can unload them by:
sudo rmmod ch34x

# Plug and unplug your CH340 device again on the USB port
sudo dmesg

# plug un-plug your device and then verify:
ls /dev/tty*

# make it accessible
sudo usermod -a -G dialout $(whoami)
sudo chmod a+rw /dev/ttyUSB0 # if /dev/ttyUSB0 was assigned

# To unload:
sudo rmmod ch34x
# or 
sudo make unload

Disable some conflicting services.

It came out during my test, at least on my machine, a service for some external brail hardware was conflicting with the drivers. I saw that in sudo dmesg

... ch340 1-10:1.0: ch341-uart converter detected
... usb 1-10: ch341-uart converter now attached to ttyUSB0
.
.
.
... usb 1-10: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1
... ch340-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0

It was apearing and dis-appearing. so I tried to hunt the service as such:

sudo systemctl list-units | grep brltty

I then disabled it:

sudo systemctl stop <brl service name or other service that is interfering and not needed>
sudo systemctl disable <brl service name or other service that is interfering and not needed>
sudo systemctl mask <brl service name or other service that is interfering and not needed>

for f in /usr/lib/udev/rules.d/*brltty*.rules; do
    sudo ln -s /dev/null "/etc/udev/rules.d/$(basename "$f")"
done
sudo udevadm control --reload-rules