Sunday, August 9, 2015

TM4C123 with DHT11 sensor

Connected the DHT11 sensor to TM4C123.  The sensor is not that accurate, but simple to use.  Result displayed on Nokia 5110 LCD.

Programs written with Energia.  There are libraries for the sensor and LCD display, but both require slight modification.

Code available on github.



Updates 2016-05-14:

Here is the wiring.  Note that my Nokia 5110 board support input of 3v to 5v.  Your mileage may vary.

TM4C123 -  LCD 5110        Comment
==================================
VBUS    -  Vcc             My version of 5110 supports 3v to 5v
VBUS    -  BL              Backlight
GND     -  GND
PB_5    -  RST             Reset 
PB_4    -  Clk             SCK(2) to Clock
PB_7    -  Din             MOSI(2) to Serial data in
PA_7    -  CE              Chip Select
PA_2    -  DC              Select between data or command



TM4C123 -  DHT11        Comment
==================================
PD_7    -  Data
VBUS    -  Vcc
GND     -  GND


10 comments:

Rob Owen said...

Hi,
I've been trying to use your code for the "TM4C123 with DHT11 sensor" - and failing!

I have a Launchpad TM4C123GXL and a Nokia 5110 on a red board. I'm using Energia, and trying to simplify the code just to be able to write to the display, without reading temperature and humidity (I have no sensors connected.)

I know the display works because I've been following an EdX course at the University of Texas at Austin - but there we use Keil, and the programming is a lot more complex. We used the following pins: SCE = 12 (PA3), RST = 10 (PA7), DC = 9 (PA6), DN = 8 (PA5), SCLK = 11 (PA2). We were told not to connect the backlight because it takes too much current, and could damage the board.

I'm new to Energia, and would be grateful if you could briefly explain a) where to place all the files - I've tried putting them all in the same folder as the .ino file, and that doesn't work!. b) How to assign the pins in the ino file; in particular, the Serial clock and serial data pins. Many thanks.

Clarence said...

When you said "that doesn't work", what kind of error did you encounter? For pin assignment, it can be passed as parameter when you create the LCD_5110_SPI:

https://github.com/kitsook/TM4C123_temperature/blob/master/LCD_5110_SPI_EX.ino#L38

Rob Owen said...

Thanks for replying so quickly. The previous error (with Energia 0014) was because it couldn't find the #include files. I have updated Energia to version 0101E0017, and now it compiles correctly. The Serial monitor shows the correct text every minute, but there is nothing on the LCD screen. So the programme is running!

I have assigned pins in LCD_5110_SPI myScreen(12, 9, 10, 13, PUSH2), but how do I assign pins for the SCLK and DN(MOSI) connections on the LCD board? e.g. I have the LCD's SCLK pin connected to pin 11(PA2), but the programme has no way of knowing this.

I have put a copy of the LCD_5110_SPI_EX.ino file (modified to ignore sensor readings) here:
https://dl.dropboxusercontent.com/u/17759511/LCD_5110_SPI_EX.ino

Thanks for your help.

Clarence said...

I can't remember exactly which pin I used, but referring to the pin diagram at:
http://embeddedcomputing.weebly.com/launchpad-stellaris-lm4f120-pins-maps.html

I believe I used the third SSI port i.e. SCK(2) and MOSI(2), which is PB_4 for clock and PB_7 for serial data.

Rob Owen said...

Thanks for your help. OK - this is my last attempt - I'm sure that I am testing your patience!

In the file LCD_5110_SPI.cpp, you have commented out all reference to the pinSerialData and pinSerialClock, because you don't seem to use them in the rest of the programme. So I've tried connecting these pins to 0volts and Vcc - in all combinations, but still nothing shows on the LCD.

Is there anything else you could suggest that I try?

Clarence said...

Hi Rob. I found my TM4C123 and tried the program again. Indeed I was using the third SPI port.

https://github.com/kitsook/TM4C123_temperature/blob/master/LCD_5110_SPI_EX.ino#L63

I cleaned up the code a bit and added comment on wiring

Rob Owen said...

Yes! It worked!

First I followed all the new wiring connections you listed in the programme - and still nothing. The serial monitor was (as before) showing text, but nothing on the LCD. I was about to give up when I thought I'd try the contrast setting (Line 69: myScreen.setContrast(0x28);). (I had tried different contrast settings with the previous version of the programme, and that hadn't helped, so I wasn't hopeful.) I changed the contrast to 0x48, and it was perfect!

Thank you for going to the trouble of finding the TM4C123, and explaining clearly in the programme how to connect the lcd panel to the board.

Now I want to find out how to draw graphics on the LCD_5110 :)

Many thanks.

Clarence said...

Hi Rob. Glad to hear that it worked for you. For my 5110, setting contrast to 0x48 will render it all black. Probably a slight variation of the QC. :P

Rob Owen said...

Hi, I've been investigating how graphics work on the 5110, and have added quite a few graphics commands to the LCD_5110_SPI.cpp library. I've also written a simple Pacman-style game using those graphics commands.

See this Youtube video for details: https://youtu.be/wCwyDiEfO_c

The Library and game can be downloaded from:
https://dl.dropboxusercontent.com/u/17759511/LCD5100_Graphics.zip

I don't know whether you want to incorporate them in your github files, but you are welcome to do so.

Sajad Rather said...

hello

i tried to implement your code in energia after downloading it,but it shows error that


sketch_sep30a.cpp:47:26: fatal error: LCD_5110_SPI.h: No such file or directory
#include "LCD_5110_SPI.h"
^
compilation terminated.