Archive for the ‘MCU’ Category.

UV index sensor with RS485 interface

This is another sensor in weather-sensor series. It is based on silabs Si1133.



Si1133 Sensor schematic with RS485 interface

Continue reading ‘UV index sensor with RS485 interface’ »

Source code generator for Command Line Interpreter (CLI)

Microcontroller with serial bus or USB CDC (virtual COM port) is usually connected to some terminal. User then type commands and firmware in the microcontroller interprets entered commands.

Developing simple interpreter is not very scientific task, more like PITA with repeating chunks of the code. After couple of successful projects with such interpreter I can say my code is somehow tested and proven in the practice. Now I prepared one application which can shorten development process and make my life easier when I start application in new device.

The source code generator generates only command line interpreter. It provides all identifiers for selected commands, provides function prototypes for each command and text template for help. Finally only the functions for executing specific commands should be then implemented.

The final application can be either multi-threaded with RTOS, or flat single thread. In both cases, there should be some function or ISR checking for new char and feeding this char to the command line editor. When new line “arrives”, the function cmd_proc() is called and then the magic happens.


General structure of the caller thread or application

Continue reading ‘Source code generator for Command Line Interpreter (CLI)’ »

Pressure, temperature and humidity sensor based on MS5637 HDC1080

This is anothe small module to measure air pressure, temperature and humidity. Two sensors are on-board: MS5637 and HDC1080. Microcontroller is small cortex M0 in TSSOP-20 housing from STM: STM32F070CxP. The SN65HVD72DGKR provides RS485 interface functionality with half duplex mode. Voltage regulator, reverse polarity protection and some LED indicators are provided on-board. Complete module is 10x55mm, produced on single-sided PCB, easily producible in every home lab with proto-PCB capability.

RH, T and air pressure sensor with RS485

RH, T and air pressure sensor with RS485

Continue reading ‘Pressure, temperature and humidity sensor based on MS5637 HDC1080’ »

HDLC-Like data link via RS485

Communication between microcontrollers is always interesting topic. I was looking for simple, efficient and reliable protocol between several microcontrollers. First I have to choose the physical layer. One of the most commonly used multipoint buses is RS485. Due to simplicity I choose half-duplex RS485. Only two wires is all it needs to establish link between two devices:


Continue reading ‘HDLC-Like data link via RS485’ »

USB to RS485

Testing of sensors with RS485 using PC without proper interface is not possible. Since RS232 interfaces are very rare, the interface should be hooked to USB. The interface between USB and RS485 can be soldered with one of the many FTDI interfaces with added RS485 driver, or bought as assembled module. There is always the third option. I made it from scratch.

I took smallest STM32F0 with USB and UART interface. The best thing with UART in the STM32F0 is that signal for driver enable is provided within hardware. The complete pinout of the microcontroller is:


Continue reading ‘USB to RS485’ »

Adding RS485 to FRDM-K64F

FRDM-K64F is nice piece of development board. Unfortunately, it is “bonded” to MBED development platform, which is a nightmare! Adding RS485 “out of the box” to the FRDM-K64F in MBED is NoGo. But it is very easy.

Here is image from my scope sending single char via UART4 with enabled RTS as DE for RS485 in Half Duplex mode:


Continue reading ‘Adding RS485 to FRDM-K64F’ »

SiLabs Si7013 humidity and temperature sensor

I got samples of Si7013.

The Si7013 I2C Humidity and 2-Zone Temperature Sensor is a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital
converter, signal processing, calibration data, and an I2C Interface. The patented use of industry-standard, low-K polymeric dielectrics for sensing humidity enables the construction of low-power, monolithic CMOS Sensor ICs with low drift and hysteresis, and excellent long term stability. The humidity and temperature sensors are factory-calibrated and the calibration data is stored in the on-chip non-volatile memory. This ensures that the sensors are fully interchangeable, with no recalibration or software changes required. An auxiliary sensor input with power management can be tied directly to an external thermistor network or other voltage-output sensor. On-board logic performs calibration/linearization of the external input using user-programmable coefficients. The least-significant bit of the Si7013’s I2C address is programmable, allowing two devices to share the same bus. The Si7013 is available in a 3×3 mm DFN package and is reflow solderable. The
optional factory-installed cover offers a low profile, convenient means of protecting the sensor during assembly (e.g., reflow soldering) and throughout the life of the product, excluding liquids (hydrophobic/oleophobic) and particulates. The Si7013 offers an accurate, low-power, factory-calibrated digital solution ideal for measuring humidity, dew-point, and temperature, in applications ranging from HVAC/R and asset tracking to industrial and consumer platforms.

I prepared prototyping board with STM32F0 and line RS485 driver:

rht  pcbrht0


Continue reading ‘SiLabs Si7013 humidity and temperature sensor’ »

Simple WEB server hosted on NXP/Freescale FRDM K64F demo board

Kinetis K64F demo board is excellent little board for experimenting with ethernet. There is no quick step-by-step tutorial for building simple web server on this board. The following instructions help bringing working HTTP server on FRDM K64F with one index page and second page with simple CGI script to print out some random numbers. This is absolute minimum for developing any web based gadget with this board.


(image source: )

What you will need:

  • Compiling tool: Keil development tools
  • Hardware:
  • Good to read: HTTP server demo application
  • LAN cable and spare port on your switch or router

Continue reading ‘Simple WEB server hosted on NXP/Freescale FRDM K64F demo board’ »

STM32F7 Discovery 3D model

I was searching for 3D model of the STM32F7 discovery board (part number STM32F746 discovery) without success. I ended with my own 3D model.

stm32f7 discostm32f7 disco1

>>>Here is the project on GRABCAD<<<

And local copy of STEP file: MB1191B-V14


How to program blank STM32F1 with STLINK V2 firmware

Today I found out how to “flash” blank STM32F103xC to make STLINK V2 debugger interface.

So, instead of desoldering from Discovery board to make miniture STLINK debug interface:

a09 - stlink v2 brain desoldered                  a0a - stlink v2 finally assembled usb mini dongle

it’s possible to solder blank (or any) STM32F10x with USB and at least 64k flash + 20k RAM, program it with STLINK V2 Firmware and use your new USB dongle for debugging STM32 or STM8 devices.

Continue reading ‘How to program blank STM32F1 with STLINK V2 firmware’ »