Eastron SDM630 with NodeMCU - compile problem


Im trying to compile this project but its probably a bit above my level of knowlage :confused:

Link to where I found this code and some explanation of what its for GitHub - peninquen/Modbus-Energy-Monitor-Arduino: A class to collect data from a energy monitor that uses modbus protocol.

If anyone would like to take a look at why this is not compiling I would be most thankful :slight_smile:

I get these faults:

C:\Users\Gerles\AppData\Local\Temp\buildbf57b7c4436269c9ccbd3be80722fdec.tmp\sketch\ModbusSensor.cpp: In member function 'void modbusMaster::begin(uint16_t, uint8_t)':

ModbusSensor.cpp:119: error: invalid conversion from 'uint8_t {aka unsigned char}' to 'SerialConfig' [-fpermissive]

(*_hwSerial).begin(baudrate, byteFormat);


In file included from C:\Users\Gerles\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Arduino.h:246:0,

from C:\Users\Gerles\AppData\Local\Temp\buildbf57b7c4436269c9ccbd3be80722fdec.tmp\sketch\ModbusSensor.h:16,

from C:\Users\Gerles\AppData\Local\Temp\buildbf57b7c4436269c9ccbd3be80722fdec.tmp\sketch\ModbusSensor.cpp:25:

C:\Users\Gerles\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/HardwareSerial.h:77:10: error: initializing argument 2 of 'void HardwareSerial::begin(long unsigned int, SerialConfig)' [-fpermissive]

void begin(unsigned long baud, SerialConfig config)


C:\Users\Gerles\AppData\Local\Temp\buildbf57b7c4436269c9ccbd3be80722fdec.tmp\sketch\ModbusSensor.cpp: In member function 'boolean modbusMaster::available()':

ModbusSensor.cpp:168: error: 'SERIAL_TX_BUFFER_SIZE' was not declared in this scope

if ((*_hwSerial).availableForWrite() < SERIAL_TX_BUFFER_SIZE - 1) { //TX buffer not empty


Using library ESP8266WiFi at version 1.0 in folder: C:\Users\Gerles\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\ESP8266WiFi
Using library pubsubclient-master at version 2.6 in folder: C:\Users\Gerles\Documents\Arduino\libraries\pubsubclient-master
exit status 1
invalid conversion from 'uint8_t {aka unsigned char}' to 'SerialConfig' [-fpermissive]

esp8266modbusEnergyMonitor.ino (3.36 KB)

ModbusSensor.cpp (15.4 KB)

ModbusSensor.h (6.15 KB)

SDMdefines.h (2.29 KB)

To make code easier to read....


  ModbusEnergyMonitor example
  An example to collect data from a Modbus energy monitor using ModbusSensor class
  to datalogger, include a RTC DS3231 and a SD card
  version 0.5 BETA 4/01/2016

  Author: Jaime García  @peninquen
  License: Apache License Version 2.0.


#include <ESP8266WiFi.h>      //ESP library from http://github.com/esp8266/Arduino
#include <PubSubClient.h>     // MQTT library from https://github.com/knolleary/pubsubclient
#include "ModbusSensor.h"
#include "SDMdefines.h"

// Update these with values suitable for your network.

const char* ssid = "........";
const char* password = "........";
const char* mqtt_server = "broker.mqtt-dashboard.com";

WiFiClient espClient;
PubSubClient client(espClient);
uint8_t msg[50];

#define MB_SERIAL_PORT &Serial   // ESP8266 has two serial ports, but Serial1 only Tx
// Serial.swap() change pins to Tx and Rx

#define MB_BAUDRATE       2400          // b 2400
#define MB_BYTEFORMAT     SERIAL_8N2    // Prty n
#define TxEnablePin       2

#define ID_1  1                       // id 001  modbus id of the energy monitor
#define REFRESH_INTERVAL  5000        // refresh time, 5 SECONDS

struct three_phase {
  float line3, line2, line1;
} voltage, current, power;

float energy = 0.0;

// global variables to poll, process and send values

//modbusSensor(uint8_t id, uint8_t fc, uint16_t adr, uint8_t hold, uint8_t sizeofValue)
modbusSensor volt(ID_1, VOLTAGE, CHANGE_TO_ZERO, sizeof(three_phase));
modbusSensor curr(ID_1, CURRENT, CHANGE_TO_ZERO, sizeof(three_phase));
modbusSensor pwr(ID_1, POWER, CHANGE_TO_ZERO, sizeof(three_phase));
//modbusSensor(uint8_t uint16_t adr, uint8_t hold)
modbusSensor enrg(ID_1, IAENERGY, HOLD_VALUE);

void setup() {
  Serial.println("time(s),Volt1(V), Volt2(V), Volt3(V), Curr1(A) Curr2(A), Curr3(A), Power1(W), Power2(W), Power3(W), Energy(Kwh)");

void loop() {

  if (MBSerial.available()) {
    energy = enrg.read();

    Serial.print(millis() / 1000);
    Serial.print(voltage.line1, 1);
    Serial.print(voltage.line2, 1);
    Serial.print(voltage.line3, 1);
    Serial.print(current.line1, 2);
    Serial.print(current.line2, 2);
    Serial.print(current.line3, 2);
    Serial.print(power.line1, 2);
    Serial.print(power.line2, 2);
    Serial.print(power.line3, 2);
    Serial.println(energy, 2);

void setup_wifi() {
  // We start by connecting to a WiFi network
  Serial.print("Connecting to ");

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("WiFi connected");
  Serial.println("IP address: ");

Hello! Do you found a solution to this problem?