guido57 / MyThermostat

A home wi-fi thermostat with a Raspberry PI-3 with LCD screen and an ESP8266 measuring the room temperature wireless.
2 stars 0 forks source link

error #1

Closed unupingu closed 6 years ago

unupingu commented 6 years ago

hy. how can fix the error "no module named tkinter" thanks.

guido57 commented 6 years ago

Hi Unupingu.

The following command should install the tkinter module in your raspberry

apt-get install python-tk python3-tk

Let me know,

Guido

unupingu commented 6 years ago

Thanks for your quik response but when i run sudo python MultiPage. py i get the same error When i run sudo python3 Multiple.py i get the error no module ptvsd

guido57 commented 6 years ago

Hi again. Three points:

guido57 commented 6 years ago

Of course, let me know your progress 👍 Bye

unupingu commented 6 years ago

no its not working.i get this error.

pi@raspberrypi:~/MyThermostat/Raspberry $ sudo apt-get install python-tk python3-tk Reading package lists... Done Building dependency tree Reading state information... Done python-tk is already the newest version (2.7.13-1). python3-tk is already the newest version (3.5.3-1). 0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded. pi@raspberrypi:~/MyThermostat/Raspberry $ python3 MultiPage.py File "MultiPage.py", line 13 from tkinter import Tk, Button, PhotoImage, messagebox ^ IndentationError: expected an indented block

guido57 commented 6 years ago

Ok, two more points:

  1. Because you commented the three lines above, you have to comment the "if" statement also. So modify MultiPage.py in such a way:

    # if os.name == 'posix':
    #    # on raspberry
    #    print("ptvsd.enable_attach('my_secret')")
    #    import ptvsd
    #    ptvsd.enable_attach('my_secret')
  2. I forgot to place AnimatedGIF.py on github, but now it's present and you can download it.

Go now!

unupingu commented 6 years ago

now i have this error

pi@raspberrypi:~/Downloads/MyThermostat/Raspberry $ sudo python3 MultiPage.py Starting server, use to stop Traceback (most recent call last): File "MultiPage.py", line 506, in app = SampleApp(server.queue) File "MultiPage.py", line 48, in init Tk.init(self) File "/usr/lib/python3.5/tkinter/init.py", line 1880, in init self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable

unupingu commented 6 years ago

do you have a image builded of this project that you can send me.

guido57 commented 6 years ago

Hi. Well, I think you are just a millimeter far from the finish line!

The error "no display name and no $DISPLAY environment variable" comes out when there's no X11 (Unix/Linux standard graphic interface) configured or when Raspbian doesn't know which display to use. For this reason, even if I send you a working Raspberry image, you have to solve this problem all the same so:

  1. attach an HDMI screen to you Raspberry and reboot
  2. or connect a TFT Screen as I showed
  3. or activate "VNC server" on your Raspberry doing sudo raspi-config and connect to it with any "VNC client": this generated an X11 server automatically

In any case, if you run from a remote shell, enter: export DISPLAY=:0.0 just once

Bye

unupingu commented 6 years ago

IT WORKS!!! (:(: THE FILE THAT I HAVE TO UPLOAD (thermo. lua)TO THE ESP8266 ,I HAVE TO CHANGE SOMETHING ?LIKE SSID/ PASSWORD.

guido57 commented 6 years ago

I'm very happy to know that. To connect your ESP8266 (with NodeMCU installed) to your local WIFI network simply do this, changing SSID and PWD with yours.

-- Connect to Wi-Fi network wifi.setmode(wifi.STATION) wifi.sta.config(SSID, PWD)

-- Wait for a few seconds and then check your ESP8266 obtained an IP address print("Connected to network " .. SSID) print("IP: " .. wifi.sta.getip())

After that, ESP8266 NodeMCU will retain these setting and automatically connect to your WIFI after any reset. Just to be safe, simply do: wifi.sta.autoconnect()

unupingu commented 6 years ago

where do i put this wifi.setmode(wifi.STATION) wifi.sta.config(SSID, PWD) i dont find them nowere

guido57 commented 6 years ago

Well, to answer your question I need to know the environment you're using to program your ESP8266 NodeMCU device. I'd suggest ESPlorer for Windows. You need to execute those commands only once, so you can:

unupingu commented 6 years ago

I use ESPlorer After lunching wifi.setmode(wifi.STATION) wifi.sta.config(SSID, PWD) Then i have to lunch thermo.lua and init.lua. ?

guido57 commented 6 years ago

Yes. Launch: wifi.setmode(wifi.STATION) wifi.sta.config(SSID, PWD) To be sure ESP is connected to the wifi, check the obtained IP Address for the ESP with: wifi.sta.getip() If everything is ok you'll have something like: 192.168.1.111 255.255.255.0 192.168.1.1

Now go to the Raspberry and take note of its IP Address, i.e. 192.168.1.69 Change line 84 of thermo.lua with url = "http://192.168.1.69:2048"

Now, for testing, simply launch, using ESPlorer: thermo.lua Raspberry should receive the measured temperature and show it on the screen once.

I'd suggest to configure your router to reserve always the same IP to your Raspberry