arduino-esp8266-alexa-wemo-switch
arduino-esp8266-alexa-wemo-switch copied to clipboard
Sonoff switch
Do you think this code could modified to work with the sonoff switch. http://blog.squix.org/2016/01/esp8266-products-hitting-market.html
It has 1M of flash and uses esp8266
Or do you think it will just work? I'm getting one to test in the next couple of weeks.
It works fine on a sonoff. I just used the arduino ide software to program it - I used the nodemcu.9v on the arduino type - I use them with the alexa echo dot
Great pieces of software...
Joe
I received 4 today and had a quick go. Using arduino I had it on generic esp8266 board and 1m flash. I changed the relay pin to pin 12 in the code and was getting error esp com mem failed or something like that. Was the pin number all you changed? And do I have to change the board type to nodemcu 9v and that will be me sorted? Really excited about this. An Alexa switch for £5! :-)
I used a fdti 3.3v
I also use a ftdi 3.3v as the programmer. I tried type as a generic 1meg flash but got reboot problems. So I used the nodemcu.9 choice.
Change the ssid Change password Change device name to (your choice)
Pins I use d6 for the relay and d7 for the led.(optional)
Joe
On Mon, Nov 14, 2016 at 6:12 PM, shenery [email protected] wrote:
I used a fdti 3.3v
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-260480180, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY8E2NrAWaVDSVncauzQh4zxYCaCKks5q-NzSgaJpZM4KoUCC .
The esp mem code error -likely means your device is not in flash mode
TO flash:
Press and hold the button, do not release: while holding it down, plug in the programmer, then release button.
Joe
On Mon, Nov 14, 2016 at 6:49 PM, joe basque [email protected] wrote:
I also use a ftdi 3.3v as the programmer. I tried type as a generic 1meg flash but got reboot problems. So I used the nodemcu.9 choice.
Change the ssid Change password Change device name to (your choice)
Pins I use d6 for the relay and d7 for the led.(optional)
Joe
On Mon, Nov 14, 2016 at 6:12 PM, shenery [email protected] wrote:
I used a fdti 3.3v
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-260480180, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY8E2NrAWaVDSVncauzQh4zxYCaCKks5q-NzSgaJpZM4KoUCC .
Ok thanks for the advice. I will give it a try today.
Cheers Steven
I tried nodemcu 0.9 esp-12. 1m spiffs and I'm still getting error mem esp com failed. Also d6 doesn't work for me. Isn't the relay gpio 12? It doesn't even compile when I have it as d6 but when I change to 12 it compiles fine.
D6 not d6 - my mistake gpio12 is D6
Ok, mem esp error - well that is a serial comm problem which means unit is not in pgm mode or your wire of the tx and rx pins on your ftdi may not be correct to the sonoff.
I leave the nodemcu .9 at 3m spiffs but 1meg is fine... The error your displaying is not related to those selections.
It is a communication issue related to wiring and or not in correct mode to flash.
Joe
On Tue, Nov 15, 2016 at 3:46 AM, shenery [email protected] wrote:
I tried nodemcu 0.9 esp-12. 1m spiffs and I'm still getting error mem esp com failed. Also d6 doesn't work for me. Isn't the relay gpio 12? It doesn't even compile when I have it as d6 but when I change to 12 it compiles fine.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-260570016, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY8mGgkHGQf1Je0eUjP13SLlFvtfmks5q-WNCgaJpZM4KoUCC .
Ok so I've been spending a bit more time on this. I have all your settings loaded. I have a fT232RL ftdi like this on http://m.ebay.co.uk/itm/Latest-Version-FT232BL-FTDI-USB-to-TTL-Serial-Adapter-for-Arduino-UK-Seller-/181797979805?nav=SEARCH connected to the sonoff. All wires connected and have been checked numerous times. I have it plugged into my tablet via USB otg and I have also tried through a powered USB hub and I am still getting the espcomm mem failed error. I occasionally get a java lang nullpointerexception error as well. Do you think it could be a power supply issue? Kind regards Steven
Also I press the button on the sonos and keep holding it until I plug it in to the tablet and there is no blinking led. I assume that's me in flash mode?
It still appears your system is not in flash mode. Your steps look fine.
- Make sure you have selected the correct serial port.. Check windows system manager under com ports. 2 Make sure the serial monitor is not open.
Joe
On Thu, Nov 17, 2016, 1:52 PM shenery [email protected] wrote:
Also I press the button on the sonos and keep holding it until I plug it in to the tablet and there is no blinking led. I assume that's me in flash mode?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-261318577, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY0zIb6cBhDdvoGljj60zVHc_wmI5ks5q_JRYgaJpZM4KoUCC .
The powersupply will not usually be a problem when doing a flash It mostly acts up when the esp8266 is running and using the sotware and wifi.
For your programmer, tx am rx are the typical error area. If all fails revese the tx and rx wires Programming note: Vcc 3.3v Gnd Tx Rx Are the only wires required.
Joe
On Thu, Nov 17, 2016, 2:20 PM joe basque [email protected] wrote:
It still appears your system is not in flash mode. Your steps look fine.
- Make sure you have selected the correct serial port.. Check windows system manager under com ports. 2 Make sure the serial monitor is not open.
Joe
On Thu, Nov 17, 2016, 1:52 PM shenery [email protected] wrote:
Also I press the button on the sonos and keep holding it until I plug it in to the tablet and there is no blinking led. I assume that's me in flash mode?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-261318577, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY0zIb6cBhDdvoGljj60zVHc_wmI5ks5q_JRYgaJpZM4KoUCC .
I've tried all of that. Jumper is on the 3.3v. Vcc is the 3.3v. Checked in device manager which com port is recognised when I connect. Serial monitor window not opened. I saw on this forum that some people were getting the same error and fixed it with clearing the flash with esptool before flashing the new firmware? Do you have any experience with this? I can't see esptool in the programmer of arduino ide.
Sorry forgot to post the forum. http://tech.scargill.net/itead-slampher-and-sonoff/
Well all sounds good I have used esptool to clear mem. Esptool is another program. Just google and download
Sometimes an esp wont work so i use the esptool to refresh it.
Wish you had another regular esp nodemcu to see if you could flash it. Since they have the programmer builtin, this would establish your serial programmer is good. Have you ever successfully flashed any esp8266?
On Fri, Nov 18, 2016, 3:06 PM shenery [email protected] wrote:
Sorry forgot to post the forum. http://tech.scargill.net/itead-slampher-and-sonoff/
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-261614408, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpYxSfyV16Id-rc1LAeQNYue3kkh_xks5q_fcqgaJpZM4KoUCC .
ok so I got a bit further today. I got this. 83936 bytes from C:\Users\Shenery\AppData\Local\Temp\arduino_build_786479/sinric.ino.bin to flash at 0x00000000 erasing flash size: 045520 address: 000000 first_sector_index: 0 total_sector_count: 70 head_sector_count: 16 adjusted_sector_count: 54 erase_size: 036000 espcomm_send_command: sending command header espcomm_send_command: sending command payload setting serial port timeouts to 15000 ms setting serial port timeouts to 1000 ms espcomm_send_command: receiving 2 bytes of data writing flash ................................................................................ [ 28% ] ................................................................................ [ 57% ] ................................................................................ [ 86% ] ...................................... [ 100% ] starting app without reboot espcomm_send_command: sending command header espcomm_send_command: sending command payload espcomm_send_command: receiving 2 bytes of data closing bootloader flush start setting serial port timeouts to 1 ms setting serial port timeouts to 1000 ms flush complete I plugged in a lamp and I get nothing though.
when I bring up serial monitor it says f5, fo, f5 f0 and there is no indication that the esp is connected to my network. when scan my network there is no esp device
Was that done with esptool?
Try running it(espool) and writing a blank bin at 0000 Do a google and you should find one If it writes ok then disconnect and reboot Then run up the arduino ide program and upload the code for the esp.. Make sure you put it in the flash mode Joe
If you had teamviewer I could look at the screen etc and maybe help more..
On Thu, Nov 24, 2016 at 11:48 AM, shenery [email protected] wrote:
ok so I got a bit further today. I got this. 83936 bytes from C:\Users\Shenery\AppData\Local\Temp\arduino_build_786479/sinric.ino.bin to flash at 0x00000000 erasing flash size: 045520 address: 000000 first_sector_index: 0 total_sector_count: 70 head_sector_count: 16 adjusted_sector_count: 54 erase_size: 036000 espcomm_send_command: sending command header espcomm_send_command: sending command payload setting serial port timeouts to 15000 ms setting serial port timeouts to 1000 ms espcomm_send_command: receiving 2 bytes of data writing flash ................................................................................ [ 28% ] ................................................................................ [ 57% ] ................................................................................ [ 86% ] ...................................... [ 100% ] starting app without reboot espcomm_send_command: sending command header espcomm_send_command: sending command payload espcomm_send_command: receiving 2 bytes of data closing bootloader flush start setting serial port timeouts to 1 ms setting serial port timeouts to 1000 ms flush complete I plugged in a lamp and I get nothing though.
when I bring up serial monitor it says f5, fo, f5 f0 and there is no indication that the esp is connected to my network. when scan my network there is no esp device
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-262804935, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY4tPzhzzZX_zkWTX0DQ0qO9yR_acks5rBbHrgaJpZM4KoUCC .
I set up esptool but not 100% of the command to use to clear the flash. Tried a few but didn't work. I have a blank.bin file saved in the esptool directory. I have installed team viewer and could maybe try that over the weekend if you have time. If you have a command to use in esptool though I could try that?
Kind regards Steven
And when I try the erase flash command in esptool I get esptool error: argument --port/-p: expected one argument
Ok so I've been having fun getting this going. I found the right command for esptool and have cleared the flash, I was then able to upload the firmware again. I've realised that there is a certain way that you have to wire the lamp in to so that the sonoff is powered via the mains. I scanned devices in alexa and it found my lamp. I asked Alexa to turn on box and she replied ok. But nothing happens the light stays off. I have tested the fuse the bulb and tried in another lamp but it doesn't turn on and I've no idea why. I'm nearly there but not sure what to do next.
Scrap that last post. I forgot to change the gpio pin again and now it works. If anyone's having bother esptool helped out a lot. Basically in my experience you have to use esptool to clear flash before you upload this code. Thank you joeman for all your help it works perfect no :-)
Great, glad you kept at it. Joe
On Sat, Nov 26, 2016, 4:56 PM shenery [email protected] wrote:
Scrap that last post. I forgot to change the gpio pin again and now it works. If anyone's having bother esptool helped out a lot. Basically in my experience you have to use esptool to clear flash before you upload this code. Thank you joeman for all your help it works perfect no :-)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-263085545, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY56t4H7nG3racqthCY7o38VWL_Awks5rCJ0KgaJpZM4KoUCC .
Yeah it works really good. My wifis been down all day. What a coincidence eh? Lol. This happening has gave me anurgancy to try and work out how to override the relay with say a hardware switch or maybe you can use the program button? Has anyone done this that you know of?
Kind Regards
You can use a push button. https://www.arduino.cc/en/tutorial/switch
when HIGH call turnOnRelay(); when LOW call turnOffRelay();
I'm not very good with adding code so not sure where to put it in the script. Where would it go? And would I be able to use the program button on gpio 0 for this? If not would the switch go at the mains side or the lamp side?
Kind regards Steven
The esp com failure means it is not likely in flash mode Make sure u hold down the button an dont let go until a few seconds after you plug in the programmer.
Joe
On Tue, Nov 29, 2016, 10:07 AM shenery [email protected] wrote:
I'm not very good with adding code so not sure where to put it in the script. Where would it go? And would I be able to use the program button on gpio 0 for this? If not would the switch go at the mains side or the lamp side?
Kind regards Steven
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/6#issuecomment-263578591, or mute the thread https://github.com/notifications/unsubscribe-auth/AWDpY32vGQx2WISNdNjUB9zzmQheLvzzks5rDDFtgaJpZM4KoUCC .
I have found this piece of code from sonoff boilerplate firmware. Looks like the code to use the button on gpio 0 to switch the relay. Can I just add this somewhere in the code? //delay(200); //Serial.println(digitalRead(SONOFF_BUTTON)); switch (cmd) { case CMD_WAIT: break; case CMD_BUTTON_CHANGE: int currentState = digitalRead(SONOFF_BUTTON); if (currentState != buttonState) { if (buttonState == LOW && currentState == HIGH) { long duration = millis() - startPress; if (duration < 1000) { Serial.println("short press - toggle relay"); toggle(); } else if (duration < 5000) { Serial.println("medium press - reset"); restart(); } else if (duration < 60000) { Serial.println("long press - reset settings"); reset(); } } else if (buttonState == HIGH && currentState == LOW) { startPress = millis(); } buttonState = currentState; } break; }
}
https://github.com/tzapu/SonoffBoilerplate/blob/master/SonoffBoilerplate.ino
I tried out this code last night. It works fine for tactile switches. I tried it with one of those cheapo switches with a spring. It worked but there was a lot of rapid turn on / off because there is no debounce in the code.
Hello,
I need the compiled bin file of sinric.ino. Can please someone send it to my mail? [email protected]