IotaWatt 4.0

Thanks! I hadn’t found that you could simply change it in the config file (nice !) so i recompiled it from source. Now it’s working fine. I had to recalibrate the VT indead, but it had to be set higher. (used to be around 7, now around 18, using the “official” VT from the store).

Only thing not working right now is the output, somehow they all stay 0 (even the ones linked to just 1 input). I’ll have another look this evening.

Glad it’s working. Yesterday I was on a road trip and fired off those responses during pit stops, using the email reply method. When I reviewed the thread last night I saw that I hadn’t read the bottom of a couple of your posts and that you were actually a step ahead of me. Two paths to the same end.

Don’t know which version of the software you cloned, but after version 2.02.03 it starts to auto update from the iotawatt.com site. So if you make changes to a version after that, they will be gone when a new version loads. That’s why the config entry is a better way to deal with the different voltage reference shunt.

The output stuff has evolved, and I have a pretty significant change that will be merged soon. It looks the same outside, but keeps the script in a more compact form in the config file, and the calculator interface is reworked to edit the new format. as a result, the index.htm configuration app changes with the ESP firmware. You probably have a version mismatch now that is causing your problems. If you haven’t changed anything but the reference volts, you might consider cloning the latest Git, using the refvolts config parameter, and loading the latest SD card apps. Somewhere In there, the graph app was reworked to work much better on iotawatt as well. You can copy all but the config.txt file and iotawatt directory and it should work fine with your your config and logs intact.

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.