Thermometer with EMW3165

emw-old-meter
Old thermometer broken by the Cat

This project started when our cat decided that playing with our thermometer is a good idea. Obviously, the thing looks enough like mouse with tail, at least when looked with cat’s eyes. The play with it ended very quickly and result was broken cable between display and sensor.The easiest way to fix this would obviously be buying a new 10€ device from local hardware store. But as I already have a weather station running on top of garage roof I started thinking that it would be nice just to display temperature from there.

Continue reading “Thermometer with EMW3165”

MXCHIP EMW3162 (Wiced Wifi) with Pico]OS

Just about every summer I have been thinking about building a sensor, which measures water temperature from the lake at our summer cottage. So I would need a board with few gpio ports to connect a DS1820 sensor and some radio communications to send data to my database server. As I already have Wifi access point installed it would nice be able to use it directly.

MXCHIP_EMW3162When I was researching for suitable parts for the system, I bumped into small module called EMW3162. The module has a STM32 Cortex-M3 microcontroller and Broadcom Cypress Wiced-compatible Wifi chip. The module costs less than $10 at Seeedstudio.com – more than popular ESP8266, but STM32 cpu has more memory and peripherals. For first module, a ~$20 development board is needed (either EMB-380-S2 or EMB-WICED-S).

To program the system, there are two alternatives: SDK provided by module maker MXCHIP and Wiced SDK provided by Broadcom. I ended experimenting with Wiced SDK, as Broadcom provides it for free (registration required, however) along with nice support community. SDK needs some patching for EMW3162, but required changes are available from github.

Wiced SDK provides multiple choices for network stack and RTOS. I ended trying FreeRTOS + LwIP combination, mostly those components being open source. Examples seem to work OK, so it is pretty easy to get things up and running.

But I have always been using Pico]OS for my embedded hobby projects. As Wiced SDK has clean api to add support for any RTOS, I couldn’t resist to start writing such layer for Pico]OS. It was actually quite easy task, all that was needed were ~15 functions to wrap Pico]OS services (threads, semaphores and queues mainly).

Pico]OS approach to building embedded systems is a little bit different than Wiced SDK, however. Wiced SDK seems like a one-stop service for about everything you’ll need to build a Wifi-enabled embedded system: it contains network stack, rtos and API functions for GPIO, ADC etc. Pico]OS on the contrary has quite powerful Makefile system which makes it easy to build separate module libraries for different needs.

I wanted to build a Pico]OS library module containing LwIP driver which I could use with existing picoos-lwip library (it uses currently HEAD revision from LwIP project). Luckily, Wiced SDK is pretty well organized and it was quite easy to find out which files I would need to compile for complete driver. There are rougly two layers in SDK: “WICED” – the full SDM and “WWD” – driver layer. I needed mostly files from WWD-layer only.

WICED SDK and Pico]OS have overlapping functionality when it comes to console serial port output/input. I wanted to use Pico]OS stuff also here, because I have a quite complete newlib syscall support layer in picoos-micro library, allowing me to use standard C stuff to print log messages and read/write files. I couldn’t find a way to fully disable USART support in WICED, so I ended up in patching SDK sources for that part.

Another, equally working approach would have been to disable console input/output api from Pico]OS nano layer and use it from Wiced SDK.

Wifi chip needs firmware before it actually works. I solved this a little bit differently than in Wiced SDK by putting the firmware file into filesystem (/firmware/CHIPNAME.bin) and serving it from there using pretty much standard C stuff.

The resulting wiced-driver library is available at Github, along with simple wiced-test application, which does nothing more than connects to access point and brings LwIP up so you can ping it.

I can now continue with my lake temperature sensor development, hopefully getting something up and running for next summer.

 

New storage temperature monitoring

med_ek-tm4c1294xl_clp-top-no-shadow-low_resOld arm board I was using to monitor my storage temperature broke. As I didn’t have any similar boards in my piles any more, I decided that this would be a great opportunity to try something more modern instead. New board should be using a Cortex-M3/M4 CPU, have ethernet controller on board and a few GPIO pins for 1-wire interface. At the end I had two choices: either Olimex STM32-E407 or Texas instruments Tiva Connected Launchpad.

As I really liked TI’s stuff on MSP430 microcontrollers before I decided to try Tiva launchpad.(Olimex does’t offer TI Cortex-M4 boards currently)

I had earlier ported Pico]OS to Tiva Launchpad, but I still had some problems in getting simple blink-a-led stuff running. I finally found out that chip on this board requires different clock setup than the one on simpler launchpad (one must call SysCtlClockFreqSet instead of SysCtlClockSet & SysCtlClockGet). The basic uIP driver for ethernet was provided as an example with tivaware and it was very easy to adapt it from there into picoos-net library.

I refactored by existing sensor-web project quite heavily by moving all board-specific stuff into separate subdirectories, hoping that project wouldn’t look like a big mess after adding new board (it now supports old Olimex LPC-E2129 arm7 board, Tiva launchpad and unix for testing). As Tiva board has more RAM than old board, it was possible to allow more concurrent tcp/ip connections, which makes the web browser interface to work a lot better than with just 2 connections.

I put the board into plastic box today and moved it into storage room. Temperature trends from it are available here.

 

Wifi for picoos-net & uIP

Picoos-net library has been lacking support for Wifi networks and I have been trying to figure out how to implement it.

I would like to run the network stack on the microcontroller along with my application so I could keep on using APIs I’m familiar with. This rules out modules that have built-in tcp/ip networking. However, writing whole Wifi stack would be a huge task and resulting library might be too big for some microcontrollers I have been using. So this rules out cheap usb-stick style approach.

hlk-rm04Microchip has a nice Wifi module, but documentation for it is not publicly available and their own network stack is limited (by license) for use with their own microcontrollers only.

Broadcom seems to have nice modules also (Wiced) and they seem to provide some kind of SDK, which might make integration of modules easier.

Continue reading “Wifi for picoos-net & uIP”

Tiva C Launchpad

launchpad-tivac-01I added an example about how to run Pico]OS on Texas Instruments Tiva C Launchpad, which is a very affordable Cortex-M4 evaluation board. It costs currently less than $13 and has 256 Kb of flash and 32 Kb of ram.

Supporting it wasn’t quite as easy as I thought. Texas Instruments provides a C-language library called ‘Tivaware’ which contains functions to access all peripherals provided by the chip. However, tivaware does not include CMSIS headers currently (I was using version 2.x), which makes porting software that uses CMSIS (like Pico]OS) more difficult than it would otherwise be. Continue reading “Tiva C Launchpad”