Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modbus devices #5

Open
gkasprow opened this issue Dec 10, 2017 · 0 comments
Open

Modbus devices #5

gkasprow opened this issue Dec 10, 2017 · 0 comments

Comments

@gkasprow
Copy link
Owner

gkasprow commented Dec 10, 2017

There are many popular industry-grade MODBUS devices that can be used for IoT purposes.
I purchased some of them: energy meters, humidity/temperature sensors, relay boards, UART-RS485 boards, DIN relays, etc.
So that's a pity that it is not supported by Cayenne environment.
So I did some quick setup to test how it works in practice.
I took ESP8266 devkit, ORNO energy meter, relay and built power switch with energy monitor. There are many such devices on Aliexpess, some of them are based on ESP8266. I tested one from Edimax and it works unreliably. While in local network it works just fine, outside of it works sometimes. So it is not the way to go. One idea is to replace the firmware with some alternative, another is to build it. Modbus is already supported by Arduino so why not to try. I connected 15$ energy meter to 2$ ESP8266 devkit, added 1$ UART to RS485 converter, some old Nokia phone charger SMPS board and wrote a few lines of code. I added also mains outlet and 2$ electrical box with DIN rail.
Here is the bricolage
20171209_185707

The code is very simple:


    result = node.readHoldingRegisters(0, 9);
 if (result == node.ku8MBSuccess)
   {
    Cayenne.virtualWrite(4, (float)node.getResponseBuffer(0x00)/10,"voltage", "Volts"); //voltage
    Cayenne.virtualWrite(5, (float)node.getResponseBuffer(0x01)/10, "current", "Ampere");//current
    Cayenne.virtualWrite(6, (float)node.getResponseBuffer(0x02)/10, "freq", "Hertz" );//frequency
    Cayenne.virtualWrite(7, node.getResponseBuffer(0x03), "pow", "Watts");//Active power
    Cayenne.virtualWrite(8, node.getResponseBuffer(0x04), "pow", "Watts");//Reactive power
    Cayenne.virtualWrite(9, node.getResponseBuffer(0x05), "pow", "Watts");//Apparent power
    Cayenne.virtualWrite(10, (float)node.getResponseBuffer(0x06)/1000);//Power factor
    Cayenne.virtualWrite(11, (float)(node.getResponseBuffer(0x07) *256 + node.getResponseBuffer(0x08))/1000);// Active energy
    Cayenne.virtualWrite(12, node.getResponseBuffer(0x03), "pow", "Watts");//Active power
     }
	}

And the result

obraz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant