Hot answers tagged

9

I did a lengthy post about RS485. First, your use of Megas seems an overkill, unless you already have them to hand. A Uno, or one of the smaller form-factor boards would seem to be perfectly adequate to monitor a few switches and turn on a couple of lights. Even the Rpi seems unnecessary. Another Uno could easily monitor your RS485 lines and connect via ...


3

To send series of bytes over Serial or any other Stream (Print) implementation use the "write buffer" method size_t write(const uint8_t *buffer, size_t size) For the case in question: byte request[] = {0, 0x03, 0, 0, 0, 0x01, 0x85, 0xDB}; RS485Serial.write(request, sizeof(request)); If someone is curios about the Modbus RTU request bytes. They are: ...


3

Check out the library Modbus-TCP on Github. It has the facility for all the function codes as asked. It has provision for Wiznet W5100 and ENC28J60 Ethernet IC. All tested with Arduino Mega. See the well documented example code for the Wiznet module in the library. For detailed knowledge about the library, read the index.html inside the doc folder of the ...


3

I have made it. Now it is working. I only checks A & B cables (tried a new one) and change address of register from 5000 to 0x5000 and now it works. I thought that this library already give 0x before address, because i didn't see it anywhere with 0x before. An advice for people with the same problems: Most of the devices which is using RS485 and ModBus ...


3

You should be fine. RS-485 does specify signal levels of ±1.5V to ±5V, but even so, and even when the sensor would misbehave or when the common mode voltage is low or high, there is still the TTL-to-RS485 converter in the middle that has 5V TTL logic on the Arduino side. As long as the TTL-to-RS485 converter is properly connected to the Arduino and working ...


2

Maybe this question is too old and the API has changed, so my answer is reference. The ModbusMaster constructor does not accept parameters. From reading the source code, the method begin(uint8_t slave, Stream &serial) just initializes variables and can be called again with a new slave value without the need to destroy the ModbusMaster object. ...


2

It's not very well documented for the slave but maybe that is because it only has two methods... It looks like the slave library is contained in the same library as the master but with name ModbusSlave485.h You can see in the .h it only has two public methods. One is connfigure() and the other is update(). see below an extract from the .h which explains ...


2

Remember RS485 is not a protocol, it is a definition of a physical transport layer. With the Mega as you chose you can use serial 1,2,3 and run them in full duplex mode over the RS485 network e.e. you can receive what you send. I have it operating in a multi master configuration. Each mega when it transmits it also receives what it just sent and can ...


2

I2C and RS485 are such vastly different protocols with such vastly different signalling needs that they cannot share the same cables. Further, I2C is not designed for connecting with long cables - it's meant for use between chips on a PCB. The simplest "Arduino" solution would be to create a new RS485 device on your RS485 bus using another MAX485 and a ...


2

I even didn't check the Modbus part of your code but the first think what I found: You are using the D2 pin for LCD and at the same time as TXEnablePin...


2

I'm not sure this can really be considered topical, but someone wanting to read floating point numbers over MODBUS with an Arduino might get something out of it. Also I have no way to test this really. But here goes: Your MODBUS map shows V2N at 30002, and you notice 30003 is not mentioned in the map. Your voltage from phase two to neutral appears to be ...


1

The setTransmitBuffer calls are for writeMultipleRegisters, which you removed from the example. The first parameter of the readHoldingRegisters is the address of the register. The second parameter is the count of registers to read. Your sketch doesn't show the retrieved data. You have no indication of success or fail.


1

The ModbusIP library expects from you that you supply the value of the register. The AirSensor library gives you that value. Set the register value to Hreg: mb.Hreg(SENSOR_ISTS, airSensor.getTemperature()); I tested your sketch without the sensor library and it is working. Client was my java test client I use to test access to Modbus TCP registers of my ...


1

Connect both of your appliances i.e AC and Humidifier to 2 different relays. Connect the relays to the Arduino Uno digital I/O pin using a small current amplifier circuit or a Darlington Transistor pair that will amplify the current going to the relay. Relay circuit Darlington Pair Now the connection of your sensor with arduino. In your code you have to ...


1

You should use two relays to operate the two devices. You would have been able to use one relay, if you would have one device ON or OFF by default. For the relays use separate I/O pins declared as OUTPUT and have some circuitry for Arduino output current to be amplified, before the relays and after the I/O pins.


1

You should update the comments and remove unused settings like the count fields for request with one value (function 5 and 6). au16reg are the data to be send. ignore the binary format from the example. To send a value of the coil or register set the value to telegram.au16reg[0]. For the Modbus message protocol see for example the Wikipedia article.


1

I'm using a mp5w pulse meter, the settings: Baud rate : 9600 Address : 02 Parity : none Stop bit : 1 Modbus memory map table for measurement value /(PV) : Modebus : 31002 Address : 03E9 Size : 5


1

The code you are using is the example provided with the SimpleModbusMaster library found on GitHub: https://github.com/angeloc/simplemodbusng It appears that the SimpleModbusMaster library isn't installed. This can happen if you install a new version of the Arduino IDE. To install this library: Go to the link above and download the zip of the code. ...


1

Your issue is that you define constants, such as timeout, which are widely used in Arduino library as parameter names. After preprocessing your definitions, correct code in "Arduino.h" such as unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); becomes unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long 1000); No wonder ...


1

You need to stop thinking quite so linearly. You are working with asynchronous systems, so your code has to be asynchronous too. Something more like this: #include <SoftwareSerial.h> #define SerialControl 7 #define RS485Tx HIGH #define RS485Rx LOW SoftwareSerial RS485Serial(11, 12); byte SendKWh[] = { 0x01, 0x03, 0x40, 0x34, 0x00, 0x02, 0x90, ...


1

OK. So I never got the reinterpret_cast, thing to work. Went with Majenko's solution. This code goes above Setup // UNION, used to re-jig float union ifloat { uint8_t bytes[4]; float val; }; // END UNION And this is the modified code, with all the comments and bug print statements removed. // MtrV, MtrC, MtrW, MtrKWh //void AddressRegistry_0() result =...


1

You need to convert the format by overlaying one type on top of the other, rather than casting from one type to another. 1000 as an integer cast to a floating point value is still 1000. You have an example of how it can be done in comments: //float y = *(float*)&x; However this method is called type punning and is frowned upon (there are compiler ...


1

so i edited code your as below #define mySerial Serial1 byte test_data[8] = {0x01,0x03,0x00,0x64,0x00,0x02,0x85,0xD4}; int data_count = 5; void setup() { mySerial.begin(9600); Serial.begin(9600); delay(1000); } int count = 0; void loop() { if(count%10 == 0) { Serial.println(); send_data(); } count++; while(mySerial.available()>...


1

@Paul, thanks for your suggestion. I want to go forward with TCP/IP. I have now setup a ESP8266 Modul. The ESP Modul is setup as a Server. The Server on the ESP Modul is up and running. I'm also able to connect to the ESP-server with "Hercules", a Terminal Tool. All the example I found were establishing communicating with Browser and HTML. I have ...


1

I have made a simple DALI controller with Arduino Nano. Maybe it will be useful for you. Look here: Simple DALI Controller


1

You could also take a look at this github project: https://github.com/ukos-git/arduino-eurotherm2416 It is specifically designed for the purpose you ask for. It basically includes Module named Temperature and a possibility to set or read it: Temperature.set(100) t = Temperature.getTemperature() Look at https://github.com/ukos-git/arduino-eurotherm2416/...


1

Modbus TCP simply put is a Modbus packet wrapped in a TCP packet. There is no 'additional layer of Modbus' added on top. If we look at the osi model pictured below you can see there is only one Modbus application layer (i.e modbus slave/server) Essentially if the wifi->RS485 gateway strips the payload from the TCP packets and simply spits it out the ...


1

Before you decided to switch platforms, take the time to figure out what your resource usage is. After compiling you'll get a report of the amount of memory you're consuming, check that first. After that, it would be helpful if you could describe more clearly what you're seeing when the code fails.


1

It looks like the problem may be initialisation order. In C/C++, global variables/objects are usually initialised in the order they are declared, and before any global functions run. In your case, this means ID_Check() gets called before array is populated, and before setup() runs. It looks like you need to make sure everything else is setup before your ...


Only top voted, non community-wiki answers of a minimum length are eligible