Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Trand
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Trand

    • PJON and Minicore not working

      Hello,

      I'm encountering an issue with the PJON protocol and the Minicore bootloader on a 328P-PU. The upload works fine, the Atmega starts and tries to connect to the gateway, but nothing comes out of the BUS PIN of the Atmega 328P-PU! The gateway doesn't receive any information.
      Using the official NANO bootloader works. I should mention that the setup is on a PCB, so there are no bad connections.
      If you have any ideas, I'm open to making it work. Thanks.

      posted in Development
      Trand
      Trand
    • RE: Counting Incoming and Outgoing Messages from a Gateway

      @mfalkvidd
      Thank you very much, that's exactly what I was looking for!

      posted in Development
      Trand
      Trand
    • Counting Incoming and Outgoing Messages from a Gateway

      Hello everyone,

      I would like to be able to count the messages passing through an MQTT gateway in order to generate statistics. The idea would be to count the received messages, sent messages, and perhaps the NACKs!
      I can successfully count the incoming messages from the nodes with void receive(), but I can't manage to do this for the outgoing messages. Is there any way to do this?

      Thank's

      posted in Development
      Trand
      Trand
    • RE: MYSBootloader 1.3.0-beta.3

      @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.

      posted in Development
      Trand
      Trand
    • RE: MYSBootloader 1.3.0-beta.3

      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 🙂

      posted in Development
      Trand
      Trand