Please I am having problems displaying the temperature values on an adafruit ssd1306 LCD. I have tested the LCD with the code from @peekay123 and it is getting to display “Hello World”. I have also been able to display time and date on it. I subscribed to one of my events involving temperature measurements and I have tested it and verified that the subscription is working as required using the blynk app however, the problem is that the LCD is not displaying the subscribed temperature values. Am not sure if I will need to create a new function for the display part. Please help me out. Below is the code am using…
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_SSD1306/Adafruit_SSD1306.h"
#define OLED_DC A1
#define OLED_CS A2
#define OLED_RESET D0
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char logo16_glcd_bmp[] =
{ 0B00000000, 0B11000000,
0B00000001, 0B11000000,
0B00000001, 0B11000000,
0B00000011, 0B11100000,
0B11110011, 0B11100000,
0B11111110, 0B11111000,
0B01111110, 0B11111111,
0B00110011, 0B10011111,
0B00011111, 0B11111100,
0B00001101, 0B01110000,
0B00011011, 0B10100000,
0B00111111, 0B11100000,
0B00111111, 0B11110000,
0B01111100, 0B11110000,
0B01110000, 0B01110000,
0B00000000, 0B00110000 };
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
float temperature = 100;
int displayTime();
void setup()
{
Particle.subscribe("Body_Temperature", myHandler, "380034000a47343432313031");
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC); // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.clearDisplay(); // clears the screen and buffer
delay(1000);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(30,45);
display.println("Temperature");
display.println(temperature);
}
void loop()
{
//Show the time and date
displayTime();
}
void myHandler(const char *event, const char *data)
{
temperature = atof (data);
}