visualapproach / WiFi-remote-for-Bestway-Lay-Z-SPA

Hack - ESP8266 as WiFi remote control for Bestway Lay-Z spa Helsinki
GNU General Public License v3.0
305 stars 74 forks source link

Display works, nothing else #330

Closed menime8 closed 2 years ago

menime8 commented 2 years ago

Hi there, i have a Dreamstream SPA, which has exact the same electronics like Lay Z Spa. Both selled from Bestway. My Pump looks like the newer 2021 model.

IMG_20220710_172051 IMG_20220710_132059 IMG_20220710_154049 IMG_20220710_172102

I started with PCB V2, NodeMCUV3 and the TXS0108E. First try, nothing happend. Second try with 10K resistor, it Starts, DSP starts flashing. Third try: 560 ohm resistors between DSP and ESP. Display works fine, melody and IP shown.

But i can't get any connection to the CIO. Wires and connections are all checked with my meter.

I hope anyone can give me a hint 🤔

Thanks

visualapproach commented 2 years ago

Maybe try resistors btwn LLC and cio also? Or switch to the MOSFET version of LLC. Or try without LLC which is probably fine in practice but may blow the esp in theory according to some people. For the price I'd take the chance...

menime8 commented 2 years ago

Maybe try resistors btwn LLC and cio also? Or switch to the MOSFET version of LLC. Or try without LLC which is probably fine in practice but may blow the esp in theory according to some people. For the price I'd take the chance...

Tried both versions. Resistors everywhere, then only ESP direct to CIO and DSP. IMG-20220710-WA0011

menime8 commented 2 years ago

I have 6 wires, +5v, 0V, RX, TX and one for Sound. What does the last wire?

SigmaPic commented 2 years ago

I have 6 wires, +5v, 0V, RX, TX and one for Sound. What does the last wire?

It's a 3 wire SPI line. Isn't it ? So, data, clk and chip select instead of RX and TX.

If you still have access to the pump PCB. May you tell me if you can read the reference of that chip

136789766-c43aaba9-92ff-4629-9687-ae5ffebc5394~2.jpg

menime8 commented 2 years ago

I thought it was RX TX.... I will have a look tomorrow for chipnumbers.

visualapproach commented 2 years ago

Maybe try resistors btwn LLC and cio also? Or switch to the MOSFET version of LLC. Or try without LLC which is probably fine in practice but may blow the esp in theory according to some people. For the price I'd take the chance...

Tried both versions. Resistors everywhere, then only ESP direct to CIO and DSP.

IMG-20220710-WA0011

Oh I see now that you connected 5V to the 3V3 input. Remove that blue wire and check that the ESP is not toasted

visualapproach commented 2 years ago

It's a 3 wire SPI line. Isn't it ? So, data, clk and chip select instead of RX and TX.

That's right for 6 wire models except the 54149E, although it is a bit unusual mode which esp cannot do in hardware unfortunately. Hence the bitbanging

If you still have access to the pump PCB. May you tell me if you can read the reference of that chip

Great if this get some clarification. Thx

menime8 commented 2 years ago

Maybe try resistors btwn LLC and cio also? Or switch to the MOSFET version of LLC. Or try without LLC which is probably fine in practice but may blow the esp in theory according to some people. For the price I'd take the chance...

Tried both versions. Resistors everywhere, then only ESP direct to CIO and DSP. IMG-20220710-WA0011

Oh I see now that you connected 5V to the 3V3 input. Remove that blue wire and check that the ESP is not toasted

It isn´t.

I used the plan from here #312

I know it could be toasted, this was my last try on sunday.

menime8 commented 2 years ago

I have 6 wires, +5v, 0V, RX, TX and one for Sound. What does the last wire?

It's a 3 wire SPI line. Isn't it ? So, data, clk and chip select instead of RX and TX.

If you still have access to the pump PCB. May you tell me if you can read the reference of that chip

IMG_20220713_124759 I read Nuvoton MS51FB9AE

https://www.nuvoton.com/products/microcontrollers/8bit-8051-mcus/industrial-8051-series/ms51fb9ae/

menime8 commented 2 years ago

Today i tried many different options, with and without resistors, with 560 and 680. It wouldn't work. Checked again all connections. The other mosfet LLC arrives, too. I see my ESP has resistors between D3 and 3v and D4 and 3v. I ordered a other ESP. More Info i have on the next few days.

visualapproach commented 2 years ago

Did you get rid of the blue wire?

menime8 commented 2 years ago

Yes IMG_20220713_152947

visualapproach commented 2 years ago

Good, I would also try some caps on CIO side and use the B port to get a better LPF. And/or overclock the ESP if there is something speed related.

menime8 commented 2 years ago

I measured on all 3 lines from CIO 4,9xx Volt with jumping around 20 mV. What would i see with my oscilloscope?

Which capacitance? 22myF?

IMG_20220713_125236

visualapproach commented 2 years ago

Ok so both ends has 1K resistors and unknown caps. So we can calculate a range of cap values with the RC formula. Cut off freq should be higher than the SPI freq. The SPI on my pump is 22 kHz IIRC. I reckon 200-1000 pF would do it. I need to think a bit on this but what you can check with the scope is the clock frequency on the clock line. And measuring the highs and lows voltages. I'm not an EE so don't expect miracles here but let's try to find this out

menime8 commented 2 years ago

The picture is from the CIO. I don't have any from the DSP. I order a few 200pf, so i can do 200/400/600 pf and so on in parallel.

I'm pretty sure, it works with that older Nodemcu.

SigmaPic commented 2 years ago

I read Nuvoton MS51FB9AE

https://www.nuvoton.com/products/microcontrollers/8bit-8051-mcus/industrial-8051-series/ms51fb9ae/

Thanks. It's a microcontroller. I will check the pin config capabilities (push pull, open drain, pull up...)

Looking at the signals with a scope may allow you to detect the root cause of the issue. You can look at signal on CIO side but also on esp side and see if something goes wrong.

I'm pretty sure, it works with that older Nodemcu.

Which one do you talk about ?

@visualapproach Did you implement a sort of test mode ? We can imagine plugging both connectors from the BWC together. Then you generate some signal in one side and you check that you can read them on other side. Only the 5V should be added. By doing this, it would allow to check the BWC board.

visualapproach commented 2 years ago

That's a great idea @SigmaPic I'm on it

SigmaPic commented 2 years ago

That's a great idea @SigmaPic I'm on it

I'm very busy this time. Otherwise I would have propose a PR.

Maybe you can try to generate 101010 at the rate of the SPI and check if you read the correct bits. Then you change the polarity of the inputs and outputs.

SigmaPic commented 2 years ago

I'm pretty sure, it works with that older Nodemcu.

Ok. I see the resistors: 12k pull up on CS and CLK on DSP side. On CS, it should not be an issue because this pin is set at high level at startup because it's an active low => the pull up is a good think For the CLK, it may not be an issue because if CS is high, CLK should no be taken into account.

menime8 commented 2 years ago

I'm pretty sure, it works with that older Nodemcu.

Which one do you talk about ?

I have the version 3.2. i ordered the 3.0 version with the CH340

SigmaPic commented 2 years ago

Yes IMG_20220713_152947

On this photo you don't have the resistors on CIO side. Do you confirm that you tried with them ?

menime8 commented 2 years ago

On this photo you don't have the resistors on CIO side. Do you confirm that you tried with them ?

Yes, tried 560 and 680 ohms

visualapproach commented 2 years ago

@SigmaPic I wonder if we can/should set the gpio:s to open drain or with pull up resistors. Don't remember what it is now and what can be done, but could be worth a look. When I have time

menime8 commented 2 years ago

One question, isn't it possible to use the Miso/Mosi/CLK from the ESP?

IMG_20220714_104431

visualapproach commented 2 years ago

Espressif states mode 3 is not supported.

SigmaPic commented 2 years ago

I'm pretty sure, it works with that older Nodemcu.

I think it won't change anything because there are some pull up on your mosfet LLC. See my shematic below. So the pull up on esp side won't change anything. But, you can try to be sure. Maybe I'm wrong.

@SigmaPic I wonder if we can/should set the gpio:s to open drain or with pull up resistors. Don't remember what it is now and what can be done, but could be worth a look. When I have time

I take a look at the full schematic and I found something strange that may explain some troubles. The issue concerns the mosfet LLC when data are sent from DSP/CIO to ESP. The other way is ok (from ESP to DSP/CIO).

As you can see on my simulation, the voltage on ESP input stay at 1.5V when DSP/CIO drive the line to 0. This comes from the serial 1k resistor. On this simulation, I put one 1k which is the one in the DSP/CIO and one 1k which is the one we put on our PCB. If I remove one 1k, it's better but not perfect. To get perfect results, I need to remove both 1k resistors which is not possible because we have at least one.

shifter

Why it happens ? Because these two 1k resistors act as a voltage divider with 10k pull up on the LLC (5V side). This means that the input of the LLC is at 0.83V instead of 0V due to this voltage divider. Because of that, the mosfet is not driven and the output of the LLC is 0.83V + mosfet diode forward volatge which is about 0.8V. So we get about 1.5/1.6V in output of the LLC which is greater that the input low voltage of the ESP which is 0.25x3.3 = 0.8V.

To confirm that issue, we could developp a dumy test SW that just put all pins in input and print the state in the console. Then we can manually put 5V on each pin and check if it's correctly detected.

As a workaround, we can eventually modify the resistors mounted on the LLC. Put for example 50k instead of 10k. An removed all pull up resistors on ESP side, the ones we talked previously that are externally mounted on some ESP. By doing this, we are theoretically in the spec of the chip. But it requires some soldering and the PCB of the LLC is very cheap => difficult to replace the resistor without breaking the PCB. custom_llc

To "perfectly" solve that issue the easiest way is to use two pin of the ESP to handle the data line. For all other lines (CS, CLK, audio), we can continue to the use the mosfet LLC or replace it by simple mosfet as shown on this schematic. But these other lines work in a single direction, so only one mosfet and one pin is needed. new_shifter

@visualapproach What do you think about that ?

But now you may wonder why it work for some people ? It may work for some people because, we reach 1.5/1.6V on the input of the ESP. According to ESP datasheet, everything under 0.8V is seen as 0 and everything over 2.5V is seen a 1. It means that everything between 0.8V and 2.5V is undertermined. Depending on some factors, it may work or not.

And why not using the recommended TXS0108E ? Finally, it may be better to use TXS0108E instead of mosfet LLC. What I don't like is that Texas recommend to shorten the output wires and not use capacitive load. In out case, we have long wires and filter with capacitors. So, I'm not sure that the chip works correctly.

My old school design with discrete mosfets takes two more pins (one for the CIO and one for the DSP) but looks more robust.

menime8 commented 2 years ago

thanks for your detailed version But why the direct connections won't work?

IMG-20220710-WA0011

And what is with his issue? He put the USB cable to ESP and then it works. Some problems with low voltage and spreading tolerances from that esp8622? https://github.com/visualapproach/WiFi-remote-for-Bestway-Lay-Z-SPA/issues/325#issuecomment-1182382569

SigmaPic commented 2 years ago

thanks for your detailed version But why the direct connections won't work? And what is with his issue? He put the USB cable to ESP and then it works. Some problems with low voltage and spreading tolerances from that esp8622? #325 (comment)

I'm sorry, I d'ont know. I can explain why I could not work with a mosfet LLC but I cannot explain why it doesn't work with a direct connection. According to internet, ESP is 5V tolerant and according to the datasheet of you microcontroller, 3.3V is enough to be seen as a logical 1. So, I would say that we can connect it directly.

Really I don't know what issue can the powerbank solve.

May be a soldering issue ? Or a broken ESP ? It's my only explanation.

This photo is quite strange, you have a short circuit between 3V and 5V and you don't have the resistor. Do you confirm that you try:

Third try: 560 ohm resistors between DSP and ESP. Display works fine, melody and IP shown.

Where is shown the IP ?

menime8 commented 2 years ago

This is a older picture, bridge was from a faulty circuit diagram.

I tried every thing, with and without, resistors and LLC, tried the mosfet one, tried the other. Tried 560 and 680 ohm. I see the ip in the display. Then the build date

SigmaPic commented 2 years ago

IMG_20220713_125236

About the pinout of the CIO.

Where is the 5V and the GND ? Pin 5 = GND Pin 6 = 5V

??

menime8 commented 2 years ago

About the pinout of the CIO.

Where is the 5V and the GND ? Pin 5 = GND Pin 6 = 5V

??

From left to right 1-6, 5 GND, 6 positiv 5v

visualapproach commented 2 years ago

@visualapproach What do you think about that ?

First I think you've made a fantastic job with the schematics and explanations. Very good! Regarding the double pins per data wire, I abandon it for two reasons; 1 it requires more components and therefore more difficult for most people. Nowadays I think you can get the PCB fabs to populate the PCB but I haven't tried that and it seemed difficult to find the right components. 2 there isn't enough GPIOs on the ESP8266. Not entirely true, but D0 cannot have interrupts and D8 is pulled to GND and boot fails if pulled high. Now, there is RX and TX pins also which I don't want to mess with because it will also make installation harder. However we might pull it off if we use D0 (no irq), D8 (pulled down), D3, D4 (pulled up) and D5 to the DSP since we don't need interrupts there. Leaving D1, D2, D6 and D7 for the CIO. So much for parallel traces :-)

There is also the possibility to switch to ESP32 with lots more GPIOs and horsepower to serve web pages quicker. But it consumes more power i guess, which in some cases seem to be a weak spot. And not to mention - I haven't got it to work yet. (Haven't put too much effort in yet but it would take a lot of time recoding, and making new PCB.)

So, any other options? Are there LLCs with weaker pullups to buy? For your information, the reason I introduced the TX0108E is because for a while the other one was difficult to source and much more expensive. Now I think there is no real difference.

SigmaPic commented 2 years ago

First I think you've made a fantastic job with the schematics and explanations. Very good! Regarding the double pins per data wire, I abandon it for two reasons; 1 it requires more components and therefore more difficult for most people. Nowadays I think you can get the PCB fabs to populate the PCB but I haven't tried that and it seemed difficult to find the right components. 2 there isn't enough GPIOs on the ESP8266. Not entirely true, but D0 cannot have interrupts and D8 is pulled to GND and boot fails if pulled high. Now, there is RX and TX pins also which I don't want to mess with because it will also make installation harder. However we might pull it off if we use D0 (no irq), D8 (pulled down), D3, D4 (pulled up) and D5 to the DSP since we don't need interrupts there. Leaving D1, D2, D6 and D7 for the CIO. So much for parallel traces :-)

Yes it requires to solder SOT23 chips. That's the price to pay :) D0 and D8 are perfect, isn't it ? No need of interrupt on data line, isn't it ? and D0 can be used as an output for data line with an external pull down resistor if needed.

There is also the possibility to switch to ESP32 with lots more GPIOs and horsepower to serve web pages quicker. But it consumes more power i guess, which in some cases seem to be a weak spot. And not to mention - I haven't got it to work yet. (Haven't put too much effort in yet but it would take a lot of time recoding, and making new PCB.)

Yes, it will take a lot of effort.

So, any other options?

Direct connection. Maybe we can add a diode from ESP input to VCC so that the ESP is protected. This resistor will act has a voltage divider with the serial resistors. We can increase a bit the serial resistor value to reduce the current coming from the CIO.

Are there LLCs with weaker pullups to buy? For your information, the reason I introduced the TX0108E is because for a while the other one was difficult to source and much more expensive. Now I think there is no real difference.

I don't think you can buy LLC with 50K resistors.

@visualapproach What is your opinion about @menime8 issue ? He tried with a direct connection. It means it's not an issue related to voltgae shifting.

Do you think it's a good idea to print in the console the command received from CIO ? Every time the CS goes high, you coul print in the console (debug.html) th value of _receivedByte. This would allow to see if he get some command or not.

visualapproach commented 2 years ago

@visualapproach What is your opinion about @menime8 issue ? He tried with a direct connection. It means it's not an issue related to voltgae shifting.

I don't know, there may be something more to it in that case. Don't know if he blew the ESP by shorting 5V and 3V3 or if he has a new one now.

Do you think it's a good idea to print in the console the command received from CIO ? Every time the CS goes high, you coul print in the console (debug.html) th value of _receivedByte. This would allow to see if he get some command or not.

As a one off in this case maybe. Otherwise its a fulltime job to try to decode what's wrong, and it is usually hardware fault caused by bad soldering, bad wires or overheated components during soldering. I think first off is to reduce the chance of this by doing a board self test as you suggested. Then if it does not work for several people maybe go that route. But didn't he have an oscilloscope? Or was it someone else? Easiest would be to check out the signals at the ESP with the scope I think. read below! Risk of damaging the scope You should read something like this: CS. ----__________________________________------ CLK:-----_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_------- DAT:-----___-_---_--____--____--_-____---------

SigmaPic commented 2 years ago

@visualapproach What is your opinion about @menime8 issue ? He tried with a direct connection. It means it's not an issue related to voltgae shifting.

I don't know, there may be something more to it in that case. Don't know if he blew the ESP by shorting 5V and 3V3 or if he has a new one now.

Do you think it's a good idea to print in the console the command received from CIO ? Every time the CS goes high, you coul print in the console (debug.html) th value of _receivedByte. This would allow to see if he get some command or not.

As a one off in this case maybe. Otherwise its a fulltime job to try to decode what's wrong, and it is usually hardware fault caused by bad soldering, bad wires or overheated components during soldering. I think first off is to reduce the chance of this by doing a board self test as you suggested. Then if it does not work for several people maybe go that route. But didn't he have an oscilloscope? Or was it someone else? Easiest would be to check out the signals at the ESP with the scope I think. You should read something like this: CS. ----__________________________________------ CLK:-----_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_------- DAT:-----___-_---_--____--____--_-____---------

Your right, the shortcut may jae broken something.

@visualapproach Do you know if the GND is connected to the ground of the main power ? In other word, is it possible to connect the GND of the CIO to the mass of the scope without any electrical issue ? Sometimes, the GND can be referenced to the main power (230V) and connecting the mass of the scope to the GND can provoke a short circuit. No issue here ?

visualapproach commented 2 years ago

@SigmaPic You are right, I don't know where the GND goes to so maybe a bad idea. Please do not destroy your scopes.

visualapproach commented 2 years ago

And also @air101 found out that his problem was due to a particular type of NodeMCU. #325

menime8 commented 2 years ago

Yes, it was me with the osci. Tomorrow the other ESP arrives. In another issue the ESP was faulty. I think there are a few fakes on the market. I'm very approved with the soldering iron, also with hot air for SMD. I repair since 2015 car amplifiers. Since then i don't have one failed solderpoint. Also i double checked every connection with the meter.

Before the bridge 3 to 5 Volt i also tried ever possible constellation.

I use a USB scope with a laptop! Hantek 6022BE. So i isolated. If the 0V is grounded, the RCD should trigger, i touched it few times while measuring.

Lets see what i can find at the next weekend.

visualapproach commented 2 years ago

@menime8 Sorry for talking about you in third person. The statement about bad solders was a general experience, not directed at you. I just described my situation where a lot of time searching for code errors often ends with success after mentioned problems had been fixed. I think you are great trying to help people in the forums!

menime8 commented 2 years ago

@visualapproach

No problem. Your code works, i think this is approved more than 100 times. My connections are fine, too. So i see the issue at the nodeMCU. My Version is 3.2 with the ESP8266 12F, they say its the better WiFi Version. Now i ordered the older 12E.

I tuned the present ESP to 160MHz, give it a try at the weekend.

visualapproach commented 2 years ago

@SigmaPic I just uploaded a new version to test the setup by connecting the cables together. It runs 1000 edges on each data line, both directions and gives back a report. You need to visit the page "/hwtestinfo.html" to run the test.

SigmaPic commented 2 years ago

@SigmaPic I just uploaded a new version to test the setup by connecting the cables together. It runs 1000 edges on each data line, both directions and gives back a report. You need to visit the page "/hwtestinfo.html" to run the test.

Nice !!! Thanks

@menime8 Do you want to test this software. It may allow you to confirm that's there's is an hardware problem on BWC side

SigmaPic commented 2 years ago

So, any other options? Are there LLCs with weaker pullups to buy? For your information, the reason I introduced the TX0108E is because for a while the other one was difficult to source and much more expensive. Now I think there is no real difference.

After thinking a bit more about that topic, I think I have found "the" easiest solution that fully matches all specifications. I have to check the datasheet again and simulate it but on the paper it works. And the the most amazing is that it can be implemented ok the PCB V2. The solution is so easy that I wonder if I missed something. Details for tomorrow. ;)

visualapproach commented 2 years ago

Curious:)

SigmaPic commented 2 years ago

The idea is to use a simple voltage divider to convert the 5V coming from CIO/DSP into 3.3V. In the other way, no need of conversion since 3.3V is seen as a logical 1 by the CIO/DSP.

Signals look perfect and it could almost be implemented on PCB v2.

llc_with_res

The only issue is the pull up resistor on D3/D4 that make the mess.

These pins shall be replaced by D0/D8 or something else as you suggested it. That's really annoying, there are not so much pins and 3 of them shall be pulled up or down.

Not entirely true, but D0 cannot have interrupts and D8 is pulled to GND and boot fails if pulled high.

We could also use D11 and D12, isn't it ?

@visualapproach What do you think ?

It's easier and cheaper. No need of LLC.

Do you have an idea why the DSP is flashing at boot and why adding serial resistor helps ?

visualapproach commented 2 years ago

The only issue is the pull up resistor on D3/D4 that make the mess.

I think one of them is for the on board LED. How much do they affect the signal?

We could also use D11 and D12, isn't it ?

What is that? I'm only aware of D0-D8

Do you have an idea why the DSP is flashing at boot and why adding serial resistor helps ?

Not really. Obviously random but errors would case things to behave weird. There is 'enable-bits' that would flash the display if toggled, but the strange thing is that it works during start up sequence.

I think it's a nice idea. Would need some mods on the pcb to make it pretty and easy. I wonder if it would work on all other models as well. Possibly the audio will be more silent but it's no good on the 2021 models anyway from what I have heard. What was your setup again @SigmaPic ? Is it working for you?

menime8 commented 2 years ago

The only issue is the pull up resistor on D3/D4 that make the mess.

I think one of them is for the on board LED. How much do they affect the signal?

I deleted the 2 resistors, another idiot idea :-) LED is working.

Where i can find the new software? I think i´m blind...

My new ESP arrived 2 hours ago.

menime8 commented 2 years ago

err

There missing files i need?

visualapproach commented 2 years ago

@menime8 Newest version is found in the development branch: image

Sometimes one need to clean build files: image