STM32F103C8T6 Pin Tester to check your soldering

How good are you at soldering?   Here is the STM32F103C8T6  microcontroller board that I use  and have to solder all of the pins.

STM32F103C8T6 Front View

Sometimes when I solder pins to the  board, the connection looks OK and even tests OK with continuity on a multimeter.  However, the solder connections even though they pass those two tests sometimes don’t fully connect the pin to the board.  More information about common soldering problems can be found  here.

I came up with a way to better test those connections. It is an Arduino sketch that tests all of the pins to make sure they work when connected to an LED.

Here is the STM32F103C8T6 pin tester to check your soldering sketch:

The sketch uses an array called ‘pins’ with a list of all the STM32F103C8T6 pin names. The setup code sets all the pins to output and the main loop just toggles the pins with a 100 millisecond delay. This makes sure that the LED will toggle ON/OFF if the connection is working properly.

Make sure to use the STM32F103C8T6  Arduino Core from here as it supports using all the pins  as output and testing with an LED.

Once you load it into the STM32F103C8T6, then  just make sure it has power and ground and connect an LED to each pin in succession and make sure it lights up. If it doesn’t, then you know it is a bad connection. This is also a way to test any connection wires that need testing. Sometimes they are ‘bad’ too, due to defects in manufacturing or just usage.

STM32F103C8T6 Pin Tester

5 Way Navigation Button connected to an Arduino or STM32F103C8T6

A 5 way navigation button actually has 7 different navigational settings. It has a lot of functionality in a small package.  The ‘button’ on it can be moved/pushed in 4 directions ( labeled up, down, left, right)  or pressed down. There are also two other switched buttons labeled ‘Set’ and ‘Reset’ for a total of 7 functions. Quite handy!

Here is what it looks like:

5 Way Navigation Button

COM is wired to ground. Each of the other navigation pins are wired to a pin on the STM32F103C8T6 or Arduino . Here is what the wiring looks like when it is wired to an STM32F103C8T6.

STM32F103C8T6 with a 5 Way Navigation Button Here is the Arduino IDE code for the STM32F103C8T6. When the button is moved or pressed it will light the LED and display the action on the serial console. Note that the input pin is initially configured as INPUT_PULLUP which makes the pin HIGH. When the button is pushed/moved it will make the  corresponding pin go to ground (LOW).

Here is the code for an Arduino Uno using Digital Pins (2,3,4,5,6,7,8):

Here is a top and side view of the button so you can see it looks somewhat like a joystick.

5 Way Navigation Button5 Way Navigation Button

PIR Sensor and Relay Switch to turn on a Light

Ever wonder how a motion detector is used to turn on a light? Take a look at this graphic (made with Fritzing). It shows the circuitry that uses an STM32F103C8T6 microcontroller to control a PIR sensor and relay switch to turn on a Light.

PIR Sensor and Relay Switch to turn on a Light

Get the Fritzing source code for the above image HERE (in case you would like to modify it).  Shown below is the code for the STM32F103C8T6 microcontroller to be used in the Arduino IDE.

When motion is detected by the sensor, the relay is turned on which completes the mains circuit. Then, what ever is connected to the relay (like a light) is turned on. The motion detection is also shown by turning on the led and logging to the serial port.

To use this code in a practical situation, remove the serial port messages and change the length of time the relay switch is on.

An STM32F103C8T6 based MIDI Controller for MIDI2LR

For those of you who use Adobe Lightroom,  there is a way to use a MIDI hardware ‘box’ to control various Lightroom actions. I am told that once you use the hardware controls you will never want to go back to the software ones. There is a Lightroom plugin called MIDI2LR which interfaces various MIDI ‘boxes’ to  Lightroom. The MIDI box sends MIDI Control/Change commands to MIDI2LR which then changes them into Lightroom actions. More info on MID2LR can be found HERE.

There are several commercial MIDI controllers which do work with MID2LR, however, features and functionality differ. Since the whole idea for using the hardware controls is ease of use and productivity, I would think that Lightroom enthusiasts would want a means of creating a custom hardware solution.

It is actually relatively easy to create an STM32F103C8T6 based MIDI Controller for MIDI2LR. As a proof of concept, I built one on a breadboard to demonstrate what can be done. Here is the design layout:

An STM32F103C8T6 based MIDI Controller for MIDI2LRDownload the Fritzing diagram source code HERE.  And here is what it looks like all wired together:

An STM32F103C8T6 based MIDI Controller for MIDI2LR

The two buttons next to the display are used to control menu selections. The menu is used to set whether the buttons send MIDI Notes or Change/Control commands and also is used to select up to 5 channels.  Therefore with the 8 buttons  x ( 5 channels) x 2 (Note vs. CC commands), there is a possibility of  80 different commands to send to MIDI2LR.  The 5 channels is arbitrary and of course changeable in the code so possibilities are only limited by practicality. When a button is pressed, the MIDI CC/Note is sent to MIDI2LR and displayed on the OLED screen.

The code below was developed and sent to the STM32F103C8T6 via the Arduino IDE:

The Arduino IDE was used to develop and program the STM32F103C8T6. The IDE was also customized to use the Arduino Core for STM32 MCUs. Also note the use of the Adafruit graphics libraries to control the OLED display.

Once the code is sent, just plug in the STM32F103C8T6 via an USB-micro cable to your Windows 10 PC and it will be added as an audio device (no drivers are needed as it is automatically recognized). Install the MIDI2LR plugin and while in Lightroom you can test out the button functions and customize the functionality.

You might say that buttons are OK but dials (rotary encoders) are what is missing.  You are right, that is what is being planned for in the next step of this project. Stay tuned!

WebRTC Phone Calls via Asterisk

Are you ready for another off topic article on WebRTC?  This one is titled WebRTC Phone Calls via Asterisk. I have written about Asterisk before (HERE) and that article did have something to do with microcontrollers  😎  Asterisk is an open source full featured phone system (PBX). In my last post about WebRTC, I showed how to do video/audio sharing via WebRTC. This article shows how to turn your Web browser into a (tele)phone (using the PC audio devices and WebRTC Javascript code). With the code provided you can make and answer calls through your Asterisk system via the Web.

Of course you need an Asterisk system up and running for testing this. There are many helpful tutorials on the internet to help with that. The Asterisk wiki also has very good documentation on installing and customizing Asterisk.

The article to customize Asterisk for WebRTC is HERE. Basically, there are three configuration files that need changed to make WebRTC Phone Calls via Asterisk.  Usually these files (httpd.conf, extensions.conf, sip.conf) are found in the /etc/asterisk directory after installation .

For httpd.conf, you will need to select a port for both TLS and HTTP.  You will also need a valid SSL certificate. I am using one from In the example below I am using port 7070 for HTTP and 7079 for TLS.

For sip.conf , you need to specify the parameters for the phone (I am using extension 5099):

Note that WebRTC will be using the websocket protocol for communications to the Asterisk server.

In extensions.conf is where you specify the context and dialing plan so that the WebRTC enabled phone can make and receive calls:

Note: The dialing plan is where security is very important because it specifies who the  ‘phone/user’ is allowed to dial  and also what is allowed to call it.

Once Asterisk has been configured, the WebRTC code can be  accessed to try a call.  To implement the SIP and WebRTC protocols I have chosen to use the JSSIP Javascript library code (HERE).

Download  the JSSIP library and  place it (jssip.min.js) in the same Web directory as the two other files (index.html and sip.js) show below.

Here is the index.html page to enable the phone:

Here is the main Javascript code (sip.js):

Make sure to change the domain name and port to match what is configured in Asterisk. Then navigate to the index.html page and you should see this page:

WebRTC Phone Calls via Asterisk






Then put in the phone number and password  for the WebRTC phone and click Register. If all goes well, the Register button will change to ‘Registered’. Your WebRTC phone is now ready to answer or make calls.

Put in an extension to call and click the Call button. The Call button will change to match the state of the call. Any incoming calls will automatically be answered and the Call button will be updated to the state of the call. Note: WebRTC (the browser) will ask permission to use the microphone when the fist call is made or answered.

Note that diagnostic messages are logged to the web console. Un-commenting the JsSIP debug.enable in sip.js will also show a lot of interesting debug information for those curious as to what is happening behind the scenes.

WebRTC Screen/Video Sharing

As many readers of this site can tell, I am a bit off topic with this article. None the less, I think those same readers will find it useful. The topic is WebRTC Screen/Video Sharing and shows how to communicate with another person (peer to peer) via video and audio using a Web browser.  This can be very useful to share a ‘screen’ or video and provide remote assistance / technical support.  Complete code and documentation is also provided to try it out (or view the documentation to see the features and if they are of interest).

As working from home becomes more prevalent these days, there is a greater need for this type of service. There are popular software products which offer some of these services, however,  perhaps you are like me and want to try/code these things yourself.  I get the features I want and I control  the (sometimes overlooked) security aspects of the service.

For those not acquainted with WebRTC, it is a means of communications between two peers. (RTC is an abbreviation for Real Time Communications) WebRTC allows for secure sharing of audio and video directly between those two peers, browser to browser (usually without anything in between).

For example, If someone has a problem/question on their computer (perhaps about the Arduino IDE) and you want to show them how something is done, get on the WebRTC Screen/Video sharing page with them. Then share  a screen and ‘walk’ them through the process in question.

WebRTC uses an API built into most modern day browsers.  Technically there are several protocols involved in WebRTC (signalling, ICE, STUN and/or TURN). For more specific information on WebRTC, see the site.

Specifically, the Web application that I am showing in this article, uses the WebRTC API to allow two users to securely communicate via audio/video over a peer to peer connection in real time.  Each of the two ‘peers’ using this Web app would need to have a video device (Web camera), microphone and speakers or headphones.

Features for this Web app include audio, video and/or screen sharing, screen capture, video capture/replay/download, chat messages, file transfer and playing a local video to stream it to the remote peer.

Technically I am not using a ‘Web’ server (like Apache or Nginx) to serve the Web page. I have coded a Node.js server script (in Javascript) which functions as a Web server in that it handles the browser HTTPS Web page request and serves back the Web page.

Here is the code for  the Node Server:

Note: The script (and WebRTC) requires an SSL certificate to ensure secure communications. Make sure to replace the lines (with key: and cert: with valid certificate references). Note: The port serving the Web page is 8080 which can be changed to any port (not conflicting with other ports in use on the server).

The modules required for the node server can be installed via npm:

npm i ws fs  https

To start the node server, use the command:

node server.js

To access the WebRTC app, in addition to the node server, a STUN and/or TURN server is also required.  For the peers to communicate, they need to know how to contact each other and therefor need to know each others’ IP address.  The STUN or (TURN) server provides this info.  The TURN server is needed if one or both of the peers is behind a NAT. As mentioned earlier, for more specifics on how WebRTC works check the the  documentation on the site. There are public STUN servers available so no need to run your own.

However, if a TURN server is need, the coturn open source TURN server is the one I recommend.

The main functioning of this app is via the webrtc.js javascript code. There are two lines  in the webrtc.js script which must be edited and changed to replace the urls for the STUN/TURN server references.

Also, if the port is changed in server.js, make sure to change it in the webrtc.js source to match also.  Once the node server is running and the changes are made to the webrtc.js script for the STUN/TURN server references, the WebRTC app is ready to go.

Using the Firefox or Chrome browser, navigate to its page:

Replacing (and optionally the port) with the actual domain name running the node server script.

The browser will ask if it is OK to share your video and audio device, once approved, the Web Page will show up:

WebRTC Screen/Video Sharing


Click the ‘Show Functions’ / ‘Hide Functions’  button to show or hide all of the extra features available for this app. View or download the documentation (HERE) for an explanation of the features.

The complete source code ( a ZIP file which includes the documentation) , can be downloaded (HERE).

A Wireless WEB Server on an ESP8266

This is a short post which shows how to create a wireless WEB server on an ESP8266.  It uses a microcontroller, in this case an STM32F103C8T6 (BluePill )  to send commands and control the ESP8266

Here is what the wiring looks like:.

A Wireless WEB Server on an ESP8266


You can get the Fritzing code for this image here.





Here is the Arduino IDE source code to load into the STM32F103C8T6 (BluePill) to create a Wireless WEB Server on an ESP8266:

If you open the serial monitor on the Arduino IDE while the code is running you will see the commands being sent to the ESP8266 and its response. You can also watch what comes to its WEB site and what it sends out in return. This can be an interesting learning experience for the beginner.

This is a simple project to make but can be the start of a bigger project or added to another circuit to add wireless capabilities.

STM32F103C8T6 Solar Power System Monitoring

If you read my last post on Solar Power System  Monitoring with an Arduino you might be wondering if that circuit could be enhanced a bit. Say, change the LCD to an OLED and add wireless (WEB server) capability?

I was not happy to have to go out and look at the device when I wanted to see the info. So I did enhance it a bit. I changed the LCD to an OLED for more info in case I did happen to be where the device is and I added a wireless module (an ESP8266). The wireless module has a WEB server so I can just connect wireless via a browser and see the info.

Since the ESP8266 needs 3 Volts, I also changed the ‘arduino’ I was using. I switched to an STM32F103C8T6 (BluePill) since it can take 5 Volts and output 3 Volts.  This new circuit still uses the LM7805 voltage regulator to take the 14 Volt input and then output 5 Volts. It also keeps the SN75176BP for the RS485 protocol conversion.  If you have not read the previous post, you can find more details there on those components.

Here is what the circuit wiring looks like:

STM32F103C8T6 Solar Power System Monitoring



You can get the Fritzing code for this circuit here.




Here is what the circuit looks like (top and front side view):

STM32F103C8T6 Solar Power System MonitoringSTM32F103C8T6 Solar Power System Monitoring







The left side has the STM32F103C8T6 and the RJ11 connector. The right side has the ESP8266, the OLED, the SN75176BP and the LM7805. The LM7805 has a heat sink on it since it gets a bit hot. The STM32F103C8T6, ESP8266, OLED and  SN75176BP are all in sockets for easy (re)placement. This circuit has all the ‘messy’ wiring and soldering on the bottom (hidden from view).  In my previous post I still had all the components on a breadboard.

Here is the code to load into the STM32F103C8T6 (using the Arduino IDE):

I am using the Adafruit GFX and SSD1306  libraries to control the OLED. The ESP8266 is just connected via a serial connection and sent commands to set it up as an access point and WEB server.

The wireless access point name is just set to ESP8266. You can change it to anything you want. The IP address is, so just go to that IP address in a browser after connecting wirelessly. The WEB page will refresh every 5 seconds.

My next step is to enhance the code to display more info as it still only outputs the codes like the LCD version does. Here is a picture (photography is not my forte) of the device on top of one of my Lithium Batteries (from Deeds Solar Solutions).





Solar Power System Monitoring with an Arduino

Sometimes, people wonder about the practical side of using an arduino. I do get asked what is the real use for some of the articles I post here.  Are these ‘gadgets‘ just toys or do they have a practical use?  Most people who ask though, are not that familiar with arduinos or microcontrollers in general.

So, this post is a partial answer to some of those questions and a place I can refer people to.  Although, if people were really curious, a search would show them a number of practical uses for arduinos and microcontrollers in general.

For example, I recently posted articles on using an arduino to communicate via the RS485 protocol here and here. Another post shows how to use an LCD (using only 3 pins) with an arduino here.

This post will show how to use the knowledge gained from those posts (plus a bit more) to build an arduino ‘gadget’ which can be used to monitor an inverter. Hence, the title of this post:  “Solar Power System Monitoring with an Arduino”.

An inverter is an essential part of a solar power system which uses sun light (solar energy) to produce electricity.

A solar power system (initial investment) can be quite expensive, depending on energy needs. Replacing parts is also expensive.  Monitoring what is happening with the solar energy conversion to electricity and its subsequent usage, is a very important part of the system to make sure it is being used efficiently and properly. If we can use an arduino for monitoring (which we can), we thus have a practical use for it (especially considering the price of buying commercial products versus do it yourself with an arduino).

I happen to have a Magnum inverter which is connected (and controlled) by an ME-ARC remote monitor. I was wondering if the ME-ARC is really needed and if it could be replaced with an arduino and an LCD screen. In my testing, I found out that the ME-ARC is not needed to actually run the inverter and it can be replaced with an arduino. What follows documents how it can be done.

The only connection into the ME-ARC is an RJ11 cable from the inverter. This RJ11 cable is the same type of cable used to connect telephones to wall jacks.

Since there is no external power cable, the RJ11 connection must be supplying both power (volts/ground) and data.  Further information is needed on how the remote gets power and data from the inverter. This information is in the Magnum Network Communications Protocol document found via a search.

From the document, we can see that the RJ11 cable does indeed provide power (14 Volts, Ground) and data. The protocol in use for data interchange is RS485. So we can use the information from my earlier posts to see how we can attach an arduino to the inverter. Note: The end of the document has a ‘Third Party Notes’ section which concerns  connecting your own device to the Magnum Network. How did they know we were going to connect an arduino ?  🙂

The RJ11 (4 wire) connection is wired like this:

Looking at the ‘front’ of the RJ11 connector with the ‘tab’  at the top, pin 1 is on the right side,  pin 4 is on the left side.

Since the arduino and the LCD need 5 volts to work and the inverter is sending 14 volts, we need a way to regulate the 14 volts down to 5 volts.

Here is the simple circuit to accomplish that.

LM7805 Voltage Regulator


Get the Fritzing code for that circuit image here.



LM7805 Circuit

This is what the circuit looks like when built.





I used an RJ11 splitter to attach both the ME-ARC and my arduino at the same time.

The splitter RJ11 Splitterwas connected to the back of the ME-ARC. The RJ11 cable from the inverter was plugged into one side of the splitter and the cable to the arduino was plugged into the other side of the splitter. Wiring that way allows viewing the ME-ARC and checking what it is showing versus what the arduino is showing. This is a good way to check that the code in the arduino is providing the same (accurate) results.

Since the communications from the inverter uses the RS485 protocol, we will use the wiring shown in a previous post which uses the SN75176BP IC for the protocol conversion.

If you haven’t taken the time to read that post, here are the wiring diagrams for the SN75176BP (left) and the complete circuit (below). The diagram shows RS485 communications between two arduinos, however, we can just pretend that one of the arduinos is the inverter. In fact, one of the arduinos was running code to emulate the inverter for testing purposes but I did not mention that in the original post.  Now you know. 🙂

SN75176BP RS485 Communications using Arduinos

Get the Fritzing code for that diagram here.  For connecting just one arduino to the actual inverter, the ‘A’ pin (from the RJ11 connector pin 4) connects to the ‘A’ pin of the SN75176BP and the ‘B’ pin (from the RJ11 connector pin 1) connects to the ‘B’ pin of the SN75176BP.

LCD Shift Register Circuit for an LCD


In hooking up the LCD to the arduino, we will also use the information from a previous post.  There we show how to use a shift register IC to minimize the number of pins used to connect the LCD to the arduino.


Now that we have all of the hardware details, we can hook it all up. The RJ11 splitter is connected to the ME-ARC. The RJ11 cable from the inverter is connected to one side of the splitter. The other side of the splitter is connected to the arduino circuit this way:

Here is what it looks like all attached and working:

Solar Power System Monitoring with an Arduino

From the picture, you can see the RJ11 cable (on the right) dropped down from the splitter on the ME-ARC. I have an RJ11 female/female connector to the cable and to an RJ11 connector which breaks out the 4 wires connecting to the arduino and the voltage regulator circuits.

You are probably wondering about the output on the LCD? Since the LCD has only 16 characters x 2 lines, it has limited space to display things. The first line has ‘codes’ for what it is displaying:

The 2nd line displays the DC volts and  amps being used just like the ‘Meter’ on the ME-ARC. The code in the arduino gets these values from a data packet sent by the inverter every 100 milliseconds. The Magnum Network Communications Protocol document (mentioned earlier) details the communications and values being sent.

Here is the arduino code so you can see how the arduino captures the inverter data, waits for the 100 millisecond ‘gap’ and then decodes and displays the values.

One serial port is used for communications to the inverter and another is used to optionally communicate with a PC and get commands to send to the inverter. Note: The code for transmitting data to the inverter is there but commented out.  I am using the Software Serial library (to emulate an additional serial port) because the Arduino Nano I am using for this project only has one serial port. The other library (LiquidCrystal595) is needed to control the LCD with only 3 pins. Make sure, if you use that library, to patch it according to the comments in my post about it mentioned above and referenced again here.

Since the inverter sends a data packet every 100 milliseconds, we can check for that ‘gap’ (no data being sent) and know that we have a complete packet.  However,  since it will take some time to run the code to display on the LCD we need to pick a ‘safe’ value for checking that timing. You will notice in the code:

the timer holds the number of milliseconds since the last input byte from the inverter. I chose a ‘safe’ value of 30 (milliseconds) which should give enough time to display on the LCD and get back to checking for inverter data.

The next step would be to test sending data to the inverter as does the actual ME-ARC remote. Only then would we have something to be able to totally replace the ME-ARC.

So now you can see that there are ‘building blocks’ (so to speak) in my posts which used together can produce something practical, Solar Power System Monitoring with an Arduino.

How a Web Server on an STM32F103C8T6 can be used to control a Relay Switch

Here is the circuit showing how a Web Server on an STM32F103C8T6 can be used to control a Relay Switch:

BluePill As A Web Server With A Relay SwitchThe Fritzing code used to create that diagram/image can be downloaded here.

An ENC28J60 ethernet module is used to connect the STM32F103C8T6 (BluePill) to a network.

Here is the source code for the sketch to load into the STM32F103C8T6 (BluePill):

This is an updated and enhanced sketch from a previous post on a WEB server using both the BluePill (STM32F103C8T6) and the ENC28J60 module. It seems the UIPEthernet  library has changed since then. I had to add these lines to the code to define the correct pin settings:

The source code has the IP address and network settings for the ENC28J60 ethernet module hard coded. Those settings may need changed for use on a different network.

The relay switch can be attached to any number of AC type low current devices and turned ON/OFF by accessing the WEB server. (The relay switch can possibly handle low current DC devices as well). I used a 2N3904 NPN transistor in my circuit to allow the STM32F103CT6 to turn the relay OFF and ON. This circuit also has a red LED to visually show when the relay is ON or OFF.

The WEB server accepts several ‘commands’:

‘LED’ toggles the internal LED On/Off, ‘analog’ displays the analog values of the first 4 analog pins and ‘switch’ toggles the relay On/Off.  So now you know how a Web Server on an STM32F103C8T6 can be used to control a Relay Switch.

Load more