Today was a lot of fun, and I mean a lot! I was able to connect not only the Botletics LTE shield, but also the Nokia 5110 screen to the Arduino, AT THE SAME TIME! I know, for the rest of the Arduino enthusiasts out there, this may seem like child’s play, but it was a big deal for me.
First, I was using the Botletics modified fona library, and with the soldered board pins, it can only connect to the Arduino one way. The problem was that I was also using the PCD8544 library to control the Nokia 5110 display, but some of the pins needed were the same ones for both devices. That certainly wouldn’t do. So, I edited the PCD8544.h file as follows:
PCD8544(uint8_t sclk = 3, // clock (display pin 2)
uint8_t sdin = 4, // data-in (display pin 3)
uint8_t dc = 5, // data select (display pin 4)
uint8_t reset = 12, // reset (display pin 8)
uint8_t sce = 13); // enable (display pin 5)
Changing these pin outs allowed me to control it with the remaining pins on the board. Now I can have both the display and the LTE shield at the same time! Essentially, the old PCD8544 library had used pins 3,4,5,6, and 7, for simplicity. I however couldn’t use 6 and 7, as those were taken by the LTE shield. So, I swapped them in the header file to point to pins 12 and 13, since they were not being used.
The only problem I ran into, though, was space. It takes a lot of space for the fona library to run the LTE shield. Originally, I was going to use the U8 library, but using those two together actually took 109% of the storage space on the Arduino Uno. I tried to trim down the portions of code for the fona side, but couldn’t get everything small enough. Fortunately, the PCD8544 library was much, much smaller, and I found that it even has a simpler interface for text only, which is mostly what I want to use the screen for.
With those two libraries pared up, I added some lines to my LTE demo sketch to allow me to display the battery information on the Nokia 5110 screen. All told the sketch uses 26470 bytes (82%) of the program storage space, the maximum is 32256 bytes. It worked great, looked good, and still leaves room for more programming.
You can check out the full commit, of course, but here is the portion about the screen:
case ‘b’: {
// read the battery voltage and percentage
uint16_t vbat;
if (! fona.getBattVoltage(&vbat)) {
Serial.println(F(“Failed to read Batt”));
} else {
lcd.setCursor(0, 0);
lcd.print(“Battery Status”);
Serial.print(F(“VBat = “)); Serial.print(vbat); Serial.println(F(” mV”));
lcd.setCursor(0, 1); lcd.print(“VBat = “); lcd.print(vbat); lcd.print(” mV”);
}if (! fona.getBattPercent(&vbat)) {
Serial.println(F(“Failed to read Batt”));
} else {
Serial.print(F(“VPct = “)); Serial.print(vbat); Serial.println(F(“%”));
lcd.setCursor(0, 2); lcd.print(“VPct = “); lcd.print(vbat); lcd.print(“%”);
}break;
}
Really simple commands to set up the cursor, and then just lcd.print to display information. I really like this simple screen library for text. It doesn’t handle graphics too well, though, which is what the U8 library excelled at.
So I guess now I need to work out some sort of menu system, as well as some sort of buttons if I want to turn this thing into a portable texting/gps/data interface device.
Linux – keep it simple.