Wrong output display in TM1637 Display, correct in Serial Monitor

Hi,

I am making a project to display Time & Gas Leakage detector for Kitchen.
I am using TM1637 for display, DS3231 for RTC & MQ-2 for gas leakage detection.

While running the attached code, I am getting correct time displayed but the Gas sensor output is incorrect in Display.
But the output is correct in Serial Monitor.

I have searched google and some programming guide but to no avail.
Can you please correct my mistake.
Below is the code snippet:

const byte gas_sensor = 0; 
int gas_level;

gas_level= analogRead(gas_sensor);  
display.point(POINT_OFF);
display.display(gas_sensor);
Serial.println(gas_level);

GAS_TIME_TM1637_DS3231.ino (1.51 KB)

(deleted)

Hi,

const byte gas_sensor = 0;
int gas_level;

gas_level= analogRead(gas_sensor); 
display.point(POINT_OFF);
display.display(gas_sensor);
Serial.println(gas_level);

you send [u]gas_level[/u] to the monitor but send [u]gas_sensor[/u] to the display.

Tom... :)

I am making a project to display Time & Gas Leakage detector

I'd like a time leakage detector too. I seem to be losing a lot of it lately. :(

TomGeorge:
Hi,

const byte gas_sensor = 0;

int gas_level;

gas_level= analogRead(gas_sensor);
display.point(POINT_OFF);
display.display(gas_sensor);
Serial.println(gas_level);



you send **[u]gas_level[/u]** to the monitor but send **[u]gas_sensor[/u]** to the display.

Tom... :)

Corrected the code to output “gas_level”, still output seems to be garbled.

gas_level= analogRead(gas_sensor); //Gas Sensor get data
display.point(POINT_OFF);
display.display(gas_level);
Serial.println(gas_level);

Sometimes output is 0400, 8CUU, 040, 8888, or even strange character like incomplete digits, characters etc.
The display in Serial monitor is correct like:
154
161
152
152
157
152

Regards,
Amandeep Singh

Hi,
Can you show us a picture of your project please.
What sort of display are you using?

Tom… :slight_smile:

Please find the attached images for the project.

I am using TM1637 display.

I use this Library for the
https://codebender.cc/library/TM1637#TM1637.h

I think there is either a variable type declaration error or the display library calling function is wrong. Please assist in resolving my issue.

Issue resolved after Library code analysis.

Below is the final Code snippet that worked:

void loop() { gas_level= analogRead(gas_sensor); display.DigitDisplayWrite(CLK,DIO,gas_level); Serial.println(gas_level); delay (1000); }

amanjosan2008: Issue resolved after Library code analysis.

There must be a lesson in that somewhere..... ;)