Hi, I greet, I need advice. I have created a simple connection with the LM-35 temperature sensor on A0 for the Arduino Uno clone and I used the TM1637 display according to the TM1637 library. But now there has been a problem. If I have the sensor connected by the USB Serial.Print, it shows the values correctly. However, if I used the connection with the display, they skip on the display over some unspecified time intervals of 2 close values in the range of about 0.5-1 ° C. Originally I wanted to create a thermometer that would record the time and temperature of the SD card, but the problem was similar. Didn't anyone know what it is?
I don't understand what you are talking about, but maybe it will be cleared up when you read the pinned post 'How to get the most from the forum'
Once we see your wiring and code, we might understand more.
It could be either a hardware problem or it could be a software problem
or both…
We need way more details about your project.
So provide a description, a schematic, a photo of your setup and a logged print…
If we could see your code, then perhaps...
Yup, sorry, but struggling to decipher that as well.
describes nothing that makes any sense
connected? by? what? how? huh?
pretend that none of us know what you think, only what you write.
Let me have a go at translating the words into understandable English
Could mean :- “I have the sensor value displayed using the serial monitor window”
I take this to mean that the serial monitor window works as expected. But when the value from the sensor is shown on the TM1637 display it shows a changing value between that vary only between one or two values.
Assuming that this is a correct interpretation of what was asked, I would give the following advice.
-
All A/D readings change by one significant bit, that is the nature of every A/D on the planet.
-
If you do any processing on that value, that is change it into a float (which you are doing because of the fractional value you are showing) you will see this fluctuation. If however you print this float value as an integer you may not see these changes.
-
There are software methods to get around this involving thresholds. That is to only change your output when the previous output has changed by a certain amount.
-
Read look at this How to get the best out of this forum before you proceed any further. It tells you how things work here about posting code.
-
Post your code.
-
Post a schematic of your circuit.
Only when you have done that can we start to help you.
Try connecting a 2k to 10k resistor between the LM35 output pin and ground, see if that helps with jitter. Worked for me.
Schematic is : LM-35 - 1 - Vcc +5V, 2 - A0, 3 - GND ; TM1637 - CLK - 2, DIO 3, Vcc - Vcc + 5V, GND - GND
Code is here:
#include <Arduino.h>
#include <TM1637Display.h>
#define CLK 2
#define DIO 3
#define lmPin A0
float tem = 0;
long lmVal = 0;
TM1637Display displej(CLK, DIO);
void setup() {
Serial.begin(9600);
displej.setBrightness(10);
}
void loop()
{
// teploměr
lmVal = analogRead(lmPin);
tem = (lmVal * 0.0048828125 * 100);
Serial.print("LM-35, Teplota = ");
Serial.print(tem);
Serial.println("°C");
//displej
uint8_t vypis[] = { 0, 0, 0, 0 };
long prom = tem*100;
vypis[0] = displej.encodeDigit((prom/1000)%10);
vypis[1] = displej.encodeDigit((prom/100)%10);
vypis[2] = displej.encodeDigit((prom/10)%10);
vypis[3] = displej.encodeDigit((prom%10));
displej.setSegments(vypis);
delay(500);
}
I think that this is HW problem because it´s only if TM1637 is connected. Code is from library example and from seller of the board. I try to connect capacitor between Vcc and Gnd of senzor but it doesn´t help. Maybe here is some disturbing from the clock display, or disbalancing of voltage of the board. It will be better to try simple LED four digits display. Thanks.
Hi @tomlib ,
I found a hint that one has to call the function
clear() before each setSegments() call to avoid remainders of previous data.
You may try this
// ...
displej.clear();
displej.setSegments(vypis);
// ...
in your sketch.
Good luck!
ec2021
This was the source of the hint
https://www.instructables.com/How-to-Use-the-TM1637-Digit-Display-With-Arduino/
The TM1637 is a 4 digit 7 seg LED display. Trying another probably won't solve your problem.
Are you using a soldrless breadboard with long jumper wires?
Since you have a 10 bit ADC, having the readings fluctuare 0.5 degrees could be normal for your set-up.
Please provide details about your hardware set-up
Hi, @tomlib
Welcome to the forum.
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Can you post some images of your project?
So we can see your component layout.
Thanks.. Tom....
![]()
The LM35 temperature sensor is a well established, simple analogue device.
I have used many without problems. Just Ground, Vcc and output pins.
However, you must read and understand the data sheet which will include any precautions you must take by adding addition components to ensure stability if using long leads.
You could try just powering up and putting a meter or scope on the output.
You can use them as is for air temperature measurements, encapsulate for liquids or strap them to heating pipes.
Tip. If you want to check them over a wide range of temperatures, buy a can of pipe freezer spray to quickly get you down to sub-zero temperatures
Your code might miss a displej.begin() call.
Many libraries have such call to initialize the pins used.
Can you share a link to the library used? (github)
And version? (latest I assume)
Alternative might be to use my TM1637 library
I think the missing instructions are the reason of the case. Display seems work properly. It can be caused with the hardware problem. Today I try to reconect the senzor to A2 or A3 and the board gives results as the sensor is not connected over that I several times overwrite the routine to the board of UNO. The schematic is very simple there are only 7 wires and no other components than LM-35 and TM1637. Can someone try the same circuit to compare results?
Schematics:
TM1637:
DIO ------------------------- 3
ClK----------------------------2
GND-----------------------GND
Vcc--------------------------Vcc
LM35
1------------------------------Vcc
2------------------------------A0
3------------------------------GND
As I said you only have a10 bit ADC, so the resolution would be 4.88mV, that translates to 0.488 degrees.. So seeing the temperature flicker +/- 0.5 degrees can happen.
As I said a breadboard with long wires can cause extra noise pickup.
It can also cause intermittent connection as you are now seeing.
Some milivolts are probably lost. ![]()
Are you asking a question?