Hello all,
I’m reading temperature from a LM35 CAZ (TO-92) sensor and displaying it to the LCD.
However, I’m running into 2 issues:
-
When trying to use analogReference(INTERNAL), compiling fails with the Wio Terminal and says INTERNAL was not declared in this scope. How do I reference an internal voltage of 1.1v (or whatever other reference voltage available), if possible?
-
Is there a way to easily print floats with two decimals to the LCD? It seems I may have to convert the decimals to INTs and then use drawNumber… suggestions?
#include <SPI.h> #include <Seeed_FS.h> #include "SD/Seeed_SD.h" #include"seeed_line_chart.h" //include the library #include "TFT_eSPI.h" #include "Free_Fonts.h" TFT_eSPI tft; TFT_eSprite spr = TFT_eSprite(&tft); // Sprite #define time_increment 1000 #define x1 20 #define y1 10 #define w1 200 #define sensorPin A0 float sensorVal; float voltage; float temperature; void setup() { Serial.begin(115200); analogReference(DEFAULT); // declare the analog pins as inputs...? not sure if necessary... pinMode(sensorPin, INPUT); tft.begin(); tft.setRotation(3); tft.fillScreen(TFT_BLACK); tft.setFreeFont(FMB9); //bold, 9pt font } void loop() { // Read sensor values sensorVal = analogRead(sensorPin); // Convert sensor value to voltage voltage = sensorVal * (1100/1024.0); // Convert voltage to Celcius temperature = voltage / 10; // print values to serial monitor Serial.print(temperature); Serial.print(" \xC2\xB0"); // shows degree symbol Serial.println("C"); // display values to LCD tft.drawString("Temp: ",x1, y1); tft.drawString(" ",w1,y1); tft.drawNumber(temperature,w1,y1); delay(time_increment); }