Post about your Basic project here

Moderator: Mmiscool

User avatar
By forlotto
#48249 Yes correct the designators are laid out for nodemcu and basic wifi dev kit so you can just look at the board and make life ez it maps the ports for you I remember this addition to the software some time ago I was like man that is nice!

Anyhow glad you figured it out.

Enjoy.
User avatar
By joeman2116
#48534 I have been playing with the Thermostat and having fun wiring up the hardware. The program works well.
I am trying to do a few things but cant seem to figure out the the syntax and there seems to be no examples around.
I have tried all kinds of combinations but either it does not work or I get syntax error.

1. I would like to put the set temperature inside an html box / or table with the box color being green and the font to be larger.

2. Also am trying to put the actual temperature readout in there own colored box / table with a larger font.

3. Change the background color of the web server

I am sure there are others who like to do the same, and once we have a working example -- it can be used for other similar projects.
SCREEN SHOT- Attached
-------------------------------------------------------------------------------------------------------------------------
memclear
SERIALPRINTLN "restart page"
cls
ip()
let tf = 0
let curr = 0
let setp = 31
let stat = On
wprint "<head>"
wprint "<meta http-equiv='refresh'content='10;URL=/input?'>"
wprint "</head>"
wprint "<table bgcolor='lightblue' border='1' cellpadding='5'>"
wprint "<th><h1>WiFi Sensor + Thermostat</h1></th>"
wprint "<th</th></table><br>"
wprint "<div><table bgcolor='Yellow' border='1' cellpadding='5'>"
wprint "<tr><th>Sensor</th><th>TempC</th><th>TempF</th></tr>"
wprint "<tr><td>DS18B20P</td>"
wprint "<td bgcolor='cyan'></td>"

'wprint htmlvar(curr) & "</td>" --- code i have tried but dont work

wprint "<td bgcolor='lightgreen'></td>" -- --- works
'wprint htmlvar(tf) & "</td></tr>" - -- code does not appear inside the light green box

'wprint "<tr><td>DS18B20P</td><td bgcolor='cyan'>htmlvar(curr) & "</td>"<td bgcolor='lightgreen'>wprint htmlvar(tf) & "</td>"</tr>" - ---- another test -
print
Button "Set Temperature" [setpt]
textbox setp
wprint "<br><br>"
wprint "Current Temp - Celsius= "
wprint htmlvar(curr)
wprint "<br><br>"
wprint "Current Temp - Fahrenheit= "
wprint htmlvar(tf)
wprint "<br><br><br><br>"

wprint "COOLING FAN="
wprint htmlvar(stat)
wprint "<br><br><br>"
Button "Exit" [quit]
wprint "<br>"
timer 4000, [refresh]
wprint "<br>"

wait

[on2]
po D2 1
SERIALPRINTLN "GPIO 2 ON"
let stat = "On"
Wait

[off2]
po D2 0
SERIALPRINTLN "GPIO 2 OFF"
let stat = "Off"
Wait

[setpt]
wprint "<head>"
wprint "<meta http-equiv='refresh' content='10;URL=/input?'>"
wprint "</head>"

Wait

[refresh]

temp 0 curr ' read current temperature for device 0 db1820
tf = curr * 9
tf = tf / 5
tf = tf + 32
SERIALPRINTLN curr
SERIALPRINTLN tf
if curr > setp then goto [on2] else goto [off2] 'TURN FAN ON IF CURRENT TEMP IS GREATER THEN SETP
Wait

[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end

I would very much appreciate if someone would help with coding.
Thanks
Joe :)
You do not have the required permissions to view the files attached to this post.
User avatar
By forlotto
#48543 for starters I would learn that the io command is being used now as the po command has been dropped!

so this code here I would change asap!

Code: Select all[on2]
po D2 1
SERIALPRINTLN "GPIO 2 ON"
let stat = "On"
Wait

[off2]
po D2 0
SERIALPRINTLN "GPIO 2 OFF"
let stat = "Off"
Wait


Change this to the following:
Code: Select all[on2]
io(po,D2,0)
SERIALPRINTLN "GPIO 2 ON"
let stat = "On"
Wait

[off2]
io(po,D2,1)
SERIALPRINTLN "GPIO 2 OFF"
let stat = "Off"
Wait


Change that little bit of code and see what happens for starters!

Also you should look over your code I notice you are missing things look at the following line for instance do you see anything missing?

Code: Select allwprint "<th</th></table><br>"


May want to consider this operator as well when comparing setp <> Not Equal is what it means not 100% on temp sensors and the setp thing but just a thought.

The other suggestion I have is start with something simple make sure you are getting a reading first then build off of that. From what I can tell if I recall correctly it does not appear that you are getting a reading at those values. Do you have your voltage and data lines etc all hooked up correctly? Errr I am not the most temp sensor savy person but there seems to be a lot of questions about temp sensors here lol just trying to help you make a little progress if anything.
User avatar
By forlotto
#48574 One other thing I noticed is that you are using serialprintln ?

SERIALPRINTLN:

Will output text or a variable to the serial interface only. Will terminate with a new line.

serialprintln {value or var}

If you are trying to print on the page you might not want to use serial print line however if you are using a serial interface go ahead have at it...

Normally the print "enter what you want to print here" or print variable works fine.

Any rate just a heads up I suggest you start with something smaller maybe just to get a reading.... Double check your code for missing items and improper statements I just had an odd lightbulb go off remembering reading your code last night and decided to drop by and mention these things mainly serialprintln I suppose I did not pay close attention and read through all your code but for what ever reason the thought popped into my head an figured I'd bring it up.

Read the reference material closely you'll start to understand why things are not working there is a difference between the serial interface and the general interface that you are communicating with something like termite is a serial interface the web interface and the serial interface are NOT one in the same so to speak. I don't know what it is you are doing or your full project so maybe you might need your code to do this but from the post and the looks of what you are describing it is not a serial interface that you are using while you could have left some info out IDK.