Pages: [1]   Go Down
Author Topic: Solved: LCD 128x64 ST7920 & NRF24L01+ & DHT11 & Arduino NANO3.0  (Read 1558 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 111
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello to all!

I'm using some Arduinos to send sensor data (Temperature read from DHT11) trought NRF24L01+ antennas. Untile here all works very well.
My setup is like attached image...
Sorry, but cannot draw very well with Fritzing. Consider the upper right device as the NRF24L01+ transceiver.

Then, I was able to wire and work on another Arduino having a ST7920 LCD 128x64 connected in Serial Mode. What I would like to do is to use the LCD on one of the existing Arduinos with the NRF24L01+ antennas but cannot figure out how to wire/setup it.... I'm not sure it's possible... 'cause:

a) the ST7920 in Serial Mode cannot be used; the NRF24L01+ still use the SPI communication also cannot share it
b) the ST7920 in Parallel Mode needs more digital PINS and I haven't enough
c) I've thought to use a TLC5940 to multiply my digital pins but seems it uses SPI as well, also, like point a, I cannot choose this mode.

Is there a way to add on an Arduino NANO all those devices in any way? (also ST7920 + NRF24L01+ + DHT11).

Thank's for the help!

Simon


* MeshSensors.png (137.56 KB, 663x692 - viewed 111 times.)
« Last Edit: February 13, 2013, 03:47:04 am by X3fil » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't have to use the SPI pins to drive the ST7920 display in serial mode. You can use any 2 pins, although the update speed will be slower than the speed you can get using SPI.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 111
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't have to use the SPI pins to drive the ST7920 display in serial mode. You can use any 2 pins, although the update speed will be slower than the speed you can get using SPI.

I'm using the U8glib library and to make the display work I use the following setup:

Code:
// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
U8GLIB_ST7920_128X64 u8g(13, 11, 10, U8G_PIN_NONE);

You mean I could use any digital pin instead pins 11 and 13 that I've still in use for my NRF24L01+?
Would be great! I need only to print some values, also a fast update speed is not a requirement.

I'll try using this setup:
Code:
U8GLIB_ST7920_128X64 u8g(4, 5, 6, U8G_PIN_NONE);

I cannot try it right now, but let you know in case there is someting that doesn't work as expected.
BTW I've to find some documentation to better understand what exactly are some common concepts like SPI, miso-mosi...
Why, in this case, SPI pins are not required?

Thank's!

Simon
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll need to check the u8glib documentation to see whether it supports serial mode using pins other than the SPI pins. If it doesn't, then you can find my own ST7920 library at https://github.com/dc42/arduino, but it's not as comprehensive as u8glib and it uses a 1K image buffer (which is half the RAM on an Uno).

The point about the SPI pins is that is uses hardware to do fast serial transfers. However, you can do similar sorts of serial transfer at a slower speed using the shiftOut function (which is very slow) or using direct port manipulation.
« Last Edit: February 12, 2013, 05:39:49 am by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 111
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll need to check the u8glib documentation to see whether it supports serial mode using pins other than the SPI pins. If it doesn't, then you can find my own ST7920 library at https://github.com/dc42/arduino, but it's not as comprehensive as u8glib and it uses a 1K image buffer (which is half the RAM on an Uno).

The point about the SPI pins is that is uses hardware to do fast serial transfers. However, you can do similar sorts of serial transfer at a slower speed using the shiftOut function (which is very slow) or using direct port manipulation.

Well, I could test your library as well! If smaller, even better!
Reading the ubglib it's written "COM interfaces: Software SPI, Hardware SPI, 8Bit parallel".
But reading the supported devices I cannot understand a part:

https://code.google.com/p/u8glib/wiki/device

Looking for ST7920, There are three ways to control:
SW SPI    u8g_dev_st7920_128x64_sw_spi    U8GLIB_ST7920_128X64(sck, mosi, cs, a0 [, reset])   
HW SPI    u8g_dev_st7920_128x64_hw_spi    U8GLIB_ST7920_128X64(cs, a0 [, reset])   
8 Bit    u8g_dev_st7920_128x64_8bit    U8GLIB_ST7920_128X64(d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw [, reset])

8Bit is parallel, ok.
Is SW SPI what I should need? But in case it uses SCK, MOSI that should part of SPI protocol on pins 11+13 already used.... what is then HW SPI? Confused again smiley-sad

BTW I'll test all those solutions, included your version.

Thank's!

Simon
« Last Edit: February 12, 2013, 08:28:22 am by X3fil » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, software SPI is what you need to use if the hardware SPI pins are not available. The fact that when using software SPI you pass the pin numbers for SCLK and MOSI suggests to me that you can pick whichever pins you like for those.
« Last Edit: February 12, 2013, 08:53:26 am by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1235
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

SPI is just a communication protocol. It can be implemented in hardware or with software.

U8GLIB_ST7920_128X64(cs, a0 [, reset])  will use the ATMega hardware subsystems. Pins are fixed and can not be changed.

U8GLIB_ST7920_128X64(sck, mosi, cs, a0 [, reset]) will use the u8glib software emulated SPI, any pins can be used.

Oliver
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 111
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



Using different pins it works the same way, as suggested. I cannot see big difference in update time, 'cause I'm drawing only some values.
The compiled sketch is a little big, also I'll try the dc42's library as well.

I've learned something new... again smiley-wink

Thank's to all for the support!

Simon
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll need to check the u8glib documentation to see whether it supports serial mode using pins other than the SPI pins. If it doesn't, then you can find my own ST7920 library at https://github.com/dc42/arduino, but it's not as comprehensive as u8glib and it uses a 1K image buffer (which is half the RAM on an Uno).

The point about the SPI pins is that is uses hardware to do fast serial transfers. However, you can do similar sorts of serial transfer at a slower speed using the shiftOut function (which is very slow) or using direct port manipulation.

Hello DC42

Does your library supports hardware SPI , i found it very simple and interesting and would like to use it in my current project

thanks
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it supports hardware SPI. See the comments in the Lcd7920.h file.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it supports hardware SPI. See the comments in the Lcd7920.h file.

Sorry I needed  to ask is the library supports Software SPI

Thanks
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it supports controlling the ST7920 without using the hardware SPI pins. It's not strictly sotfware SPI because the ST7920 has no /CS pin and doesn't return any data to the master.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: [1]   Go Up
Jump to: