Betreff: Modul ESP32-4848S040

If doesn't fit into any other category ....
Helmut_number_one
Posts: 93
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 36 times
Been thanked: 8 times

Re: Betreff: Modul ESP32-4848S040

Post by Helmut_number_one »

Thankyou in advance.
In most of the pictures I add temperature texts, they should be added with MQTT and or UDP.
But I'm still trying, only the tips are important if I get stuck.
How I turn the page and how I don't get any old switches on the new page is new to me.
But you have also created a lot of possibilities with ESP Basic, respect !!!
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 1995
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 428 times
Been thanked: 1335 times
Contact:

Re: Betreff: Modul ESP32-4848S040

Post by cicciocb »

If I understand well, you want several "pages" that contains the images of your floors?

A mechanism like next / previous page ?
Helmut_number_one
Posts: 93
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 36 times
Been thanked: 8 times

Re: Betreff: Modul ESP32-4848S040

Post by Helmut_number_one »

I have UDP implementiert:

Edit: oh Thankyou i will try it out, THANKYOU THANKYOU

Code: [Local Link Removed for Guests]

vga.pinout 11, 12, 13, 14, 0,   8, 20, 3, 46, 9, 10,  4, 5, 6, 7, 15,  16, 17, 18, 21
vga.delete
vga.setup 10, 8, 50, 480, 10, 8, 20, 480, 12e6, 1, 3, 2, 1

pin.mode 40, output
pin.mode 2, output
pin.mode 1, output
pin(40) = 0 'RELAY_1=40
pin(2) = 0 'RELAY_2=2
pin(1) = 0  'RELAY_3=1
tft.loadfont "/fonts/FreeSansBold10pt7b.bin", 10
'tft.loadfont "/fonts/FreeMonoBold10pt7b.bin", 11

pwm.setup 38, 7, 500

UDP.BEGIN 1234


i2c.setup 19, 45
option.touch 1
touch.idle

touch.init
touch_p = 0

vga.show
vgagui.init 50

vgagui.image 0,0,0,0, "/img/EG_480.bmp"

t1 = vgagui.textline (380,10,60, 30, "textbox", 10)
t2 = vgagui.textline (380,80,60, 30, "textbox", 10)

bi1   = vgagui.ButtonImage(140, 376, 48, 48, "/img/Lamp_on_45.bmp", "/img//Lamp_45.bmp", toggle)
vgagui.setevent bi1, CHANGE ,  Relais1
bi2   = vgagui.ButtonImage(129, 110, 48, 48, "/img/Lamp_on_45.bmp", "/img//Lamp_45.bmp", toggle)
vgagui.setevent bi2, CHANGE ,  Relais2
bi3   = vgagui.ButtonImage(310, 75, 48, 48, "/img/Lamp_on_45.bmp", "/img//Lamp_45.bmp", toggle)
vgagui.setevent bi3, CHANGE ,  Relais3
bi4   = vgagui.ButtonImage(337, 200, 48, 48, "/img/Lamp_on_45.bmp", "/img//Lamp_45.bmp", toggle)
vgagui.setevent bi4, CHANGE ,  Relais4
bi5   = vgagui.ButtonImage(250, 250, 48, 48, "/img/Lamp_on_45.bmp", "/img//Lamp_45.bmp", toggle)
vgagui.setevent bi5, CHANGE ,  Relais5
bi6   = vgagui.ButtonImage(323, 430, 48, 48, "/img/Lamp_on_45.bmp", "/img//Lamp_45.bmp", toggle)
vgagui.setevent bi6, CHANGE ,  Relais6

vgagui.refresh
vga.show

for z= 1 to 10000000
   vgagui.setText t1, str$(touch.x)
   vgagui.setText t2, str$(touch.y)
   touch.read
   vgagui.refresh 1, touch.x, touch.y, touch.z   
     onudp goudp 
   vga.show
next z

while 1
  touch.read
  print touch.x, touch.y, touch.z
wend

end

clearAll:
if pin(40) = 0 THEN    
   pin(40) = 1 
ELSE IF   
   pin(40) = 0
ENDIF
 return

 Relais1:

if pin(40) = 1  THEN   
   pin(40) = 0 
   UDP.WRITE "192.168.0.9", 1235, "Relais1=0"    
ELSE IF
  pin(40) = 1 
  UDP.WRITE "192.168.0.9", 1235, "Relais1=1"  
ENDIF 
return

 Relais2:
if pin(2) = 1 THEN    
  pin(2) = 0 
  UDP.WRITE "192.168.0.9", 1235, "Relais2=0"
ELSE IF   
  pin(2) = 1
  UDP.WRITE "192.168.0.9", 1235, "Relais2=1" 
ENDIF
return 

 Relais3:
if pin(1) = 1 THEN
   pin(1) = 0 
   UDP.WRITE "192.168.0.9", 1235, "Relais3=0"
ELSE IF 
   pin(1) = 1 
   UDP.WRITE "192.168.0.9", 1235, "Relais3=1"
ENDIF 
return 
     
 Relais4:
 if pin(1) = 1 THEN    
   pin(1) = 0 
   UDP.WRITE "192.168.0.9", 1235, "Relais4=0"
ELSE IF   
   pin(1) = 1 
   UDP.WRITE "192.168.0.9", 1235, "Relais4=1"
ENDIF 
return

 Relais5:
if pin(1) = 1 THEN    
   pin(1) = 0 
   UDP.WRITE "192.168.0.9", 1235, "Relais5=0"
ELSE IF   
   pin(1) = 1 
   UDP.WRITE "192.168.0.9", 1235, "Relais5=1"
ENDIF 
return

 Relais6:
if pin(1) = 1 THEN    
   pin(1) = 0 
    UDP.WRITE "192.168.0.9", 1235, "Relais6=0"   
ELSE IF   
   pin(1) = 1
   UDP.WRITE "192.168.0.9", 1235, "Relais6=1" 
ENDIF 

return

goudp:
v$ = udp.read$ 'receive the UDP data
If v$ = "Relais1=1" Then
vgaGui.SetValue bi1, 1
UDP.REPLY "Relais1 gesetzt" 
ENDIF
If v$ = "Relais1=0" Then
UDP.REPLY "Relais1 rückgesetzt" 
vgaGui.SetValue bi1, 0
ENDIF

If v$ = "Relais2=1" Then
vgaGui.SetValue bi2, 1
UDP.REPLY "Relais2 gesetzt" 
ENDIF
If v$ = "Relais2=0" Then
UDP.REPLY "Relais2 rückgesetzt" 
vgaGui.SetValue bi2, 0
ENDIF

If v$ = "Relais3=1" Then
vgaGui.SetValue bi3, 1
UDP.REPLY "Relais3 gesetzt" 
ENDIF
If v$ = "Relais3=0" Then
UDP.REPLY "Relais3 rückgesetzt" 
vgaGui.SetValue bi3, 0
ENDIF

If v$ = "Relais4=1" Then
vgaGui.SetValue bi4, 1
UDP.REPLY "Relais4 gesetzt" 
ENDIF
If v$ = "Relais4=0" Then
UDP.REPLY "Relais4 rückgesetzt" 
vgaGui.SetValue bi4, 0
ENDIF

If v$ = "Relais5=1" Then
vgaGui.SetValue bi5, 1
UDP.REPLY "Relais5 gesetzt" 
ENDIF
If v$ = "Relais5=0" Then
UDP.REPLY "Relais5 rückgesetzt" 
vgaGui.SetValue bi5, 0
ENDIF

If v$ = "Relais6=1" Then
vgaGui.SetValue bi6, 1
UDP.REPLY "Relais6 gesetzt" 
ENDIF
If v$ = "Relais6=0" Then
UDP.REPLY "Relais6 rückgesetzt" 
vgaGui.SetValue bi6, 0
ENDIF

return
Yes, I don't think you can wipe, it would be even nicer. But for 30 euros the device is pretty good ;-)
Last edited by Helmut_number_one on Wed Feb 07, 2024 10:45 pm, edited 1 time in total.
User avatar
cicciocb
Site Admin
Posts: 1995
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 428 times
Been thanked: 1335 times
Contact:

Re: Betreff: Modul ESP32-4848S040

Post by cicciocb »

HI Helmuth,
please find here a little demo that shows you how implement multiple pages :
helm3.bmp
helm4.bmp
helm1.bmp
helm2.bmp
demo_helmut.zip
You do not have the required permissions to view the files attached to this post.
Helmut_number_one
Posts: 93
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 36 times
Been thanked: 8 times

Re: Betreff: Modul ESP32-4848S040

Post by Helmut_number_one »

Very good, thank you.
I know who can do it, I'll never get there ;-)
I have a smart home app “IP-Symcon” in our house
I can do almost anything with it, hence my UDP history in my code in the last code text.
JSON or MQTT would also work.
I can do a lot with UDP, I still want to include states such as temperatures, shutters, slider for setting temp, and meter readings.

Is it for put this in project folder? "Smart Home Panel with ESP32 S3"
Thank you for your time.
Best regards Helmut

Edit:
What is still missing is the storage of states. If you turn a page and come back, the state is no longer displayed.
But I still have to plan something for the night, otherwise it will be boring
User avatar
cicciocb
Site Admin
Posts: 1995
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 428 times
Been thanked: 1335 times
Contact:

Re: Betreff: Modul ESP32-4848S040

Post by cicciocb »

Yes, if you want create a new post under project, I'll contribute.

About the status of the lights, you must store the status into a variable and then read back each time you open the page.

For example :
define at the beginning of the code the lights for each room

Code: [Local Link Removed for Guests]

room1_light1 = 0
room1_light2 = 0
room1_light3 = 0

room2_light1 = 0
room2_light2 = 0
room2_light3 = 0
.....
....
then, in the draw_roomX routines, you must read back the previous status of the lights :

Code: [Local Link Removed for Guests]

draw_room1:
vgagui.init 50
vgagui.image 0,0,0,0, "/helmut/img/EG_480.bmp"
t1 = vgagui.textline (380,10,60, 30, "t1", 10)
t2 = vgagui.textline (380,80,60, 30, "t2", 10)

prev = vgagui.ButtonImage(5, 420, 60, 60, leftOn$, leftOff$, toggle)
after= vgagui.ButtonImage(70, 420, 60, 60, rightOn$, rightOff$, toggle)
vgagui.setevent prev, TOUCH,  goPreviousPage
vgagui.setevent after, TOUCH,  goNextPage

bi1   = vgagui.ButtonImage(140, 376, 48, 48, lampOn$, lampOff$, toggle)
vgagui.setevent bi1, CHANGE ,  Relais1
bi2   = vgagui.ButtonImage(129, 110, 48, 48, lampOn$, lampOff$, toggle)
vgagui.setevent bi2, CHANGE ,  Relais2
bi3   = vgagui.ButtonImage(310, 75, 48, 48, lampOn$, lampOff$, toggle)
vgagui.setevent bi3, CHANGE ,  Relais3
bi4   = vgagui.ButtonImage(337, 200, 48, 48, lampOn$, lampOff$, toggle)
vgagui.setevent bi4, CHANGE ,  Relais4
bi5   = vgagui.ButtonImage(250, 250, 48, 48, lampOn$, lampOff$, toggle)
vgagui.setevent bi5, CHANGE ,  Relais5
bi6   = vgagui.ButtonImage(323, 430, 48, 48, lampOn$, lampOff$, toggle)
vgagui.setevent bi6, CHANGE ,  Relais6
' read back the previous status of the lights
vgagui.setValue b1, room1_lamp1
vgagui.setValue b2, room1_lamp2
vgagui.setValue b3, room1_lamp3
.....
return

and then, in the event, update the variable when you update the output

Code: [Local Link Removed for Guests]

Relais1:
pin(40) = 1 - pin(40)
room1_lamp1 = pin(40)
return

Relais2:
pin(2) = 1 - pin(2)
room1_lamp2 = pin(2)
return
....
.....

That's all!
Helmut_number_one
Posts: 93
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 36 times
Been thanked: 8 times

Re: Betreff: Modul ESP32-4848S040

Post by Helmut_number_one »

Thank you
Helmut_number_one
Posts: 93
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 36 times
Been thanked: 8 times

Re: Betreff: Modul ESP32-4848S040

Post by Helmut_number_one »

Ich habe es fast geschafft, dass die VGAButton Ihren status behalten, trotz umschalten auf andere Seiten und wieder zurück
ABER
Wenn ich per Smarthomesteuerung per UDP auf einer Seite einen Button schalte, ich aber nicht auf der Seite bin, dann werden Button auf Seiten geschaltet die gar nicht gemeint sind

I managed to get the VGAButton to retain its status despite switching to other pages and back again
BUT
If I switch a button on a page via smart home control via UDP, but I am not on the page, then buttons are switched to pages that are not intended
Why if I send this command (but:: I'm NOT on page/room 2) "Send this command in PHP from my home control: USCK_SendText(39372, "Room2_R2=1");
do switches come ON on other pages?
It also arrives in v$ the same way
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 1995
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 428 times
Been thanked: 1335 times
Contact:

Re: Betreff: Modul ESP32-4848S040

Post by cicciocb »

Hi Helmut, I'm off for some days so I cannot help you. Hoping someone on the group can do
Helmut_number_one
Posts: 93
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 36 times
Been thanked: 8 times

Re: Betreff: Modul ESP32-4848S040

Post by Helmut_number_one »

Thanks,
if it's vacation: nice time.

I know local and global variables. What seems strange to me is that a UDP message is recognized exactly, the reaction is actually precise and yet other actions are started.
If someone wants to try it, they would then have to enter their VGA data for their display into the code so that it can be done at all.
Thank you

Code: [Local Link Removed for Guests]

 goudp:
v$ = udp.read$            'receive the UDP data
If v$ = "Relais1=1" Then
vgaGui.SetValue bi1, 1
UDP.REPLY "Relais1 gesetzt" 
ENDIF
If v$ = "Relais1=0" Then
UDP.REPLY "Relais1 rückgesetzt" 
vgaGui.SetValue bi1, 0
ENDIF
return
 
Post Reply