Report Bugs Here

Moderator: Mmiscool

User avatar
By Al McDivitt
#74329
Mmiscool wrote:At the top of your code set Temp = 0

When you create the text box with a variable that is not initialised it creates the variable as a string by default and not a number.


Thanks for your help

took out the textbox, set Temp and Hum = 0
now just shows 0 for both values.
Don't spend too much time on this. thanks AL


memclear
cls
oled.cls()
Temp = 0
Hum = 0
PinDHT = 2
DHT.SETUP(11, PinDHT)


i2c.setup(4,5)
timer 1000, [branch] ' ## Time for auto refresh variables ##


oled.print("Current Temperature", 10,1)
oled.print(str(Temp), 10,10)
oled.print("Current Humidity", 10,18)
oled.print(str(Hum), 10,28) '** Hum not showing on OLED
oled.print("Your IP is:", 10,36)
oled.print(ip(), 30,48)



Wait


[TestExit]
timer 0
end

[branch]
gosub [readdata]
wait

[readdata]

Temp = DHT.TEMP() 'Current Temperature
Hum = DHT.HUM() 'Current Humidity
User avatar
By Al McDivitt
#74330
Mmiscool wrote:At the top of your code set Temp = 0

When you create the text box with a variable that is not initialised it creates the variable as a string by default and not a number.

Thanks
no joy
all I get now is 0 as the value
Please don't waste your time on this, I'll keep playing around.
I really love ESPBasic.
Just for Info
cheer's AL

current code is

memclear
cls
oled.cls()
Temp = 0
Hum = 0

PinDHT = 2
DHT.SETUP(11, PinDHT)



i2c.setup(4,5)
timer 1000, [branch] ' ## Time for auto refresh variables ##


oled.print("Current Temperature", 10,1)
oled.print(str(Temp), 10,10) ' *** Temp not showing on OLED
oled.print("Current Humidity", 10,18)
oled.print(str(Hum), 10,28) '** Hum not showing on OLED
oled.print("Your IP is:", 10,36)
oled.print(ip(), 30,48)


'textbox Temp ' *** Temp IS showing in textbox
Wait


[TestExit]
timer 0
end

[branch]
gosub [readdata]
wait

[readdata]

Temp = DHT.TEMP() 'Current Temperature
Hum = DHT.HUM() 'Current Humidity
User avatar
By Al McDivitt
#74331
Mmiscool wrote:At the top of your code set Temp = 0

When you create the text box with a variable that is not initialised it creates the variable as a string by default and not a number.


Thanks, hope this is not a double post be me, ( I'm visually disabled so please forgive a bit ) thought I did this earler today.
tried your tip all I got was 0 as the value.
I think I have a problem with my loop only running once. but still don't see why the Temp value shows right in the textbox but not on the oled.

Please don't spend too much time on this I really like ESPBasic, will keep playing with the code on may end
thanks for the help so far.

where the code is now...

memclear
cls
oled.cls()
Temp = 0
Hum = 0

PinDHT = 2
DHT.SETUP(11, PinDHT)



i2c.setup(4,5)
timer 1000, [branch] ' ## Time for auto refresh variables ##


oled.print("Current Temperature", 10,1)
oled.print(str(Temp), 10,10) ' *** Temp not showing on OLED
oled.print("Current Humidity", 10,18)
oled.print(str(Hum), 10,28) '** Hum not showing on OLED
oled.print("Your IP is:", 10,36)
oled.print(ip(), 30,48)


textbox Temp ' *** Temp IS showing in textbox
Wait




[branch]
gosub [readdata]
wait

[readdata]
Temp = DHT.TEMP() 'Current Temperature
Hum = DHT.HUM() 'Current Humidity
User avatar
By Mmiscool
#74340 Do you have a return after the bit of code that gets the temp?

Do you have code that writes the variable to the old display after receiving the temp. The oled needs to have the data written to it each time. It won't update by it self.