Can I make web interface for hardware events? #807
Replies: 13 comments
-
Posted at 2015-10-03 by MosabWadea BTW I made all the interfacing hardware and I just need to program my 8266. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by @gfwilliams Hi - are you planning on using the ESP8266 alone, or the ESP8266 and an Espruino board? I'm not sure the Espruino firmware that runs on the ESP8266 is stable enough to use properly yet - although it is improving all the time. The one that runs on something like the Espruino Pico is pretty good though. Right now, if you want the webpage to update automatically (I guess you mean while it's still open?) you'll want to do something like an AJAX request - basically having the website request another small webpage every few seconds. Potentially Websockets are an option in the future, but that's some way off. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by MosabWadea I am trying to use the 8266 alone. It is ok to do some tests with the current firmware.. No I don't need to update the page while it is still open. I just need to update the variables and once I refresh the page I see the new values |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by MosabWadea @gordon The keys I am watching are implemented as keypad, and to monitor what key is pressed I need to watch the driving pins and which pin of the sensing pins has changed.. I have the logic and I can simply convert it to code. But is it possible to make an event listener for these changes and serve the web as well? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by @allObjects You go down a different route...
If you want to have a repeat on holding a key longer than a configurable time, you need to modify 4 a bit and have a logical loop (timout before you check again with a scan), then move on. For sure fall NOT into the arduino trap. (Check out the similarly structured approach I took with the touch screen and its application with a UI...). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by MosabWadea @allObjects I don't think I get that So can you please elaborate more? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by MosabWadea Also I think you didn't get the full idea that I am working on..
to detect which button is clicked I have to do this way:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by @allObjects NP... I'll take it easy... you being experienced with Arduino: you will find out Espruino is like vacation and fun! But in deed: thinking in Espruino IS (a bit - to say at least) different... loop versus event. And because it is event driven, you can do all the things you plan to do. To get you going, I suggest you start with the wall device and the part of it that controls your ac... and for development - and teaching - purposes, assume, you are running it for an initial period on connected via USB... and then later, adding the Web server / wifi onto it so you can control it via internet. What kind of key pad are you thinking about? How many key are there? Is it multiplexed or is every key (button) just connected to a pin and can operate independent of each other? I assume - for simplicity - you have a two buttons - call them tmpUpBtn and tmpDownBtn hat work as their names imply: pressing them once will increase / decrease the desired temperature. The buttons are plain push buttons that on press connect a pin with ground. I also assume, you are using a Pico, some bread board, etc. But let me know what you have and where you plan to go. I will start very simple, and over time the things will evolve into more elaborate consturcts and objects that are easy to handle and pass on to any processing you nead, including creating a response to a http request from your browser over your planned wifi access.
Wire your buttons, connect Espruino, copy, past and upload this script (attached as AC09.js file), and operate your buttons... - I hope not having made typos. Your output should show the (adjusted) tmpTarget.Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-03 by @allObjects ...I thought you were using a multiplexed keypad... but to get as quickly as possible to the point of how Espruino works, I wrote the code with simple button. Btw, you can already use your keypad with the above code. You just wire it accordingly:
(btw, I noticed your nice adjustment in the character graphics. Use the Espruino IDE editor to write these character graphics... becaue it has fixed font... and then copy them into the posting text area.) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-04 by @allObjects Using your keypad, you can give code below (as well attached) a shot. In your case, the use of pins for driving and sensing a 3x2 = max 6 buttons and using only 4 of the 6 options while consuming 5 GPIO pins is not the most effective use of anyway already sparce resources... to say the least. You may consider an SPI or I2C driven port extender that uses max 3 GPIO pins for 8, 16, 24, 32,... estended pins...
Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-05 by @allObjects Verified (and enhanced) code creates this console output:
Noteworthy:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-05 by @allObjects 'Final', 'moduled' Keypad code is discussed (and available) in Keypad - bought or DIY - controlled directly by Espruino conversation. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-10-05 by @gfwilliams Not quite sure if I'm helping here, but in answer to your previous questions: Yes, you can do a loop - just But you probably shouldn't need that - even though it is the obvious thing to do coming from Arduino. Espruino is event based, so once you've set up a webserver with a callback function, that function will be called back when a web page is requested. If you set up a KeyPad, that KeyPad's callback function will get called when a key is pressed too. Both things will work together just fine without you having to worry -no loop needed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-10-03 by MosabWadea
just found out that this thread is not meant for this type of conversations.. I don't know how to delete the conversation however..
Hello everyone...
I am new to this forum, I hope I can add more value here.
I have a question regarding a project I am working on.
I am developing a remote controller using an ESP8266 and interfacing with some simple electronics to my hardware I want to control. I want to interface with the user using a webpage obviously.
In the beginning I started to do the development using the esplorer tool and lua scripting. But that was very not helpful and can't give me all the features I wanted. Then I found this amazing javascript interpreter that may give me what I need. So I have some questions for you guys.
I want to control a wall-mounted device that controls my AC. The device has some interfacing buttons (power, fan, tempUp and tempDown).
I want to make the device controlled by the web interface as well as the device interface itself.
developing the webpage is easy and I could follow the tutorials easily. But is it possible to update the content of the web interface when a button is clicked? I mean if someone turned on the AC, when I go to the webpage I can see the status as "ON" and if someone changed the temperature I can keep track of how many times he clicked the button and update the temp variable in the controller?
To sum up, I want to make the variables for the webpage controlled by the hardware as well as the user from the PC.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions