IotaWatt 4.0

I was suspecting something like an autoupdate looking at the boot message :wink: . Personally iā€™m not such a big fan (donā€™t fix it if it isnā€™t broken), so maybe you can make this feature user selectable (havenā€™t looked if itā€™s not already)?
I was planning on making an adapted version on one of the other pcbā€™s i got, but with spare parts (i have 5 more mcp3008 lying around, and another rtc), so iā€™ll look into this autoupdate version.

I used the latest version from git for the ino files (i compiled it myself to change the voltage referenced). The changelog says 2.02.10.
I updated the files on the sd card as well, and it stays 0 for the outputs. (just for the record, iā€™m not running a ā€œserverā€ (Web Service Type is set to none"))

Copy-pasting the ā€œrefvoltsā€:1, strangely didnā€™t work, but manually typing it worked :wink:

Will be doing a lot with this, but not right away. In the meantime you can remove the statement

NewService(updater);

in setup so that the update service does not run.

given that your device seems to be working properly, I assume you are using MCP3208.

No idea why its not working. Would need to see your config.txt file and pictures of your configure outputs screen and the status screen.

Sorry to keep bothering you, just let me know to stop :wink:
I have my config.txt here: www.hetgrensland.be/iota/config.txt
a screenshot for the configure outputs: www.hetgrensland.be/iota/inputs.JPG
a screenshot for the configure outputs detail: www.hetgrensland.be/iota/inputs2.JPG
a screenshot for the status screen: www.hetgrensland.be/iota/status.JPG

I also tried to use emonCMS with my own server, but it seems to fail, maybe due to a IP? (server is running on a synology)

UPDATE: seems to be related to the HTTP/1.1 on line 311 in eMonService)

a screenshot for the server config: www.hetgrensland.be/iota/server.JPG (see also the config.txt)
and a screenshot of the serial console: www.hetgrensland.be/iota/serial.JPG
Pasting the url visible in the serial console, with the 10.0.2.115 in front does work (the feeds show up on the server) but with an error (SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data) and raw data (in firefox (ok) This server also receives input from my diy emonPi
Strange thing: sending it to the emonPi first gave error (invalid api key) but after a reset workedā€¦

Another minor problem: the link in the serial console http://IotaWatt.local seems not to work on my system, maybe you could add the IP also?

To answer your other question: yes, i used the mcp3208 for this version, but since i have them lying around, and 30 circuits to measure, i was thinking of making a ā€œlesserā€ version

Everything looks OK to me, so I have no idea what might be going on. Itā€™s possible that some of the other include libraries that I have are modified or older versions and so we donā€™t have the same code. What I would recommend is that you leave the updater service startup in place, set the version of your code to 02.02.09, load it ans let it auto update to my 02.02.10. Then see if it works, making double sure you have the index.htm thatā€™s on the Github site.

https doesnā€™t work. Use http for now. Itā€™s about not having enough heap to support ClientSecure. We have a solution but itā€™s not ready yet.

should work with the ip address. to use IotaWatt.local, your browser device must support mDNS (muticast DNS). The most common implementation is Appleā€™s Bonjour, which you can download from them. There are others as well.

Iā€™ve only coded and tested for emoncms.org. Glyn Hudson recently got his IotaWatt running with his eMonPi. Version 2.02.10 has the changes that enabled that. This is a whole area that will have to be tackled as time allows. The immediate intent is to support emoncms.org and the pi as configured by OEM. If you figure it out before I do, please share.

I found out that the problem with the ā€œnormalā€ http send in eMonSend is that itā€™s not accepted by the synology standard webserver. I think itā€™s connected to the fact that itā€™s HTTP/1.0 i changed the
"WifiClient.println(String("GET ā€œ) + req);ā€

So now it reads:

WifiClient.println(String("GET ā€œ) + req + " HTTP/1.1\r\nā€ +
"Host: " + eMonURL + ā€œ\r\nā€ +
ā€œUser-Agent: IotaWatt\r\nā€ +
ā€œConnection: close\r\n\r\nā€);

Because of this i had to change the check of the reply (itā€™s not just ok anymore but HTTP/1.1 200 OK and a lot more)
I changed it to: (i guess that the first check isnā€™t needed anymore.
if(reply.substring(0,2) != ā€œokā€ && reply.substring(13,15) != ā€œOKā€ ){

This works, for me. however, sometimes i get a timeout . Increasing the timeout from 200 to 1000 seems to solve this.
I tried this solution with my emonpi (the old way worked with this also) and with the emoncms running on my synology.

That whole area was coded a long time ago and tested to work with emonCMS.org. It will be changing soon to use http POST, with encrypted data. Post also seems to be returning the full http header info to client.read, so there needs to be code to parse that and get at the data that follows which will be a sha256 acknowledgement. Iā€™m looking at using httpclient to do that, although Iā€™m not really sure at this point.

With the auto update the outputs work. Could it be that the github version isnā€™t the latest? (or maybe there is a difference in libraries)

The GitHub master version definitely isnā€™t the latest, but it should match the auto-update 2.02.10.

Yes, itā€™s possible my libraries are different from yours, although I cant imagine why that would cause outputs not to work. Iā€™ll make a note to refresh my libraries. I do have an old version of arduinoJson.

Could it be that webServer.ino file has been changed since the github version, more specific the if(server.hasArg(ā€œoutputsā€)) on line 281 and next?

Because if I uncomment your Serial.print lines in IotaOutputChannel.h (lines 146-150) I always get 0.00; 1, 0.00 on serial. (when calling /status?outputs=yes)
No matter how may operands the output has in it, i only shows up one time.

No, thatā€™s not it. If that were evaluated false, there would be no attempt to send any output channels.

Thatā€™s a good clue. Every script evaluation should begin with that line as those are the initial values when entering the function, but more lines should be generated as the tokens are evaluated. I would have expected a line when the input_3 line was evaluated. It looks as if the script was not properly encoded into runtime tokens.

On the surface it is indicative of a mismatch between my libraries and what you have, and it may be something that eventually comes to the surface, but I donā€™t want to spend the back-and-forth to try and determine if thatā€™s really it and if we have different libraries.

Unfortunately, I have little motivation to work on the problem as is because I have another branch containing a complete rework of the scripting feature that is just waiting to go. I havenā€™t rolled it out because I need to more thoroughly test the code that converts old scripts to new, and because the configuration app also has a complete rework of the logic under the ā€œcalculatorā€ interface. This is one of the few remaining major changes on my short list to an actual release.

I believe you should be able to see that branch called convert-to-new-output-script. That branch is compatible with the current master branch, so if you want to head farther out on the bleading edge, compile that and try it, otherwise, Iā€™ll be merging it into master in the next week or two. Make sure to grab the index.htm file in that branch as it wont work without it.

A little ahead of schedule. Updated master branch to 2.02.11 to convert to the new scripting format. If you still have auto update on, it should load within an hour. This version will still accept the old scripts, converting them to the new format for internal use but leaving the old format in the config.txt file.

After the update, installing the latest index.htm from the SD directory on Github will convert the old scripts the next time it stores an updated config file (after any edit).

If you like, you could try just compiling the new source to see if outputs work with your libraries. Iā€™d be interested in the result.

Nice work!
I recompiled it (with the changes for my emoncms server), and changed the index.htm through the website
The result is a partial succes.
The output does work now (on the input channels status page) , but there seems to be a problem with the webpage for the configure outputs : the first tim (with the old rules in the txt file) it works normal. But after changing them it does not anymore: i attached a screenshot with the errors from firefox console. It seems that there is a TypeError. I havenā€™t looked into it yet but wanted to share it.
screenshot: www.hetgrensland.be/iota/configout.JPG

edit: in config.txt it reads:

ā€œoutputsā€: [
{
ā€œnameā€: ā€œtestā€,
ā€œunitsā€: ā€œwattsā€,
ā€œscriptā€: ā€œ@3ā€
}
],

UPDATE: i think i found the problem: itā€™s in the function checkConfig()
there it checks config.format == 1, this is always true it seems, disabeling
config.outputs[i].script = old2newScript(config.outputs[i].script);
makes it to work.
I think maybe you forgot to set and read the format type in config.txt?

Iā€™ll look into that, but can I see the config.txt file?

I found it. I will post the corrected index.htm today, but the damage is done for you. Please edit your config.txt file to change the format to 2.

ā€œFormatā€: 2,

There was one last bug ( if you believe that) that didnā€™t make it to the Git. Line 1247 in index.htm should read config.format = 2;
(Instead of config.format == 2;)

UPDATE: Done.

Yes it works :wink: , stupid of me not to see the == that should have been been = when i commented out the line

Youā€™re doing just fine.

Frankly I,m amazed that you were able to build one and get it working first try with only the schematic to go on. Also, that the software is working as well as it is fresh to the outside world. These problems were all minor and easily solved - no hardware issues to speak of.

Iā€™ve got a few IotaWatt running in various sites in the US, but they are really just people who agreed to let me run them in their homes. They contribute nothing to the testing and development.

Iā€™m looking forward to you getting the three phase going because I donā€™t have any three phase test sites. Iā€™ve programmed for it, but I feel like the guy in Flight of the Phoenix who built ā€œmodelā€ planes. Weā€™ll see how it flies.

If youā€™re up for it, there are some experiments that I would like to run to determine the accuracy of measuring three phase with only only one VT. The approach is the same as the Emon ā€œthree phase sketchā€, but can be done through the config utility and should be more accurate because the sample rate is ten times that of the TX.

1 Like

As soon as the developer kits are available Iā€™d also be happy to help with testing the three phase approach.

Iā€™ll probably start a new thread ā€œIotaWatt three phaseā€ when the time is right. There will probably be some configuration options to turn on three phase specific configuration options so as not to burden the 99% with that complexity. Same goes for the forum thread.

Thanks, iā€™ve been looking at the project for some time and i have build my own frankenstein emon (first 3 ct but adapted to 7) with a custom 3-phase script i adapted from the forum. So i wasnā€™t completely a noob :wink: .
However, looking at your project and code iā€™m still amazed how good it is put together and how good it has been engineered. (i still canā€™t grasp everything from your code, so iā€™ll have some more digging to do :wink:

Sure iā€™m willing to help you out with a 3 phase test, just let me know. (currently i have 5 extra ct and 2 extra vt next to the running old setup)

The 3 phase setup (emon) i have running now is doing relatively ok, but i can see that the measurements of a minor consumer (eg 5 to 10 watts) is sometimes influenced by a big one. Since i was at the limit of the arduino nano running it (without using extenders etc) i was happy that your project came along!