MYSBootloader 1.3.0-beta.3


  • Admin

    @nagurao.basude no, you don't need to but the new version has some stability improvements. The fuse differences are to better match HW (osc type) & clearing eeprom.

    AVR fuse calculator: http://www.engbedded.com/fusecalc/


  • Hardware Contributor

    Hello, has someone used the 1MHz precompiled bootloader ? If yes what baud rate did you use to communicate via serial ?
    I flashed it on a node but I can't upload any script ("not in sync" error). If I believe HW.h it should be 9600 bauds but I have tried hat and nearly every baudrate with no luck.
    I had no problem using the 8MHz version.

    The only way I could use the 1MHz bootloader at the moment is to flash the hex file containing both bootloader and script.
    Sorry to ask this stupid question, I wanted to compile the bootloader but Internet connection is nearly down and I can't even download Atmel Studio 😞



  • @tekka Thank you very much for the response. I will just start migrating my existing nodes to MySensors v2.1.1library.



  • @tekka try as I might, I can't get the nodes to respond to the new 'signal report' option in MYS Controller, any ideas why?


  • Admin

    @Mark-Swift This feature only works on MySensors >=2.2.0



  • @tekka said in MYSBootloader 1.3.0-beta.3:

    @Mark-Swift This feature only works on MySensors >=2.2.0

    @tekka I'm using the latest dev branch on all my nodes and gateway...


  • Admin

    @Mark-Swift Hmm, that's odd - just tested it here with the latest dev and all is ok. Can you post the logs + node sketch?



  • Hello,

    I have notice strange behavior with MYSBootloaderV13pre.hex 8MHz internal bootloader.

    Problem: When I burn MYSBootloaderV13pre.hex 8MHz internal bootloader to my Standalone Atmega328p i testing it with Arduino Blink and Fade sketches. Problem is that theese sketches doesn't work on this bootloader. LED is just always ON.

    I also tested the same sketches, same wiring, same Arduino Uno (5V when programming), same FTDI programmer (3.3V), same PC with Win 10 with same drivers, same Atmega328p with Nick Gammon Atmega Board Programmer when I burn Lilypad bootloader and then upload Blink and Fade sketches, they perfectly working.

    I tried same uploading with Arduino IDE 1.6.5 and also with the newest version 1.8.5.
    As a programmer I using Arduino as ISP. I theese tests when burning bootloader I don't connect external oscilator.

    With Nick Gammon software I also checked fuses for both Lilypad and MYSBootloader settings, becose i was thought it is becose of them. Once I configure wrong fuses and it had a lot of time to reset it to default value.
    Question: So now before changing fuses I want to ask maybe someone have been faced with similar problem?

    I paste below info about Lilipad and MYSBootloader 8MHz internal oscilator boards fuse settings:

    Lilypad bootloader
    
    Atmega fuse calculator.
    Written by Nick Gammon.
    Version 1.11
    Compiled on Nov 30 2017 at 17:36:58 with Arduino IDE 10805.
    Attempting to enter programming mode ...
    Entered programming mode OK.
    Signature = 0x1E 0x95 0x0F 
    Processor = ATmega328P
    Flash memory size = 32768
    LFuse = 0xE2 
    HFuse = 0xDA 
    EFuse = 0xFD 
    Lock byte = 0xEF 
    Clock calibration = 0x8E 
    External Reset Disable.................. [ ]
    Debug Wire Enable....................... [ ]
    Enable Serial (ICSP) Programming........ [X]
    Watchdog Timer Always On................ [ ]
    Preserve EEPROM through chip erase...... [ ]
    Boot into bootloader.................... [X]
    Divide clock by 8....................... [ ]
    Clock output............................ [ ]
    Bootloader size: 2048 bytes.
    Start-up time: SUT0: [X]  SUT1: [ ] (see datasheet)
    Clock source: calibrated internal oscillator.
    Brownout detection at: 2.7V.
    
    MYSBootloaderV13pre bootloader
    
    Atmega fuse calculator.
    Written by Nick Gammon.
    Version 1.11
    Compiled on Nov 30 2017 at 19:48:16 with Arduino IDE 10805.
    Attempting to enter programming mode ...
    Entered programming mode OK.
    Signature = 0x1E 0x95 0x0F 
    Processor = ATmega328P
    Flash memory size = 32768
    LFuse = 0xE2 
    HFuse = 0xD2 
    EFuse = 0xFE 
    Lock byte = 0xFF 
    Clock calibration = 0x8E 
    External Reset Disable.................. [ ]
    Debug Wire Enable....................... [ ]
    Enable Serial (ICSP) Programming........ [X]
    Watchdog Timer Always On................ [ ]
    Preserve EEPROM through chip erase...... [X]
    Boot into bootloader.................... [X]
    Divide clock by 8....................... [ ]
    Clock output............................ [ ]
    Bootloader size: 2048 bytes.
    Start-up time: SUT0: [X]  SUT1: [ ] (see datasheet)
    Clock source: calibrated internal oscillator.
    Brownout detection at: 1.8V.
    

    I appreciate any helpful info!

    EDIT: I think I already found that there is newer MYSBootloader files of development version which working without problems. I will test it if I write good fuses 🙂



  • @tekka said in MYSBootloader 1.3.0-beta.3:

    @Mark-Swift Hmm, that's odd - just tested it here with the latest dev and all is ok. Can you post the logs + node sketch?

    @tekka, just tried again, perhaps I'm missing something obvious?

    I have the gateway and node using the latest dev branch, I click the node in MYS and then request a signal report - I see a tx in the log but nothing further? Do I need anything in the node sketch or the gateway? Does this work with the NRF's?


  • Admin

    @tekka said in MYSBootloader 1.3.0-beta.3:

    @Mark-Swift Hmm, that's odd - just tested it here with the latest dev and all is ok. Can you post the logs + node sketch?



  • Hello,

    Q1: Does anybody was able to succesfully use 8MHz MYSBootloader 1.3.0-beta.3 on standalone Atmega328p?

    All bootloaders I testing with Arduino BLINK example.
    Arduino 1.8.5

    I was testing 8MHz internal oscilator MYSBootloader 1.3.0-beta.3 with fuses on 2 different Atmega328p standalone but I can't upload sketch to it and test it. Arduino avrdude says that:
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x4a

    Used fuses:
    proMYSBL8.bootloader.low_fuses=0xE2
    proMYSBL8.bootloader.high_fuses=0xDA
    proMYSBL8.bootloader.extended_fuses=0x06 / 07
    proMYSBL8.bootloader.unlock_bits=0x3F
    proMYSBL8.bootloader.lock_bits=0x3F / 0F

    Before that, I was burned my Atmega328p with 1MHz internal oscilator MYSBootloader 1.3.0-beta.3 bootloader and it was working.

    Also I was testing 8MHz internal oscilator MYSBootloader 1.3pre2 with fuses on 2 different Atmega328p standalone and I can upload sketch to it and test it.
    Used fuses:
    proMYSBL8.bootloader.low_fuses=0xE2
    proMYSBL8.bootloader.high_fuses=0xDA
    proMYSBL8.bootloader.extended_fuses=0x06 / 07
    proMYSBL8.bootloader.unlock_bits=0x3F
    proMYSBL8.bootloader.lock_bits=0x3F / 0F

    Q2: I noticed that with 8MHz internal oscilator MYSBootloader 1.3pre2 LED blinks not continuosly it like (* led ON; - led OFF):
    *** --- *** --- *** --- ** - * - * - * - [cycle ends, then repeats again] *** --- *** --- *** --- ** - * - * - * - ...
    And this one cycle of *** --- *** --- *** --- ** - * - * - * - takes ~8 seconds. Could it be something with watchdog timer? I not very know about this setting.

    Thank You for help!


  • Admin

    @Mark-Swift said in MYSBootloader 1.3.0-beta.3:

    @tekka said in MYSBootloader 1.3.0-beta.3:

    @Mark-Swift Hmm, that's odd - just tested it here with the latest dev and all is ok. Can you post the logs + node sketch?

    @tekka, just tried again, perhaps I'm missing something obvious?

    I have the gateway and node using the latest dev branch, I click the node in MYS and then request a signal report - I see a tx in the log but nothing further? Do I need anything in the node sketch or the gateway? Does this work with the NRF's?

    Did you try with 1.3.0-beta.4? https://github.com/mysensors/MySensorsBootloaderRF24/tree/development



  • @tekka said in MYSBootloader 1.3.0-beta.3:

    @Mark-Swift said in MYSBootloader 1.3.0-beta.3:

    @tekka said in MYSBootloader 1.3.0-beta.3:

    @Mark-Swift Hmm, that's odd - just tested it here with the latest dev and all is ok. Can you post the logs + node sketch?

    @tekka, just tried again, perhaps I'm missing something obvious?

    I have the gateway and node using the latest dev branch, I click the node in MYS and then request a signal report - I see a tx in the log but nothing further? Do I need anything in the node sketch or the gateway? Does this work with the NRF's?

    Did you try with 1.3.0-beta.4? https://github.com/mysensors/MySensorsBootloaderRF24/tree/development

    @tekka that did it, it's now working... now to figure out what the returned signal report numbers mean 🙂



  • @tekka thank You for the answer. I'm not sure is answer was dedicated for me or for Mark, but I tested 1.3.0-beta.4 in the same way I described before:

    • Tested with 2 different Atmega328p
    • First try was with 1MHz - working on both Atmega328p
    • Second try with 8MHz - same situation as with beta 3, skecth won't upload and I get answer from Arduino Avrdude (this time I post full log after uploading):
    avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
    
             System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
    
             Using Port                    : COM4
             Using Programmer              : arduino
             Overriding Baud Rate          : 38400
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf1
    avrdude: stk500_recv(): programmer is not responding
    < ... >
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xf1
    
    avrdude done.  Thank you.
    

    It would be best if someone also could try to burn same bootloader on standalone Atmega328p and post results to be sure all wiring and steps I did is without mistakes.
    Strange if I I burn 1.3pre2 8MHz bootloader - it works.

    What troubleshooting I could make?



  • @tekka, Thanks for the link to the beta.4. bootloader. I have tried burning nodes using these and tested them by uploading the FW using MySController 1.0beta_b3316 (latest update meant for MySensors2.2.0) with SerialGatewaySketches using both MySensors2.2.0_rc1 and MySensrs2.2.0_pre1 libraries.

    MysController doesn't seem to even recognize the Beta.4 bootloaded Nodes (Promini 5V16Mhz with default provided fuse settings from Makefile). The extra nRF chip wiring checks and precautions (0.01uF and 100uF Caps) have been taken. What might be the problem? How to debug when SerialMontitor cant be used? Any Network Sniffer link if that helps...

    I guess the MySensors library version of the SerialGateway sketch may be posing a problem. Can you please help me with a link of the correct MySensors library version to use with beta.4 bootloaded nodes?

    Any help will be appreciated...



  • Hi @tekka!
    Do you plan to add support for the RFM69 module in MYSBootloader?



  • No help from the community! Sad!!!


  • Admin

    @wanvo This would certainly be a great addition to MYSBootloader - but very limited dev time atm. Community contributions on that topic are welcome 😉


  • Admin

    @vikasjee Apologies for the late reply - I have no idea what's the issue with your setup - my guess is that something is wrong with the fuses and/or wrong .hex used: Can you post the MYSController log, used fuse settings and any other important information?



  • @tekka thanks for the answer. I'm still a newbie.
    Now I can not make a contribution to the development due to my incompetence.
    I can help as a tester 🙂



  • @jacikaas

    Hello, maybe someone was trying 8MHz bootloader for standlaone Atmega328p?



  • Hi,

    Anyone seen this error on latest 1.3 release? It seems a define is not done for F_CPU, what am I missing here?

    Generating function prototypes...
    In file included from C:\Program Files (x86)\Arduino\portable\sketchbook\libraries\MySensors/MySensors.h:371:0,
    
    from C:\Program Files (x86)\Arduino\portable\sketchbook\libraries\MySensors\examples\GatewayW5100MQTTClient\GatewayW5100MQTTClient.ino:138:
    
    C:\Program Files (x86)\Arduino\portable\sketchbook\libraries\MySensors/core/MyTransport.cpp:777:42: error: operator '>' has no left operand
    
     #if defined(MY_GATEWAY_FEATURE) && (F_CPU>16000000)
    
                                              ^
    
    In file included from C:\Program Files (x86)\Arduino\portable\sketchbook\libraries\MySensors/MySensors.h:396:0,
    
                     from C:\Program Files (x86)\Arduino\portable\sketchbook\libraries\MySensors\examples\GatewayW5100MQTTClient\GatewayW5100MQTTClient.ino:138:
    
    C:\Program Files (x86)\Arduino\portable\sketchbook\libraries\MySensors/core/MySensorsCore.cpp:479:11: error: operator '>' has no left operand
    
     #if (F_CPU>16000000)
    
               ^
    exit status 1
    Error compiling for board ATmega328 with MYSBootloader 1.3.0.
    

    Regards



  • @cdr Same Problem here!

    Greetz Henry



  • @cdr @Henry I ran into the same issue. Turned out to be a syntax issue in the boards.txt file. If you change:

    MYSBL.menu.frequency.MYSBL16.f_cpu=16000000L
    

    into

    MYSBL.menu.frequency.MYSBL16.build.f_cpu=16000000L
    

    Then it works again. Adding build. needs to be done for the other menu entries as well.



  • @tsjoender

    PERFEKT!!! thx!!!



  • @tsjoender said in MYSBootloader 1.3.0-beta.3:

    @cdr @Henry I ran into the same issue. Turned out to be a syntax issue in the boards.txt file. If you change:

    MYSBL.menu.frequency.MYSBL16.f_cpu=16000000L
    

    into

    MYSBL.menu.frequency.MYSBL16.build.f_cpu=16000000L
    

    Then it works again. Adding build. needs to be done for the other menu entries as well.

    thanks a lot!


  • Admin



  • Hello,
    I am currently testing the OTA features with a "My Slim 2AA Battery Node", MYSBootloader 1.3.0-rc.1, MYSController Build 3316 and the original example sketch "PassiveNode" (MySensors 2.2.0). Unfortunately, no reboot will be performed if I want to execute it via the MYSController. Even with a firmware update, no reboot is performed. If I disconnect the sensor from the battery and reconnect, the firmware update will be executed. Am I doing something wrong or is this a software bug?

    Regards
    Thomas


  • Mod

    Try using smartsleep instead of usual sleep



  • Hello, thank you. It basically works with smartSleep. I only have to press the FW update or reboot button several times. After several attempts, the desired action is then executed.
    Regards Thomas



  • Hello.
    First, thanks to everybody developing all the stuff that is here, these are awesome projects and sorry to resurrect an old thread.

    Second, i am trying to use the firmware update feature from MYSController, build 3316, with MYSBootloader, 1.3.0-rc1 8MHz, on a barebone atmega 328pu 28dip .
    The device is running a simple thermistor sketch and reports happily to my RPi running MySensors ethernet gateway version 2.3.1-alpha(I have tried with version 2.2.0 as well).
    I get the "reboot" screen if i choose the firmware after setting the device as a "Board with MYSBootloader" and the device clearly reboots but does not start any firmware download.

    And of course, i am running nrf24l01+. Device is batterypowered from an 18650 li-ion, through a mcp1700 LDO 3.3v 250mA. 10uF on the nrf between vcc and gnd.
    Device is set to sleep for 60 secs, but is also set to smartsleep for 500ms, as i read somewhere had solved other peoples issues.

    Edit: I believe i was being stupid as i first burned the bootloader using arduino as isp and then burned the sketch, alas, erasing bootloader.


  • Admin

    @patrikr76 Yes, sounds like you erased MYSBootloader when uploading the sketch via ISP. Please post the MYSController log (starting before you reboot the node until the node is up an running) to verify this assumption.



  • Hello, everyone. Has anyone ever encountered a problem where after a power surge the device on this bootloader stops working? When I first encountered this, I did some tests. They're confirmed. This applies only to network devices. With the battery there are no such problems at all. So I had to switch to DuaiOptiboot. All stable. I do a bit of home programming 🙂 so I don't think the problem is on my side, simple bugs are excluded.


  • Admin

    @berkseo Can you share additional details regarding your tests, ideally including logs that showed the proper function of the bootloader before the surge and after - what tool are you using for OTA updates?


  • Hardware Contributor

    @berkseo

    +1 for more details please, regarding hw and the power supply, mcu, fuses too.
    weird problem.. it works on batt but not on AC?? how do you replicate these power surge?
    if you have AC powered nodes sensible to power surge, transcient, I would add a TVS diode on the dc power supply side, and I would protect signals if needed. adding some filtering does not hurt too, pcb gnd isolation/shielding plane as well.
    Because, "even if" there is something related to mys bootloader, it seems also related to surge protection..



  • @tekka said in MYSBootloader 1.3.0-beta.3:

    Can you share additional details regarding your tests, ideally including logs that showed the proper function of the bootloader before the surge and after - what tool are you using for OTA updates?

    Now not many can to share on the subject. We need to reproduce the problem again. OTA through the Majordomo system. But it's not about the update. The device died during a power surge, a feeling that was in the mode of receiving firmware due to the jump. Only re-recording the bootloader helped restore the device.



  • @scalz The problem was seen when the voltage surge in the network. It was later reproduced using supercapacitors. Let's try to reproduce the problem as follows: power the unit from 3.3 V, hang the supercapacitor on 1F in parallel and the led on the power through the 1K resistor, wait until the supercapacitor is charged, then wait for the discharge and on the verge of turning off ~ 2V, apply power pulses. I can't debug it right now. Will time will make. Bootloader latest version.
    There was a filter and a stabilizer. power surges are in principle excluded



  • Hello,
    can the bootloader also be used on an Atmega32U4? After programming, the Atmega is no longer recognized by the Usb port of the PC. Should programming via the IDE (Arduino, PlatformIO) still be possible or will it only work via MyController?


  • Mod

    @mafe I don't have experience with FOTA, but this part of the documentation might help:

    The MySensors master branch does not support upload through ftdi / serial (but the development branch does).

    But I don't think MYSBootloader has support for Atmega32U4 at all.



  • Thanks for your answer!
    Sorry, I forgot to mention that I want to do FOTA via an MQTT gateway. Is that working at all right now?



  • @mafe said in MYSBootloader 1.3.0-beta.3:

    imenticato di dire che voglio fare FOTA tramite un gateway MQTT. Sta f

    If I understand OTA well with an MQTT gateway it is not possible. This at least using MYSBootloader



  • Hello, in one of the devices on mega2560 I want to use MYSBootloader for FOTA. Is this even possible for mega2560?
    I changed the MYSBootloader sources for mega2560, the update is on, but it is looping (i.e. it reaches 100% and starts again), I think that the problem is in calculating the CRC of the firmware and I need to fix the static uint16_t calcCRCrom (const uint16_t len) function, but I have lack of knowledge, as I'm not a programmer, but just an amateur. Can someone help or suggest?

    P.S. Sorry for my english, it's all google translate



  • Hi, have been using myscontroller more than a year now and at some point i couldn't use OTA on devices, all the sensor data is coming in nicely. I don't know if it was due to updated arduino or i messed up something in my doards.txt or something else...
    So question is if someone can give me versions/links to working solution?
    https://github.com/mysensors/MySensorsBootloaderRF24/tree/development doesn't work.

    I'm using ProMini 16Mhz with external oscillator. Arduino is 1.8.13, MySensors 2.2.2,
    Myscontroller 1.0.0beta:b3316.


  • Mod

    @iguaan "doesn't work" is a bit too vague for us to help. Could you share a bit information on what you did, what you expected to happen and what happened instead?



  • That's the problem, i don't know what exactly happened/caused this. That's why i'm asking for working solutions/versions so i can try to trace back what might be wrong with my setup.

    Also now i remembered that i had to renew gateway with esp8266 since previous broke down. I don't know for sure that i had previously ota feature for gateway enabled.
    GW sketch:

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // kui lae peale ei jõua
    #define MY_SIGNING_WEAK_SECURITY  //!<  Nodes that present themselves as not requiring signing or whitelisting will be cleared of this requirement at the receiving end.
    //#define MY_DEBUG_VERBOSE_SIGNING //!< Enable signing related debug prints to serial monitor
    //#define MY_SIGNING_SOFT //!< Software signing
    //#define MY_SIGNING_REQUEST_SIGNATURES // Enable this if you want destination node to sign all messages sent to this node.
    //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A0 //!< Unconnected analog pin for random seed
    
    #define MY_RADIO_RF24
    #define MY_GATEWAY_ESP8266
    #define MY_WIFI_SSID "hidden"
    #define MY_WIFI_PASSWORD "hidden"
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    #define MY_IP_ADDRESS hidden
    //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
    #define MY_HOSTNAME "hidden"
    // If using static ip you need to define Gateway and Subnet address as well
    #define MY_IP_GATEWAY_ADDRESS hidden
    #define MY_IP_SUBNET_ADDRESS hidden
    
    // The port to keep open on node server mode
    #define MY_PORT hidden
    
    // How many clients should be able to connect to this gateway (default 1)
    #define MY_GATEWAY_MAX_CLIENTS 2
    
    #include <ArduinoOTA.h>
    #include <MySensors.h>
    
                                  
    void setup()
    {
        Serial.begin(115200);
      // Setup locally attached sensors
      ArduinoOTA.onStart([]() {
        Serial.println("ArduinoOTA start");
      });
      ArduinoOTA.onEnd([]() {
        Serial.println("\nArduinoOTA end");
      });
      ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        Serial.printf("OTA Progress: %u%%\r", (progress / (total / 100)));
      });
      ArduinoOTA.onError([](ota_error_t error) {
        Serial.printf("Error[%u]: ", error);
        if (error == OTA_AUTH_ERROR) {
          Serial.println("Auth Failed");
        } else if (error == OTA_BEGIN_ERROR) {
          Serial.println("Begin Failed");
        } else if (error == OTA_CONNECT_ERROR) {
          Serial.println("Connect Failed");
        } else if (error == OTA_RECEIVE_ERROR) {
          Serial.println("Receive Failed");
        } else if (error == OTA_END_ERROR) {
          Serial.println("End Failed");
        }
      });
      ArduinoOTA.begin();
    }
    
    
    void presentation()
    {
      sendSketchInfo("GW", "1"); // Present locally attached sensors here
     
    }
    
    
    void loop()
    {
        // Send locally attached sensors data here
      ArduinoOTA.handle();
    }
    

    I remember when i got it first working year(s) ago i tried also different bootloaders, fiddled with fuse settings and eventually got it working perfectly, but now (since i've updated arduino) maybe my board settings are incorrect.



  • Well found the problem.
    I had also changed gw nrf module to NRF24L01+PA+LNA 2.4GHz:
    511ec8a3-c017-4878-831f-ac176dbf5707-image.png and it seems to be the issue.
    Although regular traffic monitoring etc is working ok.
    Changed back to usual nrf24l01+ module and updates are working again.
    Both variants are ali merchandise.



  • @iguaan Try to set MY_RF24_PA_LEVEL to RF24_PA_MIN on gateway then use NRF24L01+PA+LNA module - in my case the OTA begin work perfect!



  • @cabat said in MYSBootloader 1.3.0-beta.3:

    @iguaan Try to set MY_RF24_PA_LEVEL to RF24_PA_MIN on gateway then use NRF24L01+PA+LNA module - in my case the OTA begin work perfect!

    Well finally got time to try it out and it worked like a charm, thank you!
    Also no problem with a node that is about 1,5m away from GW.
    LOW also worked, but OTA was slow.



  • Hello,
    I've been coming to this forum for a long time, and this is my first time posting.
    I have a node, that has a DFPLAYER (mp3) and it works with the stock arduino (nano) bootloader. When I burn MYSBootloader 1.3.0, the node continuously restarts every 20 seconds. It stops at "Enable to begin" and restarts.
    The library I use for the DFplayer is "SoftwareSerial". The problem would not come from there?

    #define MY_DEBUG
    #define MY_NODE_ID 19
    #define MY_REPEATER_FEATURE
    #define NODE_NAME "Door Bell"
    #define NODE_VERSION "1.0"
    
    #define MY_RADIO_RF24
    
    #include <MySensors.h>
    #include <Wire.h>
    #include "SparkFunHTU21D.h"
    #include "SoftwareSerial.h"
    #include "DFRobotDFPlayerMini.h"
    
    //For DFPlayer
    #define RX_PIN 8
    #define TX_PIN 7
    
    // Id of the sensor child
    #define TEMP_ID 1
    #define HUM_ID 2
    #define BELL_ID 3
    #define SOUND_ID 4
    #define VOLUME_ID 5
    #define EQ_ID 6
    
    unsigned long delay_wait = 300000; //5mn
    float lastTemp = 0.0;
    byte lastHum = 0;
    bool boot = 1;
    String eq = "Pop";
    byte volume = 2; //Set volume value. From 0 to 30
    int count = 0;
    
    //Create an instance of the object
    HTU21D myHumidity;
    
    SoftwareSerial mySoftwareSerial(RX_PIN, TX_PIN); // RX, TX
    DFRobotDFPlayerMini myDFPlayer;
    void printDetail(uint8_t type, int value);
    
    // Initialize general message
    MyMessage msgT(TEMP_ID, V_TEMP);
    MyMessage msgH(HUM_ID, V_HUM);
    MyMessage msgB(BELL_ID, V_ARMED);
    MyMessage msgS(SOUND_ID, V_VAR1);
    MyMessage msgV(VOLUME_ID, V_VAR2);
    MyMessage msgEQ(EQ_ID, V_VAR3);
    
    void before()
    {
        // Optional method - for initialisations that needs to take place before MySensors transport has been setup (eg: SPI devices).
    }
    
    void setup()
    {
      myHumidity.begin();
      mySoftwareSerial.begin(9600);
    
      Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
    
      if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
        Serial.println(F("Unable to begin:"));
        Serial.println(F("1.Please recheck the connection!"));
        Serial.println(F("2.Please insert the SD card!"));
        while (true) {
          delay(0); // Code to compatible with ESP8266 watch dog.
        }
      }
      Serial.println(F("DFPlayer Mini online."));
    
      //read and send EQ setting
      myDFPlayer.EQ(DFPLAYER_EQ_POP);
      send(msgEQ.set(eq.c_str()));  //read and send EQ setting
      wait(250);
    
      //read and send current volume
      myDFPlayer.volume(volume);
      byte vol = round(volume / 0.3);
      send(msgV.set(vol));
      wait(250);
    
      myDFPlayer.playMp3Folder(1); //play specific mp3 in SD:/MP3/0001.mp3; File Name(0~65535)
    
    
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and controller
      sendSketchInfo(NODE_NAME, NODE_VERSION);
    
      // Register all sensors to gw (they will be created as child devices)
      present(TEMP_ID, S_TEMP);
      present(HUM_ID, S_HUM);
      present(BELL_ID, S_CUSTOM);
      present(SOUND_ID, S_CUSTOM);
      present(VOLUME_ID, S_CUSTOM);
      present(EQ_ID, S_CUSTOM);
    }
    
    void loop()
    {
      static unsigned long timer = millis();
    
      if (millis() - timer >  delay_wait) {
    
        float humd = myHumidity.readHumidity();
        float temp = myHumidity.readTemperature();
    
        Serial.print(" Temperature:");
        Serial.print(temp, 1);
        Serial.print("C");
        Serial.print(" Humidity:");
        Serial.print(humd, 1);
        Serial.println("%");
    
        if (lastTemp != temp) {
          send(msgT.set(temp, 1));
          lastTemp = temp;
        }
    
        byte H = round(humd);
    
        if (lastHum != H) {
          send(msgH.set(H));
          lastHum = H;
        }
        timer = millis();
      }
    
    
      if (myDFPlayer.available()) {
        printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
      }
    }
    
    void printDetail(uint8_t type, int value) {
      switch (type) {
        case TimeOut:
          Serial.println(F("Time Out!"));
          break;
        case WrongStack:
          Serial.println(F("Stack Wrong!"));
          break;
        case DFPlayerCardInserted:
          Serial.println(F("Card Inserted!"));
          break;
        case DFPlayerCardRemoved:
          Serial.println(F("Card Removed!"));
          break;
        case DFPlayerCardOnline:
          Serial.println(F("Card Online!"));
          break;
        case DFPlayerUSBInserted:
          Serial.println("USB Inserted!");
          break;
        case DFPlayerUSBRemoved:
          Serial.println("USB Removed!");
          break;
        case DFPlayerPlayFinished:
          Serial.print(F("Number:"));
          Serial.print(value);
          Serial.println(F(" Play Finished!"));
          send(msgB.set(false));
          break;
        case DFPlayerError:
          Serial.print(F("DFPlayerError:"));
          switch (value) {
            case Busy:
              Serial.println(F("Card not found"));
              break;
            case Sleeping:
              Serial.println(F("Sleeping"));
              break;
            case SerialWrongStack:
              Serial.println(F("Get Wrong Stack"));
              break;
            case CheckSumNotMatch:
              Serial.println(F("Check Sum Not Match"));
              break;
            case FileIndexOut:
              Serial.println(F("File Index Out of Bound"));
              break;
            case FileMismatch:
              Serial.println(F("Cannot Find File"));
              break;
            case Advertise:
              Serial.println(F("In Advertise"));
              break;
            default:
              break;
          }
          break;
        default:
          break;
      }
    }
    
    void receive(const MyMessage &message)
    {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type == V_VAR1) {
        int num = message.getInt();
        myDFPlayer.playMp3Folder(num); //play specific mp3 in SD:/MP3/0001.mp3; File Name(0~65535)
        send(msgB.set(true));
      }
      if (message.type == V_VAR2) {
        byte vol = round(message.getByte() * 0.3);  // 0~100% to 0~30
        myDFPlayer.volume(vol);  //Set volume value (0~30)
        Serial.print("Set volume : ");
        Serial.println(vol);
      }
      if (message.type == V_VAR3) {
        byte req = message.getByte();
        Serial.print("Equalizer : ");
        switch (req) {
          case 1:
            myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
            Serial.println("Normal");
            eq = "Normal";
            break;
          case 2:
            myDFPlayer.EQ(DFPLAYER_EQ_POP);
            Serial.println("Pop");
            eq = "Pop";
            break;
          case 3:
            myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
            Serial.println("Rock");
            eq = "Rock";
            break;
          case 4:
            myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
            Serial.println("Jazz");
            eq = "Jazz";
            break;
          case 5:
            myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
            Serial.println("Classic");
            eq = "Classic";
            break;
          case 6:
            myDFPlayer.EQ(DFPLAYER_EQ_BASS);
            Serial.println("Bass");
            eq = "Bass";
            break;
          default:
            break;
        }
        send(msgEQ.set(eq.c_str()));
      }
    
    }
    

    Thanks Google for the translation 🙂



  • @Trand Do you mean that it stops at "Unable to begin"?? I don't see "Enable" in there.

    If it's "Unable" then I would suspect that you don't have it wired up correctly. Are you sure about the RX_PIN and TX_PIN? If it were me, I would double check them again. And then swap them in the code after double checking them, just in case.

    If there's absolutely no doubt that you have the correct wires connected, do you also have a ground wire connected between the Arduino and the DFplayer? Finally, are you sure that 9600 is a good speed to communicate with the DFplayer? (I have no experience with this module, so these are just general troubleshooting ideas.)



  • @ejlane Thank you for your answer. I don't think I have any connection problem, it's soldered on a PCB and it works with the original NANO Bootloader. The speed 9600 is the one given in the example of the library, and I think that the problem comes from SoftwarSerial... I continue to search.



  • @Trand Well, sorry, but nothing else comes to mind. If you have a scope or logic analyzer then you need to watch the actual signals on the wires and see what is happening.

    If you don't, then you should pick up a cheap logic analyzer. You can get one for $10 and it's invaluable for tracking down things like this. I don't know where you are based, but I see them on Aliexpress all the time.


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 2
  • 1
  • 10
  • 3

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts