Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
A

adampr1

@adampr1
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • NodeManager on STM32F103C8 - RS485 Gateway + INA219 + OLED
    A adampr1

    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

    NodeManager

  • compile NodeManager for STM32F103C8 but I get error:
    A adampr1

    First compilation error problem solved - maple library (STM32duino) use keyword "Timer" and that provide conflict with "Timer" from NodeManager.
    I just changed ALL "Timer" and "timer" to "Tajmer" and "tajmer" (polish speel of "timer" :slightly_smiling_face: ) in NodeManager files - (also Timer.h and Timer.ccp to Tajmer.h and Tajmer.ccp)

    Second problem is with analog reference for ADC converter. In STM32 we have no choice to select external or internal Vref and DEFAULT in Node.h (NodeManager) need to be modified:

    184	uint8_t _analog_reference = DEFAULT;
    

    to

    184 #if defined(ARDUINO_ARCH_STM32F1)
    185	uint8_t _analog_reference = -1;
    186 #else
    187	uint8_t _analog_reference = DEFAULT;
    188 #endif
    

    and in the file SensorAnalogInput.h we need to modify:

    33   int _range_max = 1024;
    

    to

    33   #if defined(ARDUINO_ARCH_STM32F1)
    34	  int _range_max = 4096;
    35   #else
    36	  int _range_max = 1024;
    37   #endif
    

    ADC in STM32 is 12bit with range 0-4096.

    Another thing is that presence of gateway need to by delayed because of USB reset and presence to controller. Without delay, controller (in my situation Domoticz on RaspberryPi) need few seconds to manage "virtual maple com port" on USB, gateway presence message from STM32 is already sent but not received by Domoticz. Simple fixed by uncomment (and modified from 5000 to 2000) :

    define MY_TRANSPORT_WAIT_READY_MS  2000
    

    But still problem when using sensors with interrupts eg. SensorDoor, SensorMotion, SensorInterrupt - also compilation problem with STM32 because of different interrupts constructions as by AVR - need to be solved.

    best regards -
    Adam

    PS. I'm not programmer - more CTRL-C CTRL-V :)
    Please feel free to correct and modify.

    why bluepile -

    1. cheap,
    2. USB on board - very simple programming over STM32duino bootloader - hardware serial port,
    3. second hardware serial port for RS485
    4. many pins with 5V compatibility.
    NodeManager

  • compile NodeManager for STM32F103C8 but I get error:
    A adampr1

    Hello, please help me,
    I need to compile NodeManager for STM32F103C8 but I get error:

    In file included from C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\libraries\MySensors_NodeManager1.9/MySensors_NodeManager.h:91:0,
    
                     from C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\MyS_NM_GW_STM32F103_RS485-test\MyS_NM_GW_STM32F103_RS485-test.ino:177:
    
    C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\libraries\MySensors_NodeManager1.9/nodemanager/Timer.cpp: In member function 'bool Timer::isOver()':
    
    C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\libraries\MySensors_NodeManager1.9/nodemanager/Timer.cpp:82:15: error: 'DO_NOT_REPORT' was not declared in this scope
    
      if (_mode == DO_NOT_REPORT || _mode == NOT_CONFIGURED) return false;
    
                   ^
    
    C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\libraries\MySensors_NodeManager1.9/nodemanager/Timer.cpp:82:41: error: 'NOT_CONFIGURED' was not declared in this scope
    
      if (_mode == DO_NOT_REPORT || _mode == NOT_CONFIGURED) return false;
    
                                             ^
    
    C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\libraries\MySensors_NodeManager1.9/nodemanager/Timer.cpp:84:15: error: 'IMMEDIATELY' was not declared in this scope
    
      if (_mode == IMMEDIATELY) return true;
    
                   ^
    
    C:\Users\adampr\Documents\arduino-1.8.8\Portable\sketchbook\libraries\MySensors_NodeManager1.9/nodemanager/Timer.cpp:111:15: error: 'TIME_INTERVAL' was not declared in this scope
    
      if (_mode == TIME_INTERVAL) {
    
                   ^ 
    

    This same code compiled for ArduinoNano make no problem and also standard Sketch from MySensors examples (GatewaySerialRS485) compiled for STM32F103C8 work perfect. Only when I compile NodeManager for STM32F103C8 I got that error.
    Many other sketch compiled for Arduino Uno, Pro Mini with RS485, NRF24 and RFM69, RFM95 with NodeManager are compiled with no errors.

    My Arduino IDE 1.8.8
    My NodeManager 1.9

    Best regards

    Adam.

    NodeManager
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular