Hi,
for a Project I am searching for a solution to share MOSI and SCK but I am not sure howto do it will work out of the box.
Let me explain, what I am trying to build.
I want to control my underground heating with Arduino. My underground heating currently has a temperature sensor in each room and a central until with an electronic valve for every room.
I am planning to replace the temperature sensor with:
- ATTINY84
- DHT21
- Nokia 5110 LCD
This unit is a slave unit and will communicate with a master unit:
- Arduino UNO
- 8 port Relais Board
The Master and Slave will communicate via I2C and it is working as long as I don’t use the LCD. If I want to connect the LCD I must use MOSI and SCK which will be used by I2C. As far as I understand it should be possible to share the MOSI and SCK and SS (or CS) will signal the device. However – I2C doesn’t require a SS or CS.
Do I have to rebuild the libraries to ‘emulate’ a CS? Or what is the best approach to build such a solution?
The libraries I use are:
TinyWire/TinyWireS at master · rambo/TinyWire · GitHub
LCD5110_Basic - Rinky-Dink Electronics
and WIRE
cu and thx in advance
arduw70
There is no way, that I know of, to share I2C and SPI pins. This is looking like an XY problem.
Are you out of pins so want to share them? Do the library pin assignments conflict?
Hi,
thank you for your reply. No I am not out of pins, but my understanding is:
ATTINY Uno needs pin 6 (MOSI) and 4 (SCK) on the ATTINY side.
The Nokia 5110 will require also these pins. But the Nokia seems to use CS to signal which device is addressed.
Or can the pins for the Nokia be exchanged?
Or can the pins for the Nokia be exchanged?
Yes, they can. The LCD5110 constructor lets you specify the pins to use.
LCD5110(int SCK, int MOSI, int DC, int RST, int CS);
The display uses a software SPI so the pins can be set how you need (hardware SPI uses specific pins).
Edit: reading the header files further, I see pin are assigned and the pinModes are set in the constructor. This may give you trouble. I use the Adafruit PCD8544 library.
Hi,
thx - does that lib Support ATTINY84?
does that lib Support ATTINY84?
I don't know for sure, but don't see why not. I have used it with an Uno.
arduw70:
The Master and Slave will communicate via I2C and it is working as long as I don’t use the LCD.
This makes no sense at all, unless you are trying to use the I2C pins for the display and, since you say you don't have a shortage of pins, I can't see why on earth you would do that. The 5110 can be run on the SPI bus, which sounds like a good idea, but I don't think it is normal to do so, and you are certainly not obliged to. You can use any vacant pins you like for the 5110 so long as they are properly called in the code. In the case of the standard Philips library , this means you have to edit it.
Hi,
just tested to change the pins and it is working. But after second screen update I get pixel errors and after a while the screen stops. However – in general it is working.
Thx for the tip.