STM32?


  • Mod

    @tekka do you think stm32 is sufficiently stable running mysensors or should I stick to the "old" pro mini for battery powered sensors? (Also considering the ota updates support)



  • @gohan There is no support yet for sleep, so battery powered out of the box will not work. I've been testing custom sleep function (STOP mode, external interrupts) and so far was able to run a blue pill + RFM69 with MySensors between 0.01 and 0.20 mA (inconsistent results, not sure yet why). A sketch with just blue pill ran consistently at 0.01 mA. Unfortunately my multimeter does not allow more accurate measurements.


  • Admin

    @gohan As @freynder pointed out, sleeping and low power modes are currently not implemented - if you do not need the higher speed & additional features that come along with the stm32 I'd stick (for the moment) to at328p for battery-powered sensors.


  • Plugin Developer

    I thought I'd just share a complete sketch. This is a sketch for a Co2 and dust sensor using the STM32 blue pill.

    /*
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     *  DESCRIPTION
     *
     *  MH-Z19 CO2 sensor
     *  Uses infrared to measure Co2' absorbtion spectrum. Talks to the board over over serial 9600 on Serial1.
     *  
     *  PMS-7003
     *  This sensor uses a frickin' laser to measure lots of different fine dust levels, between 0.3 and 10 microns. 
     *  It can output the raw particle count for a certain particle size and up. Or it can give the official um/mg 
     *  measurement. Talks to the board over over serial 9600 on Serial2.
     *  
     *  
     *  NRF24 pins: b0 a7 a6 a5 a4 (and 3.3v power)
     *  MH-Z19 pins: a9 a1 (and 5v power)
     *  PMS7001 pins: a2 a3 (and 5v power)
     */
    
    
    
    /* 
    //------------------------------------------------------------------------------
    //  PM sensor PMS7003 (fine dust)
    
    
    
    
    Copyright 2017 Scapeler
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.    
    
    */
    
    //------------------------------------------------------------------------------
    
    // if you uncomment this, you can get test and debug updates about the sensor' wireless connection by using the serial monitor tool.
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24                            // A 2.4Ghz transmitter and receiver, often used with MySensors.
    #define MY_RF24_PA_LEVEL RF24_PA_MIN              // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
    // #define MY_RADIO_RFM69                         // 433Mhz transmitter and reveiver.
    
    // This is needed if you use an STM32 board:
    #define MY_RF24_CE_PIN PB0
    
    // Choose if you want this sensor to also be a repeater.
    // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
    
    // Are you using this sensor on battery power?
    // #define BATTERY_POWERED                        // Just remove the two slashes at the beginning of this line if your node is battery powered. It will then go into deep sleep as much as possible. While it's sleeping it can't work as a repeater!
    
    #include <SPI.h>
    #include <MySensors.h>
    
    // Co2 sensor
    #define CHILD_ID_CO2 0 // The Co2 sensor
    
    // Dust sensor
    #define CHILD_ID_DUST_PM03 1
    //#define CHILD_ID_DUST_PM05 2
    #define CHILD_ID_DUST_PM10 2 
    #define CHILD_ID_DUST_PM25 3
    #define CHILD_ID_DUST_PM50 4
    #define CHILD_ID_DUST_PM100 5
    
    // bool receivedConfig = false;                      // This is not used in the code, but perhaps MySensors requires this?
    // bool metric = true;                               // Variable that stores if the sensor will output the temperature in Fahrenheit of Celsius. The gateway sends this preference to the node.
    
    
    // Mysensors settings
    
    // Co2
    MyMessage msgCo2(CHILD_ID_CO2, V_LEVEL);
    MyMessage msgCo2b(CHILD_ID_CO2, V_UNIT_PREFIX);
    
    // Dust. If you want to get all the raw data, the commented lines are useful.
    MyMessage msgDust03(CHILD_ID_DUST_PM03, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
    MyMessage msgDust03b(CHILD_ID_DUST_PM03, V_UNIT_PREFIX);
    //MyMessage msgDust05(CHILD_ID_DUST_PM05, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
    //MyMessage msgDust05b(CHILD_ID_DUST_PM05, V_UNIT_PREFIX);
    MyMessage msgDust10(CHILD_ID_DUST_PM10, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
    MyMessage msgDust10b(CHILD_ID_DUST_PM10, V_UNIT_PREFIX);
    MyMessage msgDust25(CHILD_ID_DUST_PM25, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
    MyMessage msgDust25b(CHILD_ID_DUST_PM25, V_UNIT_PREFIX);
    MyMessage msgDust50(CHILD_ID_DUST_PM50, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
    MyMessage msgDust50b(CHILD_ID_DUST_PM50, V_UNIT_PREFIX);
    MyMessage msgDust100(CHILD_ID_DUST_PM100, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
    MyMessage msgDust100b(CHILD_ID_DUST_PM100, V_UNIT_PREFIX);
    
    
    
    // These defines and variables can be changed:
    
    // co2
    unsigned long co2MeasurementInterval = 30000;        // Time to wait between reads (in milliseconds).
    //float co2threshold = 0.1;   // How big a measurement difference has to be before an update is sent. Makes the sensor less precise, but also less jittery, and can save battery.
    
    // dust
    // Are you using this sensor on battery power?
    // #define BATTERY_POWERED                        // Just remove the two slashes at the beginning of this line if your node is battery powered. It will then go into deep sleep as much as possible. While it's sleeping it can't work as a repeater!
    
    int dustSlowDown = 20; // The dust sensor is internally checked approximately every 700 or 800 milliseconds. Once in how many loops should it send the data?
    
    unsigned long dustMeasurementInterval = 700;  // This is a fickle thing. Changing it can give more time-outs.
    
    // PROBABLE BEST NOT TO CHANGE THESE VARIABLES
    // PMS7003 sensor - input byte variables
    int inputHigh = 0;
    int inputLow = 0;
    // variable to caclulate checksum input variables
    uint16_t inputChecksum = 0;
    // sensor variables
    uint16_t concPM1_0_CF1;
    uint16_t concPM2_5_CF1;
    uint16_t concPM10_0_CF1;
    uint16_t concPM1_0_amb;
    uint16_t concPM2_5_amb;
    uint16_t concPM10_0_amb;
    uint16_t rawGt0_3um;
    uint16_t rawGt0_5um;
    uint16_t rawGt1_0um;
    uint16_t rawGt2_5um;
    uint16_t rawGt5_0um;
    uint16_t rawGt10_0um;
    uint8_t  version;
    uint8_t  errorCode;
    uint16_t checksum;
    int dustSlowDownCounter = 0;
    
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("AIQ Sensor CO2 MH-Z19 and Dust PMS-7003", "1.0");
    
      // Register all sensors to gateway (they will be created as child devices):
    
      // co2
      present(CHILD_ID_CO2, S_AIR_QUALITY);
      send(msgCo2b.set("ppm"));
    
      // dust
      //present(CHILD_ID_DUST_PM10, S_DUST);
      //send(msgPM10.set("ppm"));
      present(CHILD_ID_DUST_PM03, S_DUST);
      send(msgDust03b.set("um/m3"));    
      //present(CHILD_ID_DUST_PM05, S_DUST);
      //send(msgDust05b.set("pp/dl"));    
      present(CHILD_ID_DUST_PM10, S_DUST);
      send(msgDust10b.set("um/m3"));  
      present(CHILD_ID_DUST_PM25, S_DUST);
      send(msgDust25b.set("um/m3")); 
      present(CHILD_ID_DUST_PM100, S_DUST);
      send(msgDust100b.set("um/m3"));  
      present(CHILD_ID_DUST_PM50, S_DUST);
      send(msgDust50b.set("pp/dl"));   
    }
    
    
    void setup() {
         delay(1000);
       Serial.begin(115200);
         delay(1000);
       Serial1.begin(9600);       //C02 sensor read serial
           while (!Serial1) {
        }
    
        Serial2.begin(9600); // PMS7003 dust sensor read serial
          while (!Serial2) {
        }
            
       delay(2000);
       while (Serial1.read()!=-1) {};  //clear Co2 buffer.
       Serial.println("hello world, I am a sensor.");
    }
    
    
    void loop() {
    
       // You should not change these variables:
       static unsigned long previousCo2Millis = 0;       // Used to remember the time of the last temperature measurement.
       static unsigned long previousDustMillis = 0;       // Used to remember the time of the last temperature measurement.
    
       unsigned long currentMillis = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
    
      // Co2 loop
      if (currentMillis - previousCo2Millis >= co2MeasurementInterval) {
        Serial.println("");
        Serial.println("CO2 - Sending data request to sensor.");
        previousCo2Millis = currentMillis;
    
        long co2ppm = readCO2();
    
        Serial.println("Co2 - PPM = " + String(co2ppm));
        send(msgCo2.set((long)ceil(co2ppm))); 
        Serial.print("Co2 - zzzzZZZZzzzzZZZZzzzz\n");
      }
    
      // The dust sensor sends its data continuously, so let's get that data.
      int dustSensorOutput = pms7003ReadData();
    }
    
    
    // MAIN FUNCTION THAT GETS THE Co2 DATA
    int readCO2()
    {
      while (Serial1.read()!=-1) {};  //clear buffer  
    
      char response[9]; // for answer
      byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
      
      // command to ask for data
      Serial1.write(cmd, 9); //request PPM CO2 
    
      Serial1.readBytes(response, 9);
    
        Serial.print(response[0], HEX);   
        Serial.print(" - ");   
        Serial.print(response[1], HEX);   
        Serial.print(" - ");    
        Serial.print(response[2], HEX);   
        Serial.print(" - ");          
        Serial.print(response[3], HEX);   
        Serial.print(" - ");          
        Serial.print(response[4], HEX);   
        Serial.print(" - ");          
        Serial.print(response[5], HEX);   
        Serial.print(" - ");        
        Serial.print(response[6], HEX);   
        Serial.print(" - ");   
        Serial.print(response[7], HEX);   
        Serial.print(" - ");      
        Serial.print(response[8], HEX); 
        Serial.println(" - END");  
    
      if (response[0] != 0xFF)
      {
        Serial.println("Wrong starting byte from co2 sensor!");
        return -1;
      }
    
      if (response[1] != 0x86)
      {
        Serial.println("Wrong command from co2 sensor!");
        return -1;
      }
    
      int responseHigh = (int) response[2];
      int responseLow = (int) response[3];
      int ppm = (256 * responseHigh) + responseLow;
      
      return ppm;
    }
    
    
    // MAIN FUNCTION FOR THE DUST SENSOR, Thanks to Scapeler.nl
    int pms7003ReadData() {
        
      // while (Serial2.read()!=-1) {};  //clear buffer
    
      if (Serial2.available() < 32) {
        if (Serial2.available() == 0) {
          delay(150);
          return -1;
        };
        if (Serial2.available() > 16) {
          delay(10);
          return -1;
        };
        if (Serial2.available() > 0) {
          delay(30);
          return -1;
        };
        delay(100);
        return -1;
      }
      if (Serial2.read() != 0x42) return -1;
      if (Serial2.read() != 0x4D) return -1;
    
      inputChecksum = 0x42 + 0x4D;
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      if (inputHigh != 0x00) return -1; 
      if (inputLow != 0x1c) return -1;    
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      concPM1_0_CF1 = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      concPM2_5_CF1 = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      concPM10_0_CF1 = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      concPM1_0_amb = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      concPM2_5_amb = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      concPM10_0_amb = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      rawGt0_3um = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      rawGt0_5um = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      rawGt1_0um = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      rawGt2_5um = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      rawGt5_0um = inputLow+(inputHigh<<8);
    
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      inputChecksum += inputHigh + inputLow;
      rawGt10_0um = inputLow+(inputHigh<<8);
    
      inputLow = Serial2.read();
      inputChecksum += inputLow;
      version = inputLow;
    
      inputLow = Serial2.read();
      inputChecksum += inputLow;
      errorCode = inputLow;
    
      Serial.print("PMS7003;"); 
    
      // The measurement recalculated to micrograms per cubic meter, a common standard.
      Serial.print(concPM1_0_CF1);
      Serial.print(';'); 
      Serial.print(concPM2_5_CF1);
      Serial.print(';'); 
      Serial.print(concPM10_0_CF1);
      Serial.print(';'); 
    
      // The measurement recalculated to micrograms per cubic meter, a common standard. Not quite sure what the difference is..
      Serial.print(concPM1_0_amb);
      Serial.print(';'); 
      Serial.print(concPM2_5_amb);
      Serial.print(';');     
      Serial.print(concPM10_0_amb);
      Serial.print(';');     
    
      // this is the 'raw' data that the sensor gathers internally, before it calculates the above values.
      Serial.print(rawGt0_3um); // This indicates total number or particles in 0.1 liter of air that have a diameter above 0.3um. This will be the biggest number, as it measures the most particles. But it's very imprecise: 50% accuracy..
      Serial.print(';');
      Serial.print(rawGt0_5um); // This indicates the total number or particles in 0.1 liter of air that have a diameter above 0.5um (so it will be a smaller count than the line above)
      Serial.print(';'); 
      Serial.print(rawGt1_0um); // This indicates the total number or particles in 0.1 liter of air that have a diameter above 1 micron. And so on..
      Serial.print(';'); 
      Serial.print(rawGt2_5um);
      Serial.print(';'); 
      Serial.print(rawGt5_0um); // Acording to the datashet, at this point the accuracy has reached at 98%.
      Serial.print(';'); 
      Serial.print(rawGt10_0um);
      Serial.print(';'); 
      Serial.print(version);
      Serial.print(';'); 
      Serial.print(errorCode);
      Serial.println("---");
      
      inputHigh = Serial2.read();
      inputLow = Serial2.read();
      checksum = inputLow+(inputHigh<<8);
      if (checksum != inputChecksum) {
        Serial.print(';'); 
        Serial.print(checksum); 
        Serial.print(';'); 
        Serial.print(inputChecksum); 
      }
      //Serial.print('\n');
    
      // let's send a message with the results
      dustSlowDownCounter = dustSlowDownCounter + 1;
      if(dustSlowDownCounter > dustSlowDown){
        
        /*  MEASUREMENT  */
        if(rawGt1_0um > 0){
          Serial.println(" Dust1_0 = " + String(concPM1_0_CF1));
          send(msgDust10.set(concPM1_0_CF1,1));
        }         
        if(rawGt2_5um > 0){
          Serial.println(" Dust1_0 = " + String(concPM2_5_CF1));
          send(msgDust25.set(concPM2_5_CF1,1));
        }     
        if(rawGt10_0um > 0){
          Serial.println(" Dust1_0 = " + String(concPM10_0_CF1));
          send(msgDust100.set(concPM10_0_CF1,1));
        }     
    
        /*  RAW DATA  */            
        
        if(rawGt0_3um > 0){
          Serial.println(" Dust03 = " + String(rawGt0_3um));
          send(msgDust03.set(rawGt0_3um,1));
        }/*
        if(rawGt0_5um > 0){
          Serial.println(" Dust05 = " + String(rawGt0_5um));
          send(msgDust05.set(rawGt0_5um,1));
        }
        if(rawGt1_0um > 0){
          Serial.println(" Dust10 = " + String(rawGt1_0um));
          send(msgDust10.set(rawGt1_0um,1));
        }
        if(rawGt2_5um > 0){
          Serial.println(" Dust25 = " + String(rawGt2_5um));
          send(msgDust25.set(rawGt2_5um,1));
        }
        */
        if(rawGt5_0um > 0){
          Serial.println(" Dust50 = " + String(rawGt5_0um));
          send(msgDust50.set(rawGt5_0um,1));
        }      
        /*
        if(rawGt10_0um > 0){
          Serial.println(" Dust100 = " + String(rawGt10_0um));
          send(msgDust100.set(rawGt10_0um,1));
        }   
        */
    
        dustSlowDownCounter = 0;
      } // End of sensing message.
    
      delay(700);  // Data will come between 200 and 800 miliseconds. If you set this be be higher than 700 you will get checksum errors.
        
      return concPM2_5_CF1;
    }
    
    
    
    

  • Mod

    @alowhum do you mind posting the links to the sensors you used? I was planning to make a similar one



  • I just finished my first low power test implementation for STM32: a low power dual button sensor using RFM69 and external interrupts. It seems to work very well so far. My multimeter shows 0.01 mA sleep current, but I'm not sure how well this can be trusted.

    The sketch can be found here: https://github.com/freynder/LowPowerButtons
    It uses platformio IDE directory structure.

    The modifications to MySensors (not complete/nicely implemented yet) can be found here: https://github.com/freynder/MySensors/tree/stm32f1_sleep
    I hope to find time in the near future to clean it up + implement support for interrupts and contribute it to the project if not already available by then.


  • Plugin Developer

    @freynder awesome! I hope you find the time.
    @gohan: just search for the sensors on Aliexpress, and then select "sort by: orders" to get get the most popular shops.



  • Nice work guys! STM32 is good for bigger projects, even consumption looks fine.
    How is solved missing on-chip eeprom?



  • When saying STM32 you have to specify which one you mean. The STM32L0 Series series has 2kB EEPROM on board.



  • BTW: for battery powered nodes the STM32L0 series is the better solution (L means ultra-low-power)!



  • How many STM32L0 boards < €2 are there?


  • Mod

    @Uhrheber more than 60,000 in stock here, but if you want to purchase a complete board you will have to pay more.



  • I said boards, not chips. Chips I can get a dime a dozen.
    And as there aren't any cheap STM32L0 boards now, most people will stay with the blue pill.


  • Mod

    @Uhrheber yep


  • Hardware Contributor

    And neither is there an arduino core available for those chips, they use and m0 core and not m3 like in the F103 versions.



  • @Nca78 The Arduino Zero is also an M0, so this shouldn't be too complicated.
    Peripherals are completely different, though.


  • Hardware Contributor

    @Uhrheber said in STM32?:

    @Nca78 The Arduino Zero is also an M0, so this shouldn't be too complicated.
    Peripherals are completely different, though.

    Yes and NRF51822 is too and the core is based on SAMD core which is from the Zero.
    But it's still a lot of work to adapt it first for Arduino and then add support in MySensors, when an NRF52832 already has a core, support in MySensors and is available at a similar price but with better performance (Cortex M4 with FPU) and includes the radio.
    And now there's an Arduino using nrf52832 (Primo), I'm pretty sure we will "soon" find some nrf52832 boards on AliExpress at a reasonable price.



  • How does the NRF52832 fare, compared to a classical solution using Arduino Nano and nRF24?
    Is it usable for a sleeping node with a (window) switch, or a remote environmental sensor, when it comes to range and power consumption?
    Is the software already stable enough?


  • Hardware Contributor

    @Uhrheber see this thread
    https://forum.mysensors.org/topic/6961/nrf5-bluetooth-action/805

    There's still progress to make but it works, and with DCDC enabled power consumption is much lower than on nrf24.



  • Hi all,
    I successfully compiling and flashing my STM32 blue pill, but don't know where is the Serial output?
    Do you use SWO or physical UART? if UART on which one?

    Thanks a lot for this great work



  • Hi all, Can somebody help me please?

    I add also some STM32 blue pill and try to run mysensors on them.
    I use the devlopment branch. Compilation is OK and I successfully flash it on my board with STLink.
    But I don't see any message/log. I am not sure that the software is runnning.
    How can I debug that?

    thansk


  • Mod

    I guess you are one of the very few using the STM32 at the moment.



  • @ooznerol : it's been a while but I've had some issues with this as well. Here are some pointers that may help you:

    If I remember correctly, it depends on the upload method which may set particular build flags. In my platformio configuration for example, I'm setting the following build flags:
    build_flags = -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER when using the stlink upload method. CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG was necessary to preserve the SWD pins and SERIAL_USB creates a virtual UART for serial output to the USB port. If Serial_USB is not set then the hardware serial is being used. Which one? According to https://github.com/rogerclarkmelbourne/STM32duino-bootloader/issues/8 it depends on the fact that you are using a bootloader or not, so serial1 (PA9/PA10) or serial2 (PA2/PA3).

    Also, if you experience issues with the USB connection, check the pullup resistor on D+ as indicated in http://wiki.stm32duino.com/index.php?title=Blue_Pill .

    I'm not sure what IDE/upload method/board library you are using. In any case, watching the output during upload to find out the build flags may be useful. If that does not help, then pls send me the details of your setup and I will try to test it myself.



  • Hi @freynder , and thanks for your help.

    I use Arduino IDE with stm32duino library to compile and upload . I haven't change the bootloader.
    This setup works without problem on my bluepill ( I had run several example without porblem, specialy to found which uart pin are used by stm32duino).

    I had a STLink connected to my blue pin (JTAG Clk/Data and SWO (and GND of course)).

    I have enable debug option : #define MY_DEBUG and #define MY_DEBUG_VERBOSE_RF24

    Here is the output of my compilation/upload :

    C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\ooznerol\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\ooznerol\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\ooznerol\Documents\Arduino\libraries -fqbn=Arduino_STM32:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=STLinkMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10803 -build-path C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727 -warnings=none -build-cache C:\Users\ooznerol\AppData\Local\Temp\arduino_cache_402979 -prefs=build.warn_data_percentage=75 -verbose C:\Users\ooznerol\Documents\Arduino\STM32Duino_MysensorsLightSensor\STM32Duino_MysensorsLightSensor.ino
    C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\ooznerol\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\ooznerol\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\ooznerol\Documents\Arduino\libraries -fqbn=Arduino_STM32:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=STLinkMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10803 -build-path C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727 -warnings=none -build-cache C:\Users\ooznerol\AppData\Local\Temp\arduino_cache_402979 -prefs=build.warn_data_percentage=75 -verbose C:\Users\ooznerol\Documents\Arduino\STM32Duino_MysensorsLightSensor\STM32Duino_MysensorsLightSensor.ino
    Using board 'genericSTM32F103C' from platform in folder: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1
    Using core 'maple' from platform in folder: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1
    WARNING: Spurious .ci folder in 'MySensors' library
    WARNING: Spurious .mystools folder in 'MySensors' library
    WARNING: Spurious .mystools folder in 'MySensors' library
    Detecting libraries used...
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11  -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include"                                                           "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp" -o "nul"
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11  -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include"                                                           "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "-IC:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp" -o "nul"
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11  -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include"                                                           "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "-IC:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp" -o "nul"
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11  -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include"                                                           "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "-IC:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp" -o "nul"
    Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM\EEPROM.cpp
    Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM\flash_stm32.c
    Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src\SPI.cpp
    Generating function prototypes...
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11  -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include"                                                           "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "-IC:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp" -o "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\preproc\ctags_target_for_gcc_minus_e.cpp"
    "C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\preproc\ctags_target_for_gcc_minus_e.cpp"
    Compiling sketch...
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include"                                                           "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "-IC:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM" "-IC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp" -o "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp.o"
    Compiling libraries...
    Compiling library "MySensors-development"
    Compiling library "EEPROM"
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\libraries\EEPROM\flash_stm32.c.o
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\libraries\EEPROM\EEPROM.cpp.o
    Compiling library "SPI"
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\libraries\SPI\SPI.cpp.o
    Compiling core...
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\start.S.o
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\start_c.c.o
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\syscalls.c.o
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\board.cpp.o
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\boards.cpp.o
    Using previously compiled file: C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\boards_setup.cpp.o
    Using precompiled core
    Linking everything together...
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -Os -Wl,--gc-sections  -mcpu=cortex-m3 "-TC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c/ld/jtag_c8.ld" "-Wl,-Map,C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727/STM32Duino_MysensorsLightSensor.ino.map" "-LC:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c/ld" -o "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727/STM32Duino_MysensorsLightSensor.ino.elf" "-LC:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\sketch\STM32Duino_MysensorsLightSensor.ino.cpp.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\libraries\EEPROM\flash_stm32.c.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\libraries\EEPROM\EEPROM.cpp.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\libraries\SPI\SPI.cpp.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\start.S.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\start_c.c.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\syscalls.c.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\board.cpp.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\boards.cpp.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\core\wirish\boards_setup.cpp.o" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727/..\arduino_cache_402979\core\core_Arduino_STM32_STM32F1_genericSTM32F103C_device_variant_STM32F103C8,upload_method_STLinkMethod,cpu_speed_speed_72mhz,opt_osstd_dd5e5f7edaf4f0539408738d9cfc05e4.a" -Wl,--end-group
    "C:\Users\ooznerol\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary  "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727/STM32Duino_MysensorsLightSensor.ino.elf" "C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727/STM32Duino_MysensorsLightSensor.ino.bin"
    Multiple libraries were found for "MySensors.h"
     Used: C:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development
     Not used: C:\Users\ooznerol\Documents\Arduino\libraries\Mysensors-rfm69_update2
    Using library MySensors-development at version 2.2.0-beta in folder: C:\Users\ooznerol\Documents\Arduino\libraries\MySensors-development 
    Using library EEPROM in folder: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\EEPROM (legacy)
    Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI 
    Sketch uses 46576 bytes (71%) of program storage space. Maximum is 65536 bytes.
    Global variables use 4432 bytes (21%) of dynamic memory, leaving 16048 bytes for local variables. Maximum is 20480 bytes.
    C:\Program Files (x86)\Arduino\hardware\Arduino_STM32/tools/win/stlink_upload.bat COM8 {upload.altID} {upload.usbID} C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727/STM32Duino_MysensorsLightSensor.ino.bin 
    STM32 ST-LINK CLI v2.1.0
    STM32 ST-LINK Command Line Interface
    
    ST-LINK SN : 49FF6E065178505040351687
    ST-LINK Firmware version : V2J28S0
    Connected via SWD.
    SWD Frequency = 1800K.
    Connection mode : Normal.
    Device ID:0x446 
    Device flash Size : 512 Kbytes
    Device family :STM32F302xE/F303xE/F398xx
    
    Loading file...
    Flash Programming:
      File : C:\Users\ooznerol\AppData\Local\Temp\arduino_build_618727\STM32Duino_MysensorsLightSensor.ino.bin
      Address : 0x08000000
    Flash memory programming...
    ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± 0%
     0%ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ 100%
    Flash memory programmed in 2s and 995ms.
    Programming Complete.
    
    MCU Reset.
    
    Application started.
    
    

    thanks for your help



  • Hi @ooznerol ,

    Your output shows build tag SERIAL_USB so I would assume Serial outputs to USB.

    Did you connect the board using USB and try to read output from there? is USB recognized as a serial device? Is the pullup resistor on D+ correct (http://wiki.stm32duino.com/index.php?title=Blue_Pill)?



  • @ooznerol : when you say the examples ran without a problem, do you mean you had serial output from the examples but not from mysensors specifically?



  • HI @freynder ,

    I just realize that when you speak about SERIAL_USB you really speak about.....Serial through USB connector 😀 .
    I believe you speak about Virtual Com Port through USB in ST-LINK.

    So I had change R10 on my blue pill and install maple driver.
    Now I have a Maple Serial COM mounted when I connect my blue pill with the USB connector 😀 .

    And......................TADA.................It is working. I had output on my terminal.

    Thanks again👍



  • Hi it's me again...............
    I have no problem with sensors sketch using RFM69.
    But I have a strange problem with the serial gateway ino.
    If I select the NRF24 radio (#define MY_RADIO_NRF24), I have some debug info on my terminal.
    But If I select RFM69 (#define MY_RADIO_RFM69), I have nothing.

    Is it normal?

    Thanks


  • Mod

    do you have #define MY_DEBUG enabled?



  • @gohan Yes of course

    I only modified the radio


  • Mod

    I have no idea then... I never used serial GW



  • Hi @ooznerol,

    Glad serial output is working now. Unfortunately I have no experience with serial gateway either, sorry.



  • @freynder

    Too bad...... Do you have any idea how we can debug this?



  • @ooznerol

    In general: isolating the problem and then tracing through the code. I understand you already isolated the problem to the combination of serial gateway and RFM69. First make sure this actually the case by uploading a sketch again you knew was working before with RFM69 (to eliminate any hardware / wiring issues that may have happened between your tests). If you can confirm that, you can start by looking at the code and find what is specific for the combination of these specific directives.



  • @freynder

    Instead facing through the code , I think about compile with a debugger (like IAR ou Keil for example). Do you think it is possible?



  • @ooznerol No experience with those I'm afraid. From my notes I see I did experiment with using GDB in combination with a Black Magic Probe (BMP) to debug the blue pill. You can probably convert your SWD adapter to a BMP device:
    https://madnessinthedarkness.transsys.com/blog:2017:0122_black_magic_probe_bmp_on_st-link_v2_clones
    https://github.com/blacksphere/blackmagic/wiki



  • Hi all, it's me again.

    So finally Gateway is working fine. The problem was that the driver (specially on windows) seems little bit unstable (I must open the serial just after strating and close it after I finish my test).

    So now I am playing with consumption.

    I take the low power implementation from freynder and reach 860uA. This implemenation used STOP mode. If I change this to STANDBY mode I reach 4.1uA. But in this case when I wake up, the CPU react as it has been reseted and relaunch all mysensors init and presenation etc etc . So the trick will be to check the wake up reason, and in case of wake up from standby not relaunch mysensors init. Do you think it is possible inside mysensors architecture?

    Thanks



  • @ooznerol I suppose you intend to run on battery? I desoldered the power led and voltage regulator on mine to reach 100uA (if readings were correct) using STOP mode. It ran on 2 AAA batteries for several months.

    I'm unsure about using the STANDBY mode. Since RAM and registers contents are lost and pins are high impedance, full reinitialization seems necessary. Do you want to prevent the presentation communication specifically from happening? You can control that from your sketch directly in the presentation function I suppose...



  • @freynder Yes I have of course remove unless hardware. ( i can't reach 3.3uA with it). In STOP mode, we are suppose to reach around 20-30uA (from datasheet). I will try yo investigate

    I can of course handle reset cause into presentation, but I don't know if other init are done inside mysensors architecture.
    For STANDBY mode , we can save usefull data for mysensors into backup register. I had done something similar in the past but not in stm32duino environnement.


  • Hardware Contributor

    @ooznerol said in STM32?:

    I can of course handle reset cause into presentation, but I don't know if other init are done inside mysensors architecture.
    For STANDBY mode , we can save usefull data for mysensors into backup register. I had done something similar in the past but not in stm32duino environnement.

    Yes, before the presentation MySensors will initialize radio, check radio link/parent etc
    There's no easy way to avoid it at the moment, but I think it should be a feature request, as we have the same situation with chips like NRF51/NRF52 which are also ARM based, if you want really low power consumption you need to go through a reset and MySensors initialization phase makes the wake up slow and power hungry.



  • Just got a blue-pill, RFM69 node working. It was a bit of a learning curve moving from Atmega.

    • Cheap J-Link: Never got it working. Cheap ST-Link: Worked
    • Arduino (and VisualMicro) uploaded blink sketch with ST-Link: no problems
    • Uploaded the USB bootloader using the ST-Link: no problems
    • Took a while to figure out I didn't have the dfu driver loaded (Windows 10), but after that no problems using the usb
    • MySensors security personalizer: no problems.
    • Mock MySensors node: no problems. Talked to my gateway. Uses RFM69 encryption.

    Seems like this is the Nano of the future, but without needing to level shift for 3.3V. I'm looking forward to making some real blue pill nodes and gateways.



  • Does anybody get the Serial Gateway with RS485 working? I can't get debug messages on serial console.


  • Hero Member

    @alowhum You may want to consider the nRF5 series instead.



  • OK it is working with Hardware Serial. But still no debug message on startup. Maybe it's because the switching of the usb mode.

    Is it possible to wait 2sec before starting up the gateway on stm32 boards?


  • Plugin Developer

    @neverdie Thanks! I ordered one, they look very interesting.



  • @freynder said in STM32?:

    @freynder said in STM32?:

    stm32 sensor is unable to connect to gateway:

    After further testing, this seems to work now. I'm not exactly sure why unfortunately. I'm now using the new RFM69 library. I noticed that communication seems to fail after uploading the sketch over stlink, even when clicking the reset button. When disconnecting/reconnecting the usb power all works well. Maybe that was the issue previously as well.

    Just following up on this as I finally found out why this is happening. I was using encryption and using serial upload (using stm32flash), the simulated eeprom would get overwritten by the flash erase. Not sure if this happens for dfu or stlink as well. Uploading using the black magic probe (which uses dbg) does not have this problem. I hope this may help someone struggling with the same issue.

    Edit: not sure about dfu or stlink.



  • Has anyone been able to do OTA programming with the STM32 yet?





  • @dab0g Wow! I did not expect anyone to answer. This is really great. I have a remote control lamp and a thermostat that use the STM32 and it would great to be able to program them OTA. I'll check it out.


  • Plugin Developer

    @nagelc said in STM32?:

    @dab0g Wow! I did not expect anyone to answer. This is really great. I have a remote control lamp and a thermostat that use the STM32 and it would great to be able to program them OTA. I'll check it out.

    If you do, be sure to create an English write-up for the rest of us!



  • My mini board. 0_1556711451166_photo_2019-05-01_14-50-00.jpg


Log in to reply
 

Suggested Topics

  • 4
  • 2
  • 8
  • 3
  • 20
  • 17

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts