Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Esp8266 first 2 jsons have incorrect values

Status
Not open for further replies.

dr pepper

Well-Known Member
Most Helpful Member
I'm putting togther a project that measures & displays temps & water flows for some liquid cooled brakes on a machine.
The Esp hosts a webpage, which contains 4 gauges and a graph.
It works except when the page opens the first 2 json updates (the one in the init part of the page, and the concurrent one) are corrupt, they are about double what they should be, all the ones after this are correct (only 2 out of the 4 values are corrupted, the others are fine).
If I have multiple pages open then when yet another page is opened all the pages corrupt for 2 consecutive json updates then the problem goes away.
This only happens if I access the Esp from a remote connection, locally (192.168...) it works perfect.
I'm a bit stuck on this one.
 
Are you able to check the json string on the esp end to figure out where or when it's being corrupted?

Mike.
 
No not really, its fastened onto a winding machine.
However I could program another chip with the same code & run it at another location and monitor the json, the code does print it to the serial port.
I ran chromes element inspector (F12), and programmed the chip to o/p the json string to the console, the data shows up on the console corrupted, the same as it does on the page.
Pic attached the first 2 json replies on the console show corrupted data for opflow & driveflow, the following ones are Ok, sorry about the smudging:
winding.png
 
Last edited:
That doesn't look like corruption. It looks like somehow the ESP is getting the wrong values when it builds the json string as the rest is all correct. sounds like you need to duplicate the problem to try to work out what's happening. Not very helpful I know but all I can suggest at the moment.

Mike.
 
Yes I think I agree.
Whats confusing me is that if I access the Esp locally it works perfect, the thing only messes up when I access it remoteky from another network.

Edit: The Esp8266 unlike the Esp32 is single core, the flow sensors have a rotating paddle wheel and a reed switch, said switch generates interrupts in the Esp, so I'm thinking of disabling interrupts when the Esp services the net functions like the json reply and index routine, as I'm now thinking maybe the wifi side of things is messing up the timings in the chip causing the measurement period to change.
 
Last edited:
The problems interrupt orientated, if I tell the Esp8266 to send a permanent value instead of the measured one it works.
Seeing as the measured value is a frequency and interrupts are used to time it then thats possible, and I guess the Esp8266 is working 'harder' communicating remotely rather than locally.
I odnt think I'll find the bottom to this one, so I'll see if I can think of a work around, I tried a couple so far but they didnt work.
Its simpel to detect when a new page is being opened, so I could work on stopping the flow measurement and keep the old values till the page is loaded, then resume.
 
Last edited:
If the design isn't fixed yet then maybe a helper chip can be added. An 8 pin pic as an I²C slave and a PWM module could handle the timing. When using ESPs I have used an I²C slave to add more peripheral handling. The 16F18313 is 8 pin with I²C and 2 capture compare modules and cheap.

Mike.
 
That had occured, but I'm not at the give up point yet.
I'm going to see if I can find a way to suspend measuring flow while the Esp is loading a page.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top