I bought a emonTx V4 1 year ago with the intent to connect it to my existing emonBase (bought in 2022). The emonTx V4 came with an ESP8266 Wifi option pre-installed.
I can connect directly to the emonTx V4 via USB cable and connect to the Serial Config Tool at Serial Monitor.
The Serial Config Tool says " Firmware update required: Looks like you are running an older firmware version on this device, please upgrade the device firmware to use this tool."
I don’t know where to initiate this firmware update.
Do I need to recompile the firmware to support PULSE counting on the terminal blocks for Pin 1 (PIN_PA6) and Pin 2 (PIN_PA7). And if so how?
I can also connect directly to the emonTx V4 via Wifi from my Mac computer and bring up the emonESP screen in my browser. But it doesn’t recognize any PULSE input with the device as delivered from the factory. (I have changed the soldered jumpers to select PULSE counting on block 1 and 2 rather than temperature.)
And I am not sure how to get the new emonTx V4 talking to my existing emonBase which is running emonCMS locally on my LAN at emonpi.local.
Disclaimer:
I’ve never tried to use the serial config tool in emonCMS on an emonPi or emonBase, so I’ve no experience of using it.
@TrystanLea
Can emoncms.org drive the serial monitor on an emonbase? Richard’s link above seems to imply that it can, but I was under the impression that the browser had to be working off and looking at the local emonCMS for it to work.
Also, as Richard points out, it looks as if a few more words or a link to the Docs is needed to explain what “please upgrade the device firmware” applies to and how to do it.
Looking at the 3 possible source files for the software inside your emonTx4, it appears that either Pin 1 or Pin 3 (depending on which you have - 6 inputs with or without temperature, or 12 inputs) is already set up to count the pulses, so no recompile is needed. But if you need 2 pulse inputs, then I’m fairly certain that you will need to set up the sketch to use Pins 1 & 2, recompile and upload. I can easily tell you the changes once I know which sketch you’re using, or you can look at the documentation for emonLibDB (included in the zip download EmonLibDB - Version 1.0.2 along with the ‘max’ example sketch) This will tell you what you need, but not necessarily where it goes in Trystan’s sketch - although it should be reasonably obvious. The instructions to recompile and upload are in Docs: Firmware — OpenEnergyMonitor 0.0.1 documentation. Although the powers that be recommend platfromio, I cannot endorse that because when I tried it, it moved directories on my machine (Ubuntu Linux - not too dissimilar to MacOS) and royally screwed up my system. I used the Arduino IDE when developing emonLibDB, so although much more complicated to set up and you need to tolerate the ‘dumbing down’ of Arduino, it served the purpose. And for what you need, once set up it’ll be absolutely fine.
Emoncms.org cannot drive the serial monitor on an emonBase… but… the serial monitor tool that Richard linked Serial Monitor can drive a serial monitor on your computer assuming in this case the EmonTx4 is connected to the laptop/computer in use and assuming the browser is Chrome…
Thanks, the link to emoncms.org implied an almost “over the Internet” remote data transfer was available, and I could envisage enormous difficulties and risks with that for no clear reason or advantage.
As for getting the new EmonTx4 talking to my existing EmonBase, I read the Docs referenced above, but I need to get them talking via the ESP8266 Wifi that came installed in my EmonTx4. The Docs only cover
OK, I got the impression you were going to use the serial connection.
Your emonTx4 has the ESP8266 Wi-Fi unit installed. Correct?
It’s visible on your LAN. Correct?
In the ESP8266, it’s got the address of your emonBase. Correct?
If it’s ‘No’ to the last one, I think the emonTx3 procedure should work for you: https://docs.openenergymonitor.org/emontx3/esp8266.html#setup-procedure and start at step 3 by ignoring the part about a jumper and powering your emonTx4 by whatever means you have - bearing in mind Wi-Fi needs a lot of power.
If it’s ‘yes’ × 3, the data should be appearing in your emonCMS.
If not (and no data appears on the emonESP page as “Latest data”), you need to check that “JSON Format” is off (the default) in your emonTx4 - and for this you do need the Serial Monitor.
Your emonTx4 has the ESP8266 Wi-Fi unit installed. Correct?
It’s visible on your LAN. Correct?
In the ESP8266, it’s got the address of your emonBase. Correct?
Thanks! That’s the Doc I needed. I now have the EmonTx4 talking to my EmonBase. (I think it’s using MQTT to do this).
I still need to figure out how to get the PULSE counting working on my EmonTx4. I actually need to get two pulse counts working. But I’ll work on that problem some more tomorrow.
I thought I’d already covered this? If you can’t make sense of it, tell me which of the green sockets you want to use for pulses, and I’ll tell you what to change in the sketch (now we know which one it is). I’ve counted pulses on all three inputs, so I know they all work when the correct API call to the emonLibDB library is in place.
If you’re familiar with the Arduino IDE, use that - and preferably the last 1.8.19. The first Arduino 2 wasn’t too good, I dumped it, it’s now on 2.3.3 and might have had the wrinkles ironed out - and might not (e.g. you couldn’t use your favourite external editor, which is a big deal for me). I won’t touch the other junk, so if you go that way, I can’t help you. You’ll need to download and put libraries in the correct places as listed in the Docs page I’ve given you, once that’s done it is straightforward.
Let me know if you want the changes to the sketch, or if you want to look at it yourself first.
Can you confirm you’ll only use the ESP to send the data, not the ISM band 433 MHz radio?
I think the Arduino IDE will suffice, but I do have VS Code (on Mac). I have some homework to do.
Correct. I don’t have a need for the ISM band 433 MHz radio from this EmonTx4. (But I do have another EmonTx3 that does use the 433 MHz radio to talk to the same EmonBase. I think that should all continue to work the same as it has.)
If you can highlight the changes I need to make to sketch that would probably be very helpful. Thank you.
What is the source of your pulses - a reed switch, or something electronic, i.e., do they have contact bounce or is the transition clean, and what is the duration and sense of a pulse, because while it’s not difficult to set up the config for the two pulse inputs, emonCMS most likely won’t handle the second in any case. You can easily change the pulse input parameters and recompile if you have to, but it’s easier to get it right first time.
[Extended]
I’ve looked through the files in detail now. There’s a problem, not insurmountable but potentially costly in time, with the _config file. There are significant differences in the code from when I wrote the original, so it’s going to take either you or I or both of us some time and effort to add in the code for the second set of pulses, in order to be able to use the serial input (via a terminal emulator, not emonCMS) to change the pulse settings on-line without recompiling and re-uploading. If you think this is important to you, we’ll give it a go. The alternative, quick and simple way is to hard-code the pulse input parameters. What do you think? From my workload’s point of view, I’d prefer the quick and simple, because I think once set, it’s probably never going to need to change, and I think you have the ability to do the recompile and upload. You can’t do an Over-the-Air upload or config via your ESP, so either way it’s a USB cable to a Pi or other computer…
I’m building this system to replace a system I had built a number of years ago using a Particle Core Photon (ver 1) microcontroller. The Photon is an Arduino-like device. I was driving a digital input of the Photon from a Stenner JLP0750-1PPG water meter (see below). I had been finding the Photon (which has long ago been discontinued) to be occasionally unreliable. Also I was using Google Cloud to log the pulse events. That part has been reliable, but it’s quite complex.
The replacement system will log pulses from two separate pulse-per-gallon (PPG) water meters to my EmonBase. These meters use reed switches. But there’s a caveat for the first PPG meter.
In the case of the Stenner model the reed switch is triggered by a magnet on the dial. Specified as “Non-voltage dry contact water meter. Min signal durations: 10 milliseconds”.
But that PPG1 input is driving two relays through an amplifier on a shield (schematic): one relay is going to the EmonTX block 1. (The other relay is driving a Chlorine injector.) (The shield was previously hosting the Particle Core, but the Particle Core is superfluous. Instead the two relays are being directly driven by the PPG1 input bridged to fire both relays.)
In practice the gallon pulses from the Stenner are 9 to 12 seconds apart measuring the productivity of a domestic well pump. It is possible that the magnet driving the reed switch could stop with the switch closed.
The other PPG2 is an equivalent to the Stenner: DAE PD-75
It is planned that it would directly drive the EmonTx4 pulse input block 2. But I don’t know the pulse rate on the second PPG2 meter yet. PPG2 is measuring water distribution from a holding tank. So it will be faster than PPG1.
Hmm…
The relay is a mechanical contact, so you will need the protection against contact bounce enabled for both. It does handle a stalled dial correctly. Are the relay contacts volt-free, and you’ll use the pull-up provided by the processor and you’ll connect the relay between GND and the respective input pin? One point to consider is the contact material of the relay, and if it’s suitable for the very low current, approx 140 µA. (Ref: AVR128DB28/32/48/64 Data Sheet, page 604). If it’s not a sealed reed relay, you might want to consider replacing it with such.
In the case of the DAE meter, they specify it’s a reed switch rated at less than 10mA at 24 V, so this will be OK wired directly into the emonTx4 as above. But this too will need de-bouncing.
If you want to look at the library API, you can count on either edge of the pulse (but not both!) and you can set “the minimum period of time that the pulse must be active and in a steady state to be
recognised, in ms. This must be shorter than the duration of the pulse.” This means the pulse needs to be steady (in whichever state - 0 V or 3.3 V) for longer than it isn’t, and the time you set is between the two.
Having looked in more detail at the changes you’ll require, it was getting too hard to tell you what to do, so I’ve gone ahead and done them for you. I need to check that everything still works as expected.
The relay shield uses four Panasonic JS1-5V-F relays. (It’s an obsolete part.) Each relay is triggered via a NPN transistor that takes a control signal from the PPG1 meter and switches the relay coil ON and OFF, which in turn makes or breaks the electrical contact on the output. There is also a fly-back diode connected across the coil to help protect the transistor from high voltage transients caused during switching.
In test with the EmonTx4 being driven on input Block 1. The EmonTx4 block is wired Ground to Relay Common and Pulse to Relay Normally Open. I can simulate pulses with a push button. But depending on the timing it triggers 1 or 2 pulses per press. This kind of makes sense based on what say above about the pulse requirements.