Pages

Wednesday, August 27, 2014

Weather Info project with CC3000, ILI9341 and DHT11

It has been ages since my last post. I took the time for vacation to take care of family matters. Now that I have time to kill, I was able to come up with this simple project that involves Sparkfun's CC3000 wifi sheild, an ILI9341 2.5 inch TFT LCD, an inexpensive DHT11 humidity and temperature sensor, and of course the handy Nucleo STM32F401RE.

In this project, I've chosen the Nucleo board since it would be more challenging to run something on a limited 96K RAM and 512K of flash ROM. In comparison, my Raspberry Pi has 512MB and code size limited only by the size of your SD card. The only advantage I think that the Nucleo has in comparison to the Raspberry Pi are the IO's - particulary the SPI channels. There are 3 SPI channels on the Nucleo board compared to only 1 on the Raspberry Pi header. The bulk of the challenge lies on having to control all these IO with an embedded RTOS, running different threads with a limited code size and ram. Luckily, the CC3000 has an embedded TCP/IP stack that runs on it, this means that I wont have to bloat code with an lwIP. However, the CC3000 itself is a beast to debug over SPI and TI's supplied code for controlling it would sometimes go into an exception handler. I initially created this project on embed (online IDE), with embed's own embed-rtos as the RTOS of choice. However since I usually work offline most of the time, I moved the code to work on Keil MDK.

So to summarize this project, the board can be booted either in two ways - by pressing the boot switch on during boot, the Nucleo board enters into a command shell (via the built-in serial RS232 connection), where you can enter a bunch of commands to test the LCD, examine memory or other tasks. By default, by remaining the boot switch open during boot, it goes into its normal process loop which consists of the following:
  1. Load config.ini from the SD card, and get the web page to get the weather info from. In this case this would be openweathermap.com. 
  2. Initializes the CC3000 wifi sheild and connects to the Access point (AP).
  3. Initialize the LCD (ILI9341)
  4. Once AP is connected, it proceeds to read the weather data from openweathermap.com, and retrieve the JSON formatted weather info.
  5. Parse the JSON file and extract relevant weather data.
  6. Read the values of the DHT11 sensor - temperature and humidity.
  7. Once all weather info's are read update the weather information on the LCD screen.
  8. Repeat the process from step 4.
Here's the video of the running demonstration:


Links to souce code is found here : https://github.com/vpcola/Nucleo

That's it for now, I'll discuss the details of the implementation of this project on my next blog.