UK power socket with HF-W02 module

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bobdvb
Normal user
Posts: 10
Joined: 04 Oct 2016, 11:21

UK power socket with HF-W02 module

#1 Post by bobdvb » 19 Oct 2016, 12:31

Hi All,

I was ordering from DX.com so I thought I would take a chance and order a TS-S18 UK smart plug hoping that it had an ESP8266 module inside and it does!
Image

I've taken it apart and for your pleasure taken some pictures and put them in a Google album:
https://goo.gl/photos/M1RjE4xJXeocNutB8

It has a HF-W02 ESP module with an 8Mbit (1MB) Winbond flash chip which has GPIO's to spare and the header board is also nicely labelled and even has headers for the TXD, RXD and IO0. I put 5V into it from my USB serial adaptor on the 5Vcc pin (the board has its own 3.3v regulator) and managed to get the bootloader. By grounding IO0 I flashed on the 1024 R120 but once it starts up none of the serial port data makes any sense now. I saw somewhere here that I should blank the flash bank if there is a problem and I used Blank_1M.bin to do that, but still it doesn't work right. I've also tried R140 r3 but it behaves exactly the same. I've also tried an external 7805 PSU to ensure it had sufficient power to start with and a different FTDI USB adaptor, my only other hardware option is to try a different 3.3v regulator.

I wondered what the serial port baud rate was and after trying everything I decided to measure the period of the bits on the wire to see if I could spot something and what is odd is that it comes out at 176-178kHz which makes no sense in serial land?

I've flashed it twice now and both times the same, interestingly the serial data does seem consistent rather than just junk:
ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09826c6d
~ld
y▒a▒
▒▒n▒+▒&|▒+X▒▒▒g▒ ▒▒A▒V▒▒▒&▒▒;N▒&▒▒▒.▒Xa▒
▒▒*▒▒n
Now, I don't have a dump of the original firmware from the device so I may have ended up with a brick as a result, but I don't believe it, I think I've just done something wrong and I would appreciate anyone's advice as to what steps to take next?

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: UK power socket with HF-W02 module

#2 Post by cherowley » 21 Oct 2016, 21:09

Funnily enough just last week I discovered the very same about a couple of plugs I've had for months.

Having same probs with flashing though. Flashes on but won't run..

It will run the demo arduino sketches though but the baud rate is different from what is set in code. The WiFi stuff also doesn't work. Someone has mentioned these plugs may have a 40mhz crystal instead of the usual 26mhz...

bobdvb
Normal user
Posts: 10
Joined: 04 Oct 2016, 11:21

Re: UK power socket with HF-W02 module

#3 Post by bobdvb » 23 Oct 2016, 15:04

cherowley wrote:Funnily enough just last week I discovered the very same about a couple of plugs I've had for months.

Having same probs with flashing though. Flashes on but won't run..

It will run the demo arduino sketches though but the baud rate is different from what is set in code. The WiFi stuff also doesn't work. Someone has mentioned these plugs may have a 40mhz crystal instead of the usual 26mhz...
Ah, thanks, thanks to you I have found this post which slightly disagrees with you but gives me some ideas:
http://www.esp8266.com/viewtopic.php?f=13&t=11727

and this: http://esp8266-re.foogod.com/wiki/Serial_UART

I will have another go with some other obscure rates.

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: UK power socket with HF-W02 module

#4 Post by cherowley » 24 Oct 2016, 09:41

Hiya,

Hmm, in my case that ties up perfectly as when i boot the plug i get a read out at 115200 - which does then suggest a 40mhz xtal as indicated in your post :)

I posted over there about this and someone gave some ideas on making sure the xtal speed is set correctly:

http://www.esp8266.com/viewtopic.php?f=13&t=12175

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: UK power socket with HF-W02 module

#5 Post by cherowley » 25 Oct 2016, 10:03

Hi Bob,

Just to let you know I've successfully flashed the plugs and have them working now.

It is indeed the problem of them having 40mhz xtals - if you look at the board you can see it marked 40 too..

http://www.esp8266.com/viewtopic.php?f=13&t=12175

I had to edit the bin file setting a couple of bytes from 1 to 0 before uploading (1=26mhz, 0=40mhz).

GPIO's are active low.

12 Green Led
13 Relay
14 Red Led

bobdvb
Normal user
Posts: 10
Joined: 04 Oct 2016, 11:21

Re: UK power socket with HF-W02 module

#6 Post by bobdvb » 25 Oct 2016, 15:16

thanks!

I'll give that a go when I get a chance, hex edit to the byte location and flip the bit. It's a shame that we'll have to do that each time but not exactly painful.

Bob

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: UK power socket with HF-W02 module

#7 Post by cherowley » 25 Oct 2016, 15:52

No probs, give me a shout if you get stuck :)

Yeah, would be nice to have an option somewhere to define the xtal freq like we can for flash speed, flash size, spiffs etc

Supergeek
New user
Posts: 1
Joined: 10 Nov 2016, 21:33

Re: UK power socket with HF-W02 module

#8 Post by Supergeek » 10 Nov 2016, 21:44

Hi

Thanks for sharing this, definitely made it easier for me to get started on these. :) I've found a slightly easier way to flip the bit, the configuration table is generated from this file:
../packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266/core_esp8266_phy.c

This file defines an array of configuration data, entry 48 holds the crystal setting, change it to 0 for a 40MHz crystal.

This changes the setting for any ESP8266 project built in the Arduino IDE so don't forget to change it back before building for any other boards. :oops:

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: UK power socket with HF-W02 module

#9 Post by cherowley » 10 Nov 2016, 23:15

Thanks supergeek, very good to know :)

bobdvb
Normal user
Posts: 10
Joined: 04 Oct 2016, 11:21

Re: UK power socket with HF-W02 module

#10 Post by bobdvb » 11 Nov 2016, 13:24

Okay, that's frustrating, I applied the esp_init_data_default and flipped the 30 byte at the right address but it didn't help!

I wasn't planning on building an image myself but I might have to try it now!

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: UK power socket with HF-W02 module

#11 Post by cherowley » 11 Nov 2016, 14:20

Hi bob,

I had to do a search in the bin file:

search for: 04FEFDFFF0F0F0E0E0E0E10AFFFFF8

Change byte under second F8 from 1 to 0

repeat for second match


Hmm, i scribbled this note when I was doing it but now reading it back it's a bit cryptic sorry!

Justblair
Normal user
Posts: 63
Joined: 08 Aug 2016, 23:42

Re: UK power socket with HF-W02 module

#12 Post by Justblair » 14 Nov 2016, 17:59

Supergeek wrote:Hi

Thanks for sharing this, definitely made it easier for me to get started on these. :) I've found a slightly easier way to flip the bit, the configuration table is generated from this file:
../packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266/core_esp8266_phy.c

This file defines an array of configuration data, entry 48 holds the crystal setting, change it to 0 for a 40MHz crystal.

This changes the setting for any ESP8266 project built in the Arduino IDE so don't forget to change it back before building for any other boards. :oops:
Great advice. Thanks a lot, got ESPeasy up and running on a Haufan Power strip.... Only to find that the relays, leds and night light are controlled by an attached sti microcontroller... And I of course did not work out how they talk to each other before updating the fimware doh!

Got a hunch though that I can try out...

https://www.amazon.co.uk/gp/product/B01 ... UTF8&psc=1

jeremypoulter
New user
Posts: 1
Joined: 06 Mar 2017, 10:45

Re: UK power socket with HF-W02 module

#13 Post by jeremypoulter » 06 Mar 2017, 10:52

FYI I have been working on updates to the ESP8266 Arduino core to allow programming of this, there is a pull request open; https://github.com/esp8266/Arduino/pull/3025 and I have started on my own firmware here; https://github.com/jeremypoulter/SmartPlug, very pre-pre-alpha but might be of use.

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: UK power socket with HF-W02 module

#14 Post by bobbybeans » 15 Mar 2017, 15:15

nice I was contemplating buying these but decided agaisnt it as I didn't want to do hex editing and I can easily flash others that work. I look forward to this and might buy them in the future

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests