Solved: LCD 128x64 ST7920 & NRF24L01+ & DHT11 & Arduino NANO3.0

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

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.

dc42:
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:

// 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:

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

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 GitHub - dc42/arduino: Reusable modules, drivers and patches for the Arduino platform, 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.

dc42:
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 GitHub - dc42/arduino: Reusable modules, drivers and patches for the Arduino platform, 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 :frowning:

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

Thank's!

Simon

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.

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

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 :wink:

Thank's to all for the support!

Simon

dc42:
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 GitHub - dc42/arduino: Reusable modules, drivers and patches for the Arduino platform, 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

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

dc42:
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

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.