Giter VIP home page Giter VIP logo

rak3172_canopus's Issues

Exemple Modbus master doesn't working

Hello sir,

I am experiencing an issue with the Canopus version 1 board. The Modbus Master example code available on GitHub is not working, and my own code that uses the frames is also not working.

this is your exemple code :

#include "Canopus_Modbus.h"
ModbusMaster node;
#include <Rak3172_Canopus.h>
#define V_RS485 PB12

#define V1
uint8_t result;
void setup()
{
  pinMode(V_RS485, PWR_ON);
  pinMode(PB2, OUTPUT);
  Serial.begin(115200);
  Serial.print("\r\n*****************RAK3172_CANOPUS*******************");
  Serial_Canopus.begin(9600, SERIAL_8N1);
}
void loop()
{
  //***************READ node 1**************************
  node.begin(1, Serial_Canopus); //slave ID node
  Serial.printf("");
  Serial.printf("\r\n\n\nExample read modbus RTU for RAK3172_Canopus board");

  result = node.readHoldingRegisters(0, 1);//Read 40000 to 40009
  delay(10);
  if (result == node.ku8MBSuccess) //Read success
  {
    for (uint8_t i = 0; i < 10; i ++ )
    {
      Serial.printf("\r\nValue 4000%d: %d", i, node.getResponseBuffer(i));
    }
  }
  else Serial.print("Read Fail node 1"); //read fail
  digitalWrite(PB2, !digitalRead(PB2)); //blink led
  delay(500);
}

And this is my code, using frames (when i run this code i see tx led blinking but with a dim light):

#include <Rak3172_Canopus.h>  // Include the Rak3172_Canopus library header file.
#include "Canopus_Modbus.h"
#include "Rak3172_Canopus.h"
#define V1
#define RS485_VCC PB12

byte Temp[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0a};
byte responseBuffer[50]; // Taille du tampon de réponse
float Value, Val1;

void setup() {
  Serial.begin(115200);
  Serial_Canopus.begin(9600, SERIAL_8N1);
  pinMode(RS485_VCC, OUTPUT);
  digitalWrite(RS485_VCC, PWR_ON);  //On power Vrs485
  //pinMode(V_SS5, PWR_ON);
}

float temp(){
//  node.begin(1, Serial_Canopus); //slave ID node
  RS485_Tranmit;
  Serial_Canopus.write(Temp, sizeof(Temp));// Envoyer la requête au capteur

  // Lire la réponse
  RS485_Receive;
  delay(200);
  int responseLength = Serial_Canopus.available();
  if (responseLength > 0) {
    for (int i = 0; i < responseLength; i++) {
      responseBuffer[i] = Serial_Canopus.read();
    }
      Value = (responseBuffer[3] << 8) | responseBuffer[4];
      Value = Value/100;
      Serial.print("temperature : ");
      Serial.print(Value);
      Serial.println(" °C");
  } else {
    Serial.println("Aucune réponse reçue.");
  }

  return Value;
}

void loop() {

  Serial.println("________________________");
  temp();
  delay(1000);

}

notice 1 : i use a Seeed studio EC sensor (RS485, 12V) i use a externel alimentation with this sensor and the seem gnd for all the system.
notice 2 : i have also an conveter usb to RS485 for test.

[Example Modbus Slave doesn't working]

Hi a Nam,
I tested your example code Rak3172 working as Modbus slave but it's doesn't work,
I am using your example and Modbus Poll working as master for reading data from Rak_v1
I don't know exactly where is the problem.
I tested some simple cases and wiring or hardware is not problem.

  1. I had tested simple transmit and receive in this UART1 of Rak3172 and its work fine.
  2. I had tested your example code with Esp32 (change the UART(Serial 1 -> Serial 2)) and it's working well,

But when I am using this code for Rak3172 and it can't run.
Any suggest for me, Did I forget anything?
Thanks.

Rom Overflow

Hello, I like the card design, congratulations. I used your library it works fine. But I have a question. When I import high size libraries, I get "ROM overflowed" error. Have you encountered an error similar to this? When I run even the simplest example codes, it appears to be 61% full from the ROM. Thanks in advance for your answer.

Good luck.

Error: Detect baudrate fail, can not get the baudrate on Arduino IDE

 Hi, NamNamIoT !
    I’m workig with a RAK3172_CANOPUS  using  Arduino IDE. 
    It compiles ok, then uploads it to my board but fails. as shown below:
    ![Detect baudrate fail](https://github.com/NamNamIoT/RAK3172_CANOPUS/assets/163369668/6141faac-5e59-4990-88fa- 
    c59bbc56dd25)
    Previously, I successfully loaded the code with STM32CubeProgrammer and switched to loading with Arduino IDE but encountered 
    this error.
   Boards that have never been loaded with STM32CubeProgrammer will still operate normally.
   Hope to receive help from you !!! 
   Thanks.

[Fixed:data loss when value in modbus register > 255]

Hi a Nam,
I tested rak3172_canopus and using Canopus_modbus.h lib with rak_v1, when reading Modbus register when value > 255 (1 byte) i lost data.
I think problem in https://github.com/NamNamIoT/RAK3172_CANOPUS/blob/main/examples/RAK3172_ModbusRTU_Master/Canopus_Modbus.cpp
line 697, 708, 723.
Try this code below to fix it

  1. Line 697: _u16ResponseBuffer[i] = (u8ModbusADU[2 * i + 4] << 8) | u8ModbusADU[2 * i + 3];
  2. Line 708: _u16ResponseBuffer[i] = (0 << 8) | u8ModbusADU[2 * i + 3];
  3. Line 723: _u16ResponseBuffer[i] = (u8ModbusADU[2 * i + 3] << 8) | u8ModbusADU[2 * i + 4];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.