so I have the KY-028 digital temperature sensor and I have it hooked up to a 0.96in OLED display with an Arduino uno, I found some simple code just to display the data onto the screen, but all the sensor readings are in the hundreds for some reason and I can't figure out how to get it to output data in degrees Celsius.
im using and it displays the data from the sensor(in hundreds) when I switch it to digital read it just stays at 1.00
here's my code, wiring setup at the bottom.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.setTextColor(WHITE);
}
void loop() {
float sensor=digitalRead(A0);
display.setCursor(0, 0);
display.print("Tempature: ");
display.println(sensor);
display.display(); //you have to tell the display to...display
delay(2000);
display.clearDisplay();
}
DISPLAY:
SDA---A4
SLC---A5
VCC---3.3v
GND---GND
TEMP Sensor:
A0---A0
DO---pin 12
VCC---5v
GND---GND
arduino getting power from computer USB for now
any help is appreciated and if you need any more info that I didn't put here ill be glad to provide it, thanks!
My guess is that the NTC thermistor on that module (the ky-028 not being a sensor, but the module as a whole) needs a library to read the digital pin, and probably some formula to convert the analog reading to a temperature.
A simple one-time read of a digital pin can only ever be 0 or 1 by definition, so it needs to read and digest a stream of those I'd say, to arrive at some value.
elvon_blunden:
My guess is that the NTC thermistor on that module (the ky-028 not being a sensor, but the module as a whole) needs a library to read the digital pin, and probably some formula to convert the analog reading to a temperature.
A simple one-time read of a digital pin can only ever be 0 or 1 by definition, so it needs to read and digest a stream of those I'd say, to arrive at some value.
ok, how would I go about doing that? sorry, I not that good with the coding side of things...
I understand that I need to include a library, and I've done that, I used the example sketch and its now outputting the temperature correctly in the serial monitor.
could you by any chance help me merge these two "scripts or sketches?" together (sorry I couldn't think of another word for them)
code from example sketch from library:
#include <ACI_10K_an.h>
void setup() {
Serial.begin(9600);
}
void loop() {
Aci_10K an10k; //start an instance of the library
//Aci_10K an10k(3.3,12);support for 3.3 volt board and/or 12bit analog read resolution
Serial.print("temp: ");
Serial.println(an10k.getTemp(analogRead(0)));
delay(1000);
}
It looks like that the following schematic does correspond to your Project Kit -- KY208; if so, can you measure on-going changing temperature with this one?
GolamMostafa:
\It looks like that the following schematic does correspond to your Project Kit -- KY208; if so, can you measure on-going changing temperature with this one?
A look at the schematic tells me "no".
It's a kind of temperature switch - switching it's output when the temperature is above or below a certain point. Like a thermostat, but without a scale on the setting screw.