Author Archives: volker

ESP32 General Purpose with BMS

24 Mar 22
volker
No Comments

For most of my projects I use an ESP32. Some of the projects are meant to run independently on Battery (LiPo). This implies the use of a BMS to charge the LiPo and protect it from undervoltage.

For a long time I used one of those

You got connectors for input power via USB or solder connection. Two connectors for the LiPo and finally two connectors for the Power to the ESP.

In order to avoid having to use a second board for BMS in my projects I designed a new PCB for my ESP32 containing the BMS.

In order to keep the size of the board small, I designed the board to use the second side of the PCB.

The Schematic of the BMS part is identical to the dedicated BMS board (use the TP4056).

 

 

 

ESP OLED Mini

01 Aug 21
volker
No Comments

Those 0.96″ OLED displays are a great way of displaying information on a small area.

Alone they do not make sense so usually a controller is needed to control or measure “things” and display results on the display.

So I came upwith the idea to have a bundle of those being as small as possible (handleable by myself).

I designed a small PCB just able to connect to the OLED, host the ESP and provide a few I/O lines. Since the OLED is I2C anyway one way of interfacing was alread given.

I actually designed two boards. One for the ESP8266 and one for the ESP32.

Schematics for the ESP8266 looks like this.

It is basically very simple. An ESP, the OLED, some solder bridges to be able to deal with various types of the OLED. Some OLEDs hav a pin order of SDA, CLK, GND, VCC while others switch VCC and GND => SDA, CLK, VCC, GND.

By ading a “blob” of solder to some solder bridge, either one can be used.

For the I/O pins there was not musch space left on the PCB, so the pins only got a small pad just big enough to solder a little wire to them.

The PCB ( for the ESP32 version) came out like this.

Still 2 Layer. The ESP Board fits beneath the OLED board.

This is the ESP32 Board. You can see the tiny pads for I/O 25,26,27.

And the ESP8266 Board. The I/O Pads are not separated from the pins, but they just extend the pad of the ESP8266 pins  ( I/O 12,13,14,16 and Analog)

This is the soldered ESP8266 version

Using my 3D Printer I gave them a nice little housing. The case also contains a LiPo Charger, a little Lipo (300mA/h), a regulator X => 3.3V and a switch (On/Off)

With a little programming it shows some measurement values from one of my remote sensors

 

 

 

Remote Power monitor

29 Jul 21
volker
No Comments

I recently had the problem that I wanted to measure the power consumption of my weather sensor under real life conditions. Fundamental question here: Can a solar cell with an attached Lipo and an BMS supply enough energy so that the sensor can run “infinitely” without externally supplied power.

In order to measure this I needed a device able to measure power (implicitly also voltage and current) being operated remotely (potentially anywhere).

To measure Power/Voltage/Current I recently used an INA219A in another project (I8Driver) and was quite satisfied withit. To control the INA’s I decided for an ESP32 (since I have a lot of experience with it)

For programming the ESP32 I decided to integrate a USB connector that can also supply the powermeter with power. For the USB to TTL I do with CH340C Chips. Less pins that an FT232. I have good experience with it.

Programming the ESP requires a control of the reset pin (EN) and the Flash Pin (Gpio 0 ) of the ESP32. Luckyly platformIO by default handles it nicely with UART interface. It controls the RTS and DTR signals in the correct way to be used as RTS= Reset and DTR as Flash. Both are active Low, so a pullup resistor (10k) ensures that the pins are in a defined state. In typical ESP32 Boards of the shelf the control of reset and flash is a bit more complicated and requires additional transistors since the boards have buttons for a manual interaction. Since my solution does not have reset or flash buttons, there is no need for it.

In case there is enough power (Landline) for the remote powermeeter it might be nice to have a display so I integrated an 0.98″ OLED

After the first prototype it turned out that a button to be able to enter a maintenance mode is very useful. So is an LED in case the OLED is not used due to power limitations.

In the end I came up with the following design

Here some pictures

 

 

Regarding the software:

WiFi Handling

The Power Mon is configured via WiFi. It can operate in station mode (creating its own accesspoint) or it can attach itself to an existing WiFi router (if configured accordingly).

Configuration is done via simple HTTP GET requests providing the parameters as query parameters.

http://172.2.0.1/wifi-cfg?ssid=MYROUTER&pass=secret

This example defines the wifi connetion for a WiFi router. If the power mon is in accesspoint mode, the IP to use is 172.2.0.1.

Destination for measurement results

Power mon measures values in intervalls. The results can be transferred to the following destinations:

MQTT Server

Via the WiFi config a MQTT server (Host, port, user/password (optional) and SSL (optional) can be configured. If the MQTT server is configured and the ESP32 is able to reach an exiting WiFi network(router), it will publish its measurements to the MQTT server

REST(ish) Server

Optionally a RESTish server can be configured. In this case the ESP32 will issue GET requests with query params to the configured server if the ESP32 was able to connect to a WiFi router. The REST afficionados will state that it is not REST since the request is GET and not POST, but the implementation of GET is just easier and we are in an embedded environment.

Local

In case the Power Mon has no connection to any server, the measurements can be stored locally in the Flash Mem of the ESP32 (SPIFFS).

Deep Sleep

The Power mon can be set into deep sleep between its measurement intervall. This lowers the energy consumption of it.

Maintenance Mode

In its regular routing there might be conditions that Power Mon cannot be reached via WiFi ( if only Local measurement storage is wanted). In order to bring Power Mon into a state where it can be configured, the maintenance button exists.

Pressing the button while booting up brings Power mon into Maintnance mode. It does not do any mesurements then. Only Wifi ist started and it tries to reach a configured access point.

 

 

 

Mini-Meditation-Lamp

13 Feb 21
volker
No Comments

A friend of mine builds Bascetta stars as a christmas decoration. This link gives you an idea what I am talking about: http://www.mathematische-basteleien.de/bascetta_stern.htm

Us together came the idea that a light source within the stars would look even better than the stars themselfes.

Since I like to play around with electronics, I developed a little circuit consisting of a little programmable controller and 3 LEDs. The PCB for it is quite small and fits easily into those stars. Almost all people who saw them wanted to have them and we indeed sold some of them.

I designed a little PCB (thanksto DesignSpark, great tool, guys)

Finally it looks like this:

 

I thought to myself that those stars are basically meant as Christmas decoration and not for the rest of the year. So I came up with the idea to create a mobile with different illuminated bodies (not only a Bascetta star). I googled and found out that some very interesting bodies are the so called Platonic solids=> https://en.wikipedia.org/wiki/Platonic_solid

I found a german company (Herrmann Lehrmittel) => http://www.herrmann-lehrmittel.de selling those solids as demonstration/illustration for students.

In order to be able to place my little PCB into those solids, I needed to get them in a way that I could assemble them myself.  Gluing them together surely is a very tricky thing so the best would be to get them as half shells. I wrote an e-mail to the company and the owner answered me directly. In a telephone call he told me that he also had the idea to bring some light into his solids. He even had talks with his supplier of the plastic granulate to try out some opaque. Mr. Herrmann then was extremely friendly and sent me some samples for free to check out how it could work with my LEDs.

Before I really assemble the half shells finally, I will do some tests like putting the shells together by some adhesive tape. I made a video to give you an impression how the first prototype looks like. It is not a beauty and just a proof of concept.

Click here to see the video

 

ESP8266 with Matrix Display

12 Feb 21
volker
No Comments

Some day I stumbled about 8×8 Matrix LEDs with an SPI interface. While I started with a single 8×8 Matrix for little test purposes, I found out that there are also quite cheap displays with 4 arranged displays offering 32×8 pixel. I combined 2 of them to implement a little clock, driven by the internet (via time server ntp).

The driver was a ESP8266. I created an extra little controller board to attach the esp directly to the LED. This worked out well.

Some day I developed the idea to couple the esp8266 very closely to the matrix display to create little nifty devices.

Phase one: Find out how are the 8×8 matrix modules addressed by the gadgets you can buy?

It turns out: MAX7219 ist the answer. One application for this chip is to drive 7 segment displays with 8 digits. By nature of the 8×8 LED Matrix modules you can buy, you can also use the chip to address a single 8×8 Matrix module. The MAX7219 can be chained. that way several 8×8 modules can be packed together.

The internet is full of schematics how to couple the 7219 with the LED matrix.

As said before the interface to the 7219 from the controler side is SPI and also quite simple.

The overall schematics for the little device ended up to be:

The schematics consist of a voltage regulator to transform 5V (most likely provided by an USB interface) to the 3.3V the ESP8266 likes. The regulator is a AMS1117 (3.3V).

The ESP got a programming interface J1 (details in the previous post). For the connection to the matrix SPI is used (CS, MOSI, CLK) MISO we do not need since the 7219 does not hand back anything to the ESP8266.

A little detail: As Matrix Modules “Common Cathode” ones are required.Do not ask me why they are called common Cathode since the anodes are also connected, so also common.

R2 seems to determine the current that drives the LEDs. The internet told me that 10k would be a good value. I tried and it works with red and blue matrixes. The brightness of the LEDs is handles via PWM by the 7219 anyway.

R3 and R4 and pullups for the programming adapter and I also chose 10k. R1 I found in a few schematics on the internet it is a pulldown for the chip select. In fact it did not seem to be necessary so on the pcb I usually do not solder any resistor to it.

To be able to maybe attach some extra “things” to the module I added a few additional ports (J4 could be used as I2C ) when 3.3V and GND istaked from J5. J6,J7J8 are just “extensions to the esp pins, since for a a through hole connector I just did not have enough space on the PCB.

J3 is the incoming Power supply. It does not necessarily have to be 5V since the LED Matrix also works with less voltage (e.g. 3.3V), but the primary use case is to have it attached to USB.

An option will be to drive the thing via LiPo. The AMS1117 is not the best choice here since it it not a good LDO regulator, but it will work.

J2 is an output connector that could be used to attach cascaded Matrix modules.

Although the schematic looks extremely simple, the tricky part was the size of the board. It must not be bigger than the dimensions of the LED Matrix itself.

So the layout required to be my fist 4 layer layout.

I started with burried viasuntil I found out that JLCPCB does not support that. Vias are always though. This complicated the design a bit.

The PCB came delivered and looks like this:

You can seeone pin of the ESP8266 is a bit longer. It is the analog pin. I should be able to solder directly to it if possible. As described before IO16 and IO12 are also not through holes for reasons of space. I should also be able to solder directly to then only on this side without a though hole.

When soldering the components to the board I alsway start to solder the ESP8266 part. Somehow getting MAX7219 Chips is harder than ESP8266. So if I screw something up in the ESP8266 area, I did not waste a MAX7219.

Voltage Reg and the pullups for Reset, Flash and the MAX7219 Current control are soldered.

Next time I will use the KiCad “Hand Solder Pads”for the 1206 pads. they are definitely better to solder.

Her majesty, the ESP8266 residing on the other side of the PCB. On top of it, the 2.54 Header for the programming cable.

After having done a test programming, the MAX7219 as soldered.

The Matrix LEDs will be plugged in to the one row sockets above and below the MAX7219.

 

The final result looks like this:

The one row socket connectors are optional. A replacement of the LED Matrix will not be possible so easily if necessary of course.

Very compact design.

 

Programmer / Serial Interface for ESP8266 and ESP32

12 Feb 21
volker
No Comments

On the Market you can find an incredible amount of boards with ESP chips on them made for Makers.

Using those boards in a Dev environment is easy because you can simply plug them into your breadboard and use the on board USB to directly program them via Arduino or PlatformIO.

When you leave the Breadboard Area and start projects where the ESPs are built into some case and you intend to reprogram the ESPs while in the case, it is very hards to design the case in a way so you can reach the USB of the ESP Board.

So I intended to split the functionality of programming and the actual ESP processor into 2 boads. Programming shall be easy to build into a case and the ESP also shall be able to end up wherever suitable in the case.

I had a look at the various USB to TTL solutions on the marked and did not find a single one fitting my needs because they ALL lack the necessary UART pins.

How to program a ESP?

Basically it is very simple: Pull the GPIO0 to LOW and reset the chip via a short Low on the Reset (EN) pin. After that, the chip is able to be programmed via TX/RX.

How to control the GPIO0 and Reset Pins. A look into the documentation of PlatformIO, they use the UART signals RTS/DTR for that. RTS is for Reset and DTR for “Flash”.

And exactly those signals are missing in the most UART adapters.

So I  designed my ESP boards in a way to have Reset and GPIO0 pulled up to +3.3Volts, and have RTS and DTR pulling them to low in the right sequence.

This is basically what the most ESP Prototype boards do. They usually have an additional logic (2 transistors) built in there because most of them also have pushbuttons to reset or flash the ESP. In my case I do not need that, so the simple pullup solution will do.

The next question to solve was: Which USB to UART converterchip to use? The defacto standard is the FTDI232 Chip. I tried it and I got it working, but it has a lot of pins and the TSSOP package has quite minimal distances between the pins (not easy to solder by hand).

A great alternative ar the CH3X0 chips. I used CH330N for projects not requiring DTR/RTS, just RX/TX. For DTRand RTS I switched to CH340C.

I directly went for 3.3V supply to the UART since ESPs like 3.3V. The 3.3V is generated by an AMS1117 for 3.3V.

Usign KiCAD leads to the folloging PCB

Get it manufactured by JLCPCB and you end up with this PCB in your Hands.

R1 by the way is an optional Resistor to couple Ground against the shielding of the USB. The internet was not clear how to handle shielding the USB. Some connect ot to ground, others don’t

 

 

 

RS232 <=> Bluetooth Converter

25 Oct 20
volker
No Comments

 

From time to time I deal with devices only offering a RS232 to interact with them in a “programmatic” way. Some of my multimeters only offer RS232 since they are old.

My computer does not offer a RS232 interface anymore, just USB. One solution I came along was to connect them via RS232 to Bluetooth. I checked out a few modules exiting on the market.

I was not happy with them. Connection problems, crashes, etc. made me think about my own solution.

I came up with this little board I designed:

It is basically very simple.

The RS232 connection is done via the DSUB 9 connector. Only RX,TX,GND is used since most of my devices do not offer CTS, DTR etc.

The RS232 signals are handled by the standard Chip MAX232 (bottom picture) and the typical  Caps to generate the required voltage levels for RS232.

The signals from the MAX232 are fed into a HC-05 module (top picture, lower part). A HC-06 would also have been possible, but I had several HC-05 at hand so I used them.

A few things I had to consider.

Where to get the power supply from. RS232 does not offer any type of supply voltage. Some people use DTR, CTS etc. signals to derive a power supply from, but I regarded this as too risky. So I choose to have a USB micro plug for the power supply. USB Power is typically always around where I use the module. Some internet sites say the HC05 is capable to run at 5V, but I tried to be sure and added an AMS1117 (3.3V) Voltage regulator to power the HC05. It is optional and by just shortcutting 2 pins, the HC05 would run on 5V.

How to configure the HC-05 for baud rate etc.? I decided to just have a jumper to connect the key pin of the HC05 to VCC. Several internet sites say that the “key” pin needs to be GND while powering up, but my modukles require VCC in order to go to AT Mode. Being in AT Mode allows you to send AT commands to control communication settings (Baud, Bits, etc.), the name of the device (BT Name) and the pin code for pairing. Just plug the jumper while powering up, then remove it again.

 

 

ODroid GO Tricorder Project reaches custom PCB Phase

21 Oct 18
volker
4 comments

 

 

ODroid created a fantastic Product with the ODroid GO.

A nice compact device with an LCD, Buttons, Speaker, a ESP32 from Espressif AND an expansion board.

Although the Hardkernel Wiki already gives examples how to use the device for your own hardware projects, it seems that almost all people regard it as a “Gameboy Clone”.

For the Odroid GO Tricorder project I just waited for a device like the GO. The Idea was: Bundle a set of sensors and provide it with some nice interface.

The GO provides 2 Pins at the expansion board that can be used for I2C interfacing. All the sensors for the Tricorder had to have that interface.

Ingredients

Sensors

The following Sensors are built in:

BME280

A sensor that can measure ambient temperature, humidity and pressure.

VEML6040

It can measure light in red, green and blue, white , in lux and as color temperature

VEML 6075

Measure UV (A/B) radiation and provide a UV Index

BNO055

Measure Roll, Pitch, Yaw, Accelleraton in X/Y/Z, Gyroscopic measurements also possible (rotational forces)

CCS811

It meausures Gas concentrations (ppm, ppb) of CO2 (Carbon Dioxide) and VOC (Volatile Organic Compounds)

VL53LOX

A so called “time of flight” sensor that measures distances up to 120cm via laser

MLX90614

An infrared Sensor cabable of measuring temperatures in the range of -70 to 380 degree Celsius

Mics-6814

Another Gas Sensor able to detect carbon monoxide, nitrogen dioxide, ethanol, hydrogen, ammonia, methane, propane, iso-butane

I2C Switch

I decided to use the VEML 6040 and the VEML 6075 Sensors because their outputs seemed quite reasonable (realistic).

The drawback was that both sensors require I2C address 0x10. Because of this I needed a I2C switch TCA9543A (2 port).

I split up the sensors into two groups (according on how I wanted to place the sensors on a designed PCB  for easy routing)

Software

Platform IO (VS CODE)

Programming the ESP32 can be done via the ESP-IDF, an C/C++ SDK from Espressif. I personally regarded it as “too low level”, so I decided to go the Arduino way since I had more experience with this.

Years ago I stared with the Arduino IDE, but then Platform IO crossed my way. You can also code Arduino style with it, but it just looks better. It can be used as plugin for the MS VS Code Editor which I also regard as a very nice one.

For all of the sensors there are libraries that can be used under Arduino. Some of them I had to adapt since most libraries assume that the sensor they are made for is the only device on the I2C bus, and some are not directly able to deal with an ESP32.

DesignsparkPCB

It took some while to gather all the sensors from China (EBAY is my best friend now), and for quite some time a prototype on Breadboard was used to develop the software, but from the beginning it was clear that there has to be a PCB for the Tricorder.

Year ago I was searching for a good tool to design PCBs. My choice fell on DesignsparkPCB. You can draw Schematics and derive PCBs from it. A very important thing is to easily create your own Components, since it is very hard to get component libraries for all you need.

paint.net

The screens for the tricoder had to be drawn as background image. After having tried a few freely available paint programs I stuck with paint.net

Photo

The photos were taking with my Samsung S8

Stages of the hardware development

Breadboard

The breadboard was the first stage to put things together easily. In the picture all the sensors are removed already, only the wiring is left.

First soldering

   

In this prototype not all sensors were integrated. I just made it to get a feeling of the handling, holding the tricorder in hand.

 The PCB (Rev. 1)

        

As described above, the PCB was designed with Designspark. Since I am not a fan of having a lot of chemistry in my house, I had the PCB made by a company.

To make it cheap, I did not do it with solder resist.

Assembly

        

The assembly and a first test revealed that I did a mistake in the PCB design. I actually wanted to have the BME280 on the other side.This cost me one BME280 because it burned being assembled on the wrong side and I had to place the next one on top of the BNO055. Well, not really a big deal.

Plugin Time

The Software

As mentioned above, my choice to develop the software was PlatformIO as a plugin for the VS Code editor. The code is written in “Arduino” using C++ for some of my own libs to handle the screens.

As a tricorder it should look like Star Trek, so I got me inspired by some screens I found via google, just search for “Star Trek LCARS”

LCARS = Library Computer Access / Retrieval System ( for the non Trekkies)

I devided the Sensors into several screens that can be switched via the A/B buttons of the GO.

Init

      

The sensors (at least some) need to be initialized before we go. (Uhhh, should have cleaned the screen before making the pictures).

Ambient

The first screen shows some ambient values (Temperature, Humidity, Barometric Pressure, Light intensity in Lux, UV Index) those Values come from BME280, VEML640, VEML6075

Light

For Light measurements LUX is not the only interesting value. The composition of the light might be interesting (percentage of red, green, blue as bargraph), the color temperature can be derived from that distribution of the base colors.

Gases

The various gases are presented here. all of them (except VOC I think) are given in PPM (parts per million).

Since the names of the gases did not fit on the screen I took their chemical formulas.

As described by the datasheet the MICS gas sensor needs a heat up phase before its values become accurate. The Values for C3H8 and C4H14 (Propane and Butan) still are too high. There are no such gases in my home I hope.

The page combines 8 Gases from the Mics and 2 Gases from CCS811 (CO2 and VOC)

Distance

The distance is given in centimeter. The VL53LOX is capable to go for 120cm MAX. I must say, the precision is quite accurate accoring to my ruler.

Having the distance given in Inch requires some config or button to switch it. Currently the project is only for mebeing European => The Metric System RULES!

Temperature

The Temperature is not the one from the BME 280 (Environmental) its the temperature directly ahead of the tricorder. Its more or less like one of those Pistol shaped thermometers.

Units are Celsius.

Orientation

The display for the orientation is the hardest to design in 320×240 Pixels.

How to display Roll/Pitch/Yaw?

I am not really satisfied with it, but for a first shot it seems ok.

 

Playing around with Odroid-GO

10 Sep 18
volker
No Comments

Odroid GO is a fantastic device for those dealing with espressif chips (8266/ESP32).

While the big focus is on gaming, the device also got a 10 pin expansion header to support I2C and SPI.

Having a build in graphical LCD and several buttons, this makes the device an ideal playground for own projects including own hardware.

 

Checking out on Docker Swarm

28 Jul 17
volker
No Comments

I am currently checking out on Docker Swarm. All not really hard. Tricky part is to get Hazelcast to work there. Another story is to get some logfiles generated within a container be visible all over a network