New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP8266-01 and 433Mhz radio (transmit) #735
Comments
Here is the transmit code I appended to original issue:
|
@olliephillips Can you provide some information, documentation on the wave form you are trying to produce? Ideally a signal transition diagram with timings at the appropriate scale would be perfect. I'm wondering if this isn't a similar story to that we had for NeoPixels which requires sub microsecond precise resolution. |
@nkolban Unfortunately, and rather frustratingly, I would not know where to begin in generating that. All I can add is that this is the signal (below) I'm trying to send which the above pulse timings translate to.
The approach for both receiving from the remote and then replaying it, is based on that on the epsruino site here http://www.espruino.com/Remote+Control+Sockets Unfortunately, I doubt this information helps much. |
For digitalPulse the lengths are in milliseconds, so you need to get down to 0.3ms. Ahh, I see what's been done now. While @tve has implemented this, the Try changing: https://github.com/espruino/Espruino/blob/master/targets/esp8266/jshardware.c#L551-L563 to this: https://github.com/espruino/Espruino/blob/master/targets/stm32/jshardware.c#L2572-L2593 And assuming the utility timer works, it should all start working. That function should probably be moved out of jshardware.c altogether and put into |
Way beyond me @gfwilliams but thanks for diving in here. It sounds very promising. |
I ran your test program ( Gordon, I understand what you suggest and I'll get there at some point... |
Ha, well..... I tried the utility timer based implementation... and... surprise, surprise.... it doesn't work! I captured the reason in a comment in the code:
There are 484 bytes left free in SRAM, which is where interrupt routines have to go and where |
I would try the following:
Although the newSend array is still weird because of the 0.001 at the end, and because without it, it doesn't leave the pin in the same state it started in. |
@tve Great news, it works. Not so great news, it was maybe never a timer issue? Above code works 'as is' (with pin names changed) on Pico. So... and you know where I'm going with this.... :) I added that same line to my code - the code at the top of this issue, and guess what? It works. Remove it, and it does not. So I guess the question is why is pinMode critical on ESP8266 and not Pico? Thanks @tve for your help on this issue. Appreciated. |
Actually, I think timing a factor and your suggestion improves it. Your code switches the 433Mhz socket much more reliably than mine - which is actually quite sporadic - though it is firing which it would not before the addition of Thanks again!! |
Thanks for the update! I'll close the ticket, feel free to reopen if you have new issues. |
|
Yes. I checked the docs on the digitalWrite and Pulse methods and saw that it is/should be output by default. |
Ok, I'll add setting the pin to output if it's not an output. We do want to support setting it to open-drain output beforehand and it not changing, right? (I have to admit that I find it odd that digitalPulse changes the pin mode when digitalWrite doesn't (for a good reason).) |
digitalWrite does change pin mode - or it should do! It calls The reasoning is that most people (outside the Arduino world) get fed up if they say Basically you just need to make sure the first call in PinPulse is to |
I'm trying to track down how this is supposed to work. In jspin.c's jshPinOutput I see https://github.com/espruino/Espruino/blob/master/src/jspin.c#L253-L254:
thus the pin is set to output if it's not in manual mode. jshGetPinStateIsManual keep track in its own array whether a pin mode has been set. But I don't see where |
Wow, thanks for spotting that! I just filed a bug for it here: #765 I'm surprised it hasn't come up before as a problem with Espruino... |
The esp8266 side of things will need some follow-up after #765 is resolved, so I'm leaving this open for now. |
Just to say I have now fixed #765 (finally!) |
What will this mean for need to set pinMode prior to using digitalPulse/Write/Read on ESP8226 port? Still need to explicitly set pinMode prior to calling, or does this fix mean can adopt core espruino approach, and not? |
Afaik it means you can do like the other Espruino boards do now. |
Looks like every thing is fixed and nothing left open, so lets close it again |
[originally openen by @olliephillips https://github.com/espruino/EspruinoBuilds/issues/3
I'm trying to run a 433Mhz radio on ESP8266/Espruino. The aim is to control 433Mhz wireless plug sockets. I have code that runs and triggers socket on Pico with 433Mhz transmitter. Same code will NOT work on ESP8266 with same 433Mhz transmitter.
My boards are the "01" variant.
I have used various builds since port project began. Current version I'm testing with is "espruino_1v81.tve_esp8266-flash-strings_662306b_esp8266.tgz". But issue has existed throughout.
My 433Mhz project relies on the Espruino method, "digitalPulse()"
Thinking/discussion around this topic on Gitter has so far implied ESP8266 has hardware timer constraints that may limit its application in areas that require precise, and in particular, very small/short timings. As well as 433Mhz I'm inferring that means projects base on infrared transmission too.
However, similar projects seem to exist for Arduino which would suggest hardware is not the constraint. An ESP8266 flashed with appropriate software seems able to use a 433Mhz radio to transmit to these RF controlled plug sockets. Link to video - https://www.youtube.com/watch?v=NAkyki615cY&feature=youtu.be
Of interest is that ESP8266 seems to be able to accurately record the signal from the remote control that came with the plug sockets. I can replay the resulting binary code using a Pico and have it trigger the socket. Looking at the code involved in receiving those signals, I would suggest (though it is only a suggestion) that it also relies on an accurate hardware timer to record the code so that it can be replayed.
Latest discussion on gitter with @tve suggested the default logDebug setting of "true" may be a factor, but in later tests adding this has changed nothing.
My limited understanding of why Arduino projects might work while Espruino does not is that the former compiles to C++ while Espruino is still interpreted at runtime - so the issues are different and potentially more complex.
What bugs me is that ESP8266 via Espruino can record a signal I can reuse (on Pico), but seems incapable of sending same.
If I can provide more info let me know. Would love to put this to bed - one way or the other.
The text was updated successfully, but these errors were encountered: