Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Connect & read pulse sensor output from a Mac

Hi all, I’ve been reading a bit and want to start logging our energy consumption with the minimal amount of new hardware.

Currently I have a Mac running as a server, physically very close to our utility meter.

There seem to be a few different USB connected breakout boards available, but I’m having trouble telling if these boards will enable me to get input readings from the optical pulse sensor via an USB connection.

From reading the specifications of the pulse sensor, maybe a simple USB <-> serial (TTL) adapter will be enough to get readings?

https://openenergymonitor.com/programmer-usb-to-serial-uart/

Please share any suggestions, ideas and/or experience you might have.

I’d say using an Arduino to read the pulses by interrupt then send the number of pulses over serial at whichever frequency you like.
I think you will need some kind of microprocessor independent of your mac to do this easily.

A long shot would be hacking an input on the mac and reading the pulse value. Perhaps some code to read the microphone jack input.

Recently I discovered the emonTH can accept these pulse inputs, so you could have pulses, temperature and humidity all in one sent over serial with your FTDI adaptor, possibly you’d need some minor changes in the firmware, I’m unfamiliar with the TH’s firmware, it might already be set to send data over serial.

@danbates Thanks for your insight!

Looks like getting temperature readings from DS18B20 using the approach I suggested above works fine.

Can anyone please confirm if it should be possible to read pulses from the Optical Utility Meter sensor using a similar adapter/programmer?

I take it you mean Optical Utility Meter sensor?

@Bill.Thomson Sorry if I was unclear in my post above. You are correct and I’ve edited the post to clarify this part.

Do you have any other knowlage to share on the topic?

Not a problem. Just wanted to be sure everyone was on the same sheet of music.

If you’re speaking of the sensor sold by the OEM Shop, it’s actually an analog device.

That’s right. The temperature sensor in the instructable article is capable of digital communication. The optical sensor is old skool analog. Roughly speaking, low output in low light, high (near Vsupply) output in full beaming light.
Hence, you probably need an intermediary microprocessor like an arduino.

Thanks for pointing out that it’s an analog sensor. Will it therefore be suboptimal to read it’s output with a serial adapter?

According to the EmonTx’s documentation on pulse counting, this sensor should be connected to the same interface as the DS18B20 sensor.

The OpenEnergyMonitor optical pulse sensor can be connected directly to the emonTx V3 via its RJ45.

Beyond suboptimal.

It’s understandable where the question comes from. RJ45 is a physical plug/socket standard.

What signal type the RJ45 is carrying through it could be any of the myriad of digital or analog varieties, for example ethernet.

The device being connected (the sensor) is in fact a 3 wire analog device.

The RJ45 was chosen on the Tx for convenience as the sensors come shipped with an RJ45 plug.

You could if you like, cut the plug off the sensor, and connect the three wires what you like. They’re Vcc (up to 5v), signal, and GND.

If you can read individual bits, individual 1s and 0s from the serial adaptor, you’ve got a chance. That might be worth a look. My understanding is that normal serial comms works in handshaked bytes, not bits, so it wouldn’t be a standard thing, to read the high and low of a sensor like this.

Edit: RJ11 is usually for telephone :slight_smile:

To flesh that out a little more, the optical sensor doesn’t send a message, like the character ‘1’ meaning “I see light” or the character ‘0’ meaning “It’s dark”, it generates a voltage. If your serial adapter transmits the control lines (DTR, DSR etc) and those can be read at the receiving end (the old AT command set maybe?), then you might be able to use that and you stand a chance. Otherwise as @danbates said earlier, you need a small processor to see the change in voltage and generate a suitable message that your Mac can receive and do something useful with.

Exactly. If you can find a way to read the digital state of these on the serial adaptor then you’ve got a chance.
If you’ve got the drive to make it work have a look at python-serial modules. A script could be written in python (or your language of choice) to read the state of the control or reset lines of the serial adaptor.

Thanks again @danbates & @Robert.Wall for bearing with me. It’s clear that I need a microcontroller to convert the analog “signal” into digital values.

Any suggestions or preferences in hardware? Reading around, just an Arduino won’t do as it’s not a “USB host”. I will need additional hats etc?

What do you think about the specs of the following boards for the task at hand?

They both have analog input pins and the correct voltage available for the sensor. But I’m not sure if the Trinket (first board above) will enable me to get real-time signals via USB.

An Arduino will work, for example the Uno, Nano or Micro, as will both of those with some extra work.
Seems like you’ll have to take a leap and try get something working!

I don’t know the Arduino platform, so I cannot advise you.