G+_Rud Dog Posted December 16, 2018 Share Posted December 16, 2018 This is a cludged code example but still warrants the question why does the Serial.println() print out the current twice in the com port output monitor? The Client.println() just below or above only sends the current once? lines 185 - 188 https://pastebin.com/MuKcbnqB Link to comment Share on other sites More sharing options...
G+_Bob Shields Posted December 16, 2018 Share Posted December 16, 2018 Arduino's Serial.println() function does not support float/double arguments like your "Irms" variable. See forum.arduino.cc - printing a double variable for a possible work-around. Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted December 16, 2018 Share Posted December 16, 2018 Not sure. Because of line 124 (or line 141) plus line 188? When does it double print? When washer on or off? Maybe comment out lines 187 and 188 and see what happens? Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted December 17, 2018 Author Share Posted December 17, 2018 If you look at the code in the HTML section you will see only one Client.println() and one Serial.println() and yet when this code is processed it prints out two lines for Serial.println() and one line for the client.println(). Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted December 17, 2018 Share Posted December 17, 2018 Rud Dog I did look at it, of course. I see what you are saying, but that does not help answer where the other entry is coming from. The way you troubleshoot things like this is to experiment (I suggested commenting out lines 187 and 188 as a test). I'm not that familiar with the webpage portion of your code. What is the purpose of lines 187 and 188 being in that location? Perhaps there is an unexpected interaction with client.println and the webpage code is "echoing" back your Serial.println ? Just a guess ... today I dismantled the breadboard where I had your circuitry duplicated, so would have to put it all back together to try out your code. If you could print here exactly what you are seeing, perhaps that would give a clue. Are you seeing something like: Current Draw is: 1.8 Printing Irms 1.8 Printing Irms 1.8 Or something different? (I made up the 1.8 obviously) I don't see your body closing tag, so maybe you need a: client.println(" Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted December 17, 2018 Author Share Posted December 17, 2018 Keeping a focus on the problem; the web page prints Irms once while the serial monitor port print Irms twice. There is only one line of code calling out that unique print statement. If I comment out lines 187 and 188 //Serial.println("Printing Irms"); //Serial.println(Irms); (This was tried early on as the best practices step to figure out why the Serial.println() was printing twice. The results were) And after that, no Printing Irms shows up either once or twice. Added the client.println(" Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted December 17, 2018 Author Share Posted December 17, 2018 Bob Shields thank you for your input. Are you saying the serial.println() will print twice if it is not float/double arguments? Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted December 18, 2018 Share Posted December 18, 2018 Rud Dog When you originally asked "why does the Serial.println() print out the current twice in the com port output monitor?", you didn't show us an example of what was printing, and I thought you meant it was printing the same Irms value twice in the serial monitor (as shown by the example I made up). Now that you've shown us what you are actually seeing, it's even more curious. The question now is not why is the Irms value printing twice, but rather why is it NOT printing 4 times! The example you posted shows the line " Running void loop()" being printed 4 times in the serial monitor. That shows that the loop ran 4 times. My question (that I'm asking myself) is why it only printed the Irms 2 times in those 4 times? I have taken your code and deleted all the other lines that do not pertain to this particular result, but have not yet discovered the cause. Is there more that you are seeing in the serial monitor than you are posting here? Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted December 18, 2018 Author Share Posted December 18, 2018 Currently working on figuring out a way to bypass the fluctuating current during the wash cycle. Getting back to the original question I don't know. What is not clear to me is when the line for printing Irms has run it prints out two times there were others but that is acceptable as those are printed as it goes through the code again. (LOOP) I think. Not sure how you are seeing four times but will review that when I reload the code into the device as stated I am working on getting around the odd low and hi currents during the cycle. Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted December 19, 2018 Share Posted December 19, 2018 Rud Dog Four times through the loop is what you showed us in your message. Here's a copy ( I added the numbers for counting) (1)Running void loop() Printing Irms 1.52 (2)Running void loop() (3)Running void loop() Printing Irms 1.47 (4)Running void loop() Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted December 19, 2018 Share Posted December 19, 2018 Rud Dog As for getting around the extra high/low numbers, I had a thought of adding a bunch of them (say 10 or so) into an array and then taking the average and using that. You could also add a bunch to an array then strip out the Min and Max (low and high) values, then take an average. Link to comment Share on other sites More sharing options...
G+_John Sullivan Posted December 19, 2018 Share Posted December 19, 2018 John Sullivan Ok, think I got it figured out. Notice two things: (1)your IF statements don't have options for all possible Irms readings (2) this line of code: if (!client) { return; } Going back to the example you provided ( and I add numbers to), the loop continues until it runs the test for the wifi connection, which fails. When it hits that line (If(!client), there is no connection so it "returns" and starts the loop again. You showed us four samples of the loop, two of which the Irms was below 2, so your code called to print the value. (numbers 1 and 3 in my example) You also had two runs through the loop where the Irms was above 2 AND washer ==0, and you don't have any code to handle that, so it just printed "Running void loop()" (my examples #2 and 4) Link to comment Share on other sites More sharing options...
Recommended Posts