I haven't had any success displaying anything in the LCD with the Mailbox Notifier Upgrade. I ordered a second LCD thinking maybe the first was defective but still nothing appears. I used your MailboxNotifier2_receiver.ino sketch but I converted it to use the RFM69 library. It works fine when I test it in the Arduino IDE Serial Monitor. I have also tried the LCD_C0220BiZ_test.ino sketch to no avail. At this point I'm not sure if it's my circuit or my code that is the problem. Any help would greatly be appreciated.
Attached is a picture of my breadboard.
Here are the readings I get on the LCD pins:
#2 - SCL = 3.28
#3 - SDA = 3.28
#5 - VDD = 3.29
#6 - VOUT = 2.75
#7 - C1+ = 3.10
#8 - C1- = .24
Here are the members in my RFM69 library:
Keywords.txt
LCD_C0220BiZ.cpp
LCD_C0220BiZ.h
Lcd.h
RFM69.cpp
RFM69.h
RFM69registers.h
SPI.h
SPIFlash.h
ST7036.h
twi.c
twi.h
wire.h
Note: SPI, SPIFlash, ST7036 and WIRE are separate libraries.
And here's the MailboxNotifier2_receiever.ino code:
// Standalone receiver with LCD Moteino based MailboxNotifier
// This is the code running on the receiving end that displays info on LCD
// LowPowerLab.com - 2013-8-25 (C) [email protected]
// http://opensource.org/licenses/mit-license.php
// uses the RFM12B library found at: https://github.com/LowPowerLab/RFM12B
// the LCD libraries are found in separate ZIP file (source: https://bitbucket.org/fmalpartida/st7036-display-driver/wiki/Home)
#include <Arduino.h>
#include "ST7036.h"
#include "LCD_C0220BiZ.h"
#include <Wire.h>
#include <RFM69.h>
#include <SPI.h>
#define SERIAL_BAUD 115200
#define NODEID 1 // network ID used for this unit
#define NETWORKID 100
#define FREQUENCY RF69_433MHZ //Match this with the version of your Moteino! (others: RF12_433MHZ, RF12_915MHZ)
#define ENCRYPTKEY "sampleEncryptKey"
#define ACK_TIME 50 // # of ms to wait for an ack
#define LED 9
#define LDRPIN A0 //light sensor on pin A0 for backlight purposes
#define BACKLIGHTPIN 6
char temp[MAX_DATA_LEN];
RFM69 radio;
ST7036 lcd = ST7036 (2, 20, 0x78, BACKLIGHTPIN); //row count, column count, I2C addr, pin for backlight PWM
unsigned short status_code;
typedef struct {
unsigned long lastOpen;
unsigned long lastClosed;
unsigned short battery;
} Payload;
Payload theData;
byte battChar[8] = {0b00000,0b01110,0b11111,0b11111,0b11111,0b11111,0b11111,0};
void setup()
{
pinMode(LED, OUTPUT);
radio.initialize( FREQUENCY, NODEID, NETWORKID);
radio.encrypt(ENCRYPTKEY);
Serial.begin(SERIAL_BAUD);
char buff[50];
sprintf(buff, "Listening at %d Mhz...", FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY== RF69_868MHZ ? 868 : 915);
Serial.println(buff);
lcd.init();
lcd.setContrast(10);
lcd.clear();
lcd.load_custom_character(0, battChar);
lcd.setCursor(0,4);
lcd.print("initialized");
}
byte recvCount = 0;
int milliCount=0;
void loop()
{
if (radio.receiveDone())
{
digitalWrite(LED,HIGH);
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
if (radio.DATALEN != sizeof(Payload))
for (byte i = 0; i < radio.DATALEN; i++)
Serial.print((char)radio.DATA[i]);
else
{
theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else
char periodO='X', periodC='X';
long lastOpened = theData.lastOpen;
long lastClosed = theData.lastClosed;
long LO = lastOpened;
long LC = lastClosed;
char* MLOstr="LO:99d23h59m";
char* MLCstr="LC:99d23h59m";
char* BATstr="BAT:1024";
if (lastOpened <= 59) periodO = 's'; //1-59 seconds
else if (lastOpened <= 3599) { periodO = 'm'; lastOpened/=60; } //1-59 minutes
else if (lastOpened <= 259199) { periodO = 'h'; lastOpened/=3600; } // 1-71 hours
else if (lastOpened >= 259200) { periodO = 'd'; lastOpened/=86400; } // >=3 days
if (lastClosed <= 59) periodC = 's';
else if (lastClosed <= 3599) { periodC = 'm'; lastClosed/=60; }
else if (lastClosed <= 259199) { periodC = 'h'; lastClosed/=3600; }
else if (lastClosed >= 259200) { periodC = 'd'; lastClosed/=86400; }
if (periodO == 'd')
sprintf(MLOstr, "LO:%ldd%ldh", lastOpened, (LO%86400)/3600);
else if (periodO == 'h')
sprintf(MLOstr, "LO:%ldh%ldm", lastOpened, (LO%3600)/60);
else sprintf(MLOstr, "LO:%ld%c", lastOpened, periodO);
if (periodC == 'd')
sprintf(MLCstr, "LC:%ldd%ldh", lastClosed, (LC%86400)/3600);
else if (periodC == 'h')
sprintf(MLCstr, "LC:%ldh%ldm", lastClosed, (LC%3600)/60);
else sprintf(MLCstr, "LC:%ld%c", lastClosed, periodC);
sprintf(BATstr, "BAT:%i", theData.battery);
sprintf(temp, "%s %s %s", MLOstr, MLCstr, BATstr); //sprintf(sendBuf, "MLO:%ld%c MLC:%ld%c", lastOpened, periodO, lastClosed, periodC);
byte len = strlen(temp);
Serial.print(temp); Serial.print(" ("); Serial.print(len); Serial.print(")");
lcd.clear();
lcd.setCursor(0,0);
lcd.print(MLOstr);
lcd.setCursor(1,0);
lcd.print(MLCstr);
float battV = ((float)theData.battery * 3.3 * 9)/(1023*2.8776);
dtostrf(battV, 3, 2, BATstr);
Serial.print(BATstr);Serial.print("v");
//sprintf(temp, "BAT:%sv", BATstr);
//lcd.setCursor(0,11);
//lcd.print(temp);
lcd.setCursor(0,14);
lcd.print(char(0));
lcd.setCursor(0,15);
sprintf(temp, "%sv", BATstr);
lcd.print(temp);
}
if (radio.ACK_REQUESTED)
{
byte theNodeID = radio.SENDERID;
radio.sendACK();
}
delay(5);
digitalWrite(LED,LOW);
Serial.println();
}
//update backlight every second
if (millis() - milliCount > 1000)
{
milliCount = millis();
int LDR = analogRead(LDRPIN);
lcd.setBacklight(map(LDR, 0, 1024, 0, 255));
lcd.setCursor(1,19);
}
}
// wait a few milliseconds for proper ACK to me, return true if indeed received
static bool waitForAck(byte theNodeID) {
long now = millis();
while (millis() - now <= ACK_TIME) {
if (radio.ACKReceived(theNodeID))
return true;
}
return false;
}
Ok, I've done the RFM69 convesion myself, this code is tested and working, as long as you wire the LCD correctly. From the picture it's hard to tell exactly but I think you got power and SCL/SDA with pullups which looks right.
https://github.com/LowPowerLab/MailboxNotifier/blob/master/MailboxNotifier3_receiver.ino
Also the sender for this:
https://github.com/LowPowerLab/MailboxNotifier/blob/master/MailboxNotifier3_sender.ino
Hope this helps
I uploaded your new sketch and the LCD is still not displaying anything. Must be my wiring. Thanks for your help.