NodeManager on STM32F103C8 - RS485 Gateway + INA219 + OLED



  • Hi all,
    two monts ago I've created simple RS485 gateway (with NodeManager) based on STM32F103C8. It's working very stable (ok right now I'm using only two nodes 🙂 - for test reason) and now I've created 2-nd version with INA219 and OLED SH1106.
    2_1561967420588_photo5821056587899449907.jpg 1_1561967420588_photo5821056587899449906.jpg 0_1561967420588_photo5821056587899449905.jpg
    The reason is that I'd like to make something like PoE (my RS485 are connected over CAT7 cable with 2 pairs as power line 12V for nodes) and my RS485-gateway should send to Domoticz status of voltage, summary current and power consumption of my 485-nodes. Because I'd like to use display in vertical (2xDIN case) need to use U8g2lib.h library. It's working ok with constant text but how I can read out vales of NodeManager variable eg.

    float voltage = ((ina219*)nodeManager.getSensor(0))->getValueFloat();
    

    General my question is how can I, in main loop, get value from NodeManager sensors?
    Part of my code - compile error (because of variable)

      // call NodeManager before routine
      nodeManager.before();
    
      u8g2.begin();
    
       u8g2.firstPage();
       do {
         u8g2.setFont(u8g2_font_helvR10_tf);
         u8g2.drawStr(3,15,"Voltage");
         u8g2.drawStr(3,45,"Current");
         u8g2.drawStr(3,75,"Power");
       } while ( u8g2.nextPage() );
      
      delay(5000);
    
      u8g2.clear();
     
       u8g2.firstPage();
        do {
         u8g2.drawStr(1, 32, "START");
       } while ( u8g2.nextPage() );
    
    }
    
    // loop
    void loop() {
    //  digitalWrite(MY_DEFAULT_ERR_LED_PIN, state);
    
    while (transportCheckUplink() == false){
    
      u8g2.firstPage();
      do {
        u8g2.setFont(u8g2_font_helvR14_tf); // 14 px height
        u8g2.drawStr(3, 32, "Disconnected!");
        } while ( u8g2.nextPage() );
     }
      
      // call NodeManager loop routine
      nodeManager.loop();
      
      int sensorIna219_Id = nodeManager.registerSensor(ina219);
      float voltage = ((ina219*)nodeManager.getSensor(0))->getValueFloat();
      float current = ((ina219*)nodeManager.getSensor(1))->getValueFloat();
      float power = ((ina219*)nodeManager.getSensor(2))->getValueFloat();  
      
      u8g2.firstPage();
      do {
         u8g2.setFont(u8g2_font_helvR10_tf);
         u8g2.drawStr(3,15,"Voltage");
         u8g2.drawStr(3,45,"Current");
         u8g2.drawStr(3,75,"Power");  
       
      u8g2.setFont(u8g2_font_fub30_tn);
      u8g2.setCursor(3, 35);
      u8g2.print(voltage);
      u8g2.setCursor(3, 70);
      u8g2.print(current);
      u8g2.setCursor(3, 100);
      u8g2.print(power)
     } while ( u8g2.nextPage() );
      
    }
    

    I know it's little be chaotic - hope not problem to understand 🙂

    B.R.
    Adam

    P.S.
    my ArduinoIDE 1.8.9, MySensors 2.3.1 and NodeManager 1.9 dev


  • Contest Winner

    @adampr1 sorry for reading this thread only now with so much delay 😕 Nice project btw! Which compilation error are you receiving from Nodemanager? I also wonder if you can leverage Nodemanager's hooks capabilities to interact with it in a more clean way. Thanks!


Log in to reply
 

Suggested Topics

  • 2
  • 1
  • 2
  • 1
  • 2
  • 2

2
Online

11.4k
Users

11.1k
Topics

112.7k
Posts