Giter Club home page Giter Club logo

rfid134's People

Contributors

makuna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rfid134's Issues

HexLsbAsciiToUint64()

Hello, Thank you for your rfid code.
But where can I find the implementation of the HexLsbAsciiToUint64() function?
Is it in some Arduino library?

Thank you.

WL134 and ESP8266

Sometime WL134 module doesn't "read" (blue LED turns on, but no reading). After some seconds, wl134 reads and transmit correctly. Why?

Enhance to support HDX tag data format

Alistair Phillips @Ali_Phillips01_twitter Dec 09 2021 07:34
Hi, thanks for the code, Im using the WL-134 Board for aliexpress, the rfid134 code works with the sample tag that has come with the reader, however the code gives "Com Error 130" when i try my UK Sheep EID tags .... in the bast i have written my own code to read the tag and that works fine, what does the Com Error 130 mean, and why wont it read the uk animal tags

Alistair Phillips @Ali_Phillips01_twitter Dec 10 2021 06:44
just to follow up i found the issue, The code is set to look for full duplex tags and the ones im using are HDX so had to change the line if (packet[Rfid134_Packet_EndCode] != 0x03) to if (packet[Rfid134_Packet_EndCode] != 0x07) to look for the correct end

End Code can be 0x03 or 0x07.
Add member in Rfid134Reading for TagStyle and an enum that matches these end codes.

Consider exposing a Reset feature

"You can pull RST low level for 10 ms, and then pull it high, ( suggest 5V voltage)the module will restart read tags.if you plan to use 1pcs lipo battery, I suggest you can use MP1540 step-up DC-DC,3.7 lipo battery step-up tp 8V, and get best reading performance.no sleep mode, you can use mosfet to control power supply, when you don't need read tag, you can shut down the power."

At least add something to wiki

This is the answer from the guy that build the pcb

After Arduino Uno sleep mode SLEEP_MODE_PWR_DOWN serial data is read incorrect

Hello,

I am trying to make a cat feeder for my cats. Everything works just fine without implementing sleep mode... I tried implementing sleep mode to save my electric bill and batteries... But unfortunately I can not find a way to do it. Until the first sleep reader is working fine, then it stops working. Even if it reads some kind of id, value of it is incorrect. I have moved serial reading part to loop() method. What I am doing wrong or what can I try to make it work... ? I do not have any electrical engineering background so any help would be very appreciated.

Here are some serial logs:
3:43:16.129 -> Rfid13Ar�ե������k�going to���eep... 23:43:34.066 -> Arduino���ke up! 23:43:34.066 -> Arduino���ke up! 23:43:34.066 -> Arduino���ke up! 23:43:34.066 -> Arduino���ke up! 23:43:35.811 -> Arduino���ke up! 23:43:35.811 -> Arduino woke up! 23:43:35.843 -> Arduino woke up! 23:43:35.843 -> Arduino woke up! 23:43:35.843 -> Arduino woke up! 23:43:35.843 -> Working 23:43:35.843 -> Rfid134_Error_None 23:43:35.843 -> Rfid134_Error_PacketEndCodeMissmatch 23:43:35.843 -> Rfid134_Error_Packe� ���cksum 23:43:37.718 -> Rfid����_Error_PacketChecksumInvert 23:43:37.752 -> 83821369977 23:43:37.752 -> Arduino woke up! 23:43:37.752 -> Arduino woke up! 23:43:37.752 -> Working 23:43:37.752 -> Rfid134_Error_None 23:43:37.752 -> Rfid134_Error_PacketEndCodeMissmatch 23:43:37.752 -> Rfid134_Erro���acketChecksum �He�id134_Error_Pac����ChecksumInvert 23:43:39.538 -> 17840194 23:43:39.580 -> Arduino woke up! 23:43:39.580 -> Arduino woke up! 23:43:39.580 -> Arduino woke up! 23:43:39.580 -> Working 23:43:39.580 -> Rfid134_Error_None 23:43:39.580 -> Rfid134_Error_PacketEndCodeMissmatch 23:43:39.580 -> Rfid134_�Q.�or_PacketChecks�W�� 23:43:41.161 -> Rfid134_Error_���ketChecksumInvert 23:43:41.161 -> 69688 23:43:41.206 -> Arduino woke up! 23:43:41.206 -> Arduino woke up! 23:43:41.206 -> Arduino woke up! 23:43:41.206 -> Working 23:43:41.206 -> Rfid134_Error_None 23:43:41.206 -> Rfid134_Error_PacketEndCodeMissmatch 23:43:41.206 -> Rfid1�&��Error_PacketChe����um 23:43:42.920 -> Rfid134_Err�K}�PacketChecksumI�˕�rt 23:43:42.920 -> 17

Code:

#include <avr/sleep.h>
#include <avr/power.h>
#include <SoftwareSerial.h>

// Define RX and TX pins for SoftwareSerial (optional)
const int rxPin = 10;
const int txPin = 11;


SoftwareSerial mySerial(rxPin, txPin);

enum Rfid134_Error {
  Rfid134_Error_None,

  // from library
  Rfid134_Error_PacketSize = 0x81,
  Rfid134_Error_PacketEndCodeMissmatch,
  Rfid134_Error_PacketChecksum,
  Rfid134_Error_PacketChecksumInvert
};

struct Rfid134Reading {
  uint16_t country;
  uint64_t id;
  bool isData;
  bool isAnimal;
  uint16_t reserved0;
  uint32_t reserved1;
};

enum DfMp3_Packet {
  Rfid134_Packet_StartCode = 0,
  Rfid134_Packet_Id = 1,
  Rfid134_Packet_Country = 11,
  Rfid134_Packet_DataFlag = 15,
  Rfid134_Packet_AnimalFlag = 16,
  Rfid134_Packet_Reserved0 = 17,
  Rfid134_Packet_Reserved1 = 21,
  Rfid134_Packet_CheckSum = 27,
  Rfid134_Packet_CheckSumInvert = 28,
  Rfid134_Packet_EndCode = 29,
  Rfid134_Packet_SIZE = 30
};

uint64_t HexLsbAsciiToUint64(char* text, uint8_t textSize) {
  uint64_t value = 0;
  uint8_t i = textSize;
  do {
    i--;

    uint8_t digit = text[i];
    if (digit >= 'A') {
      digit = digit - 'A' + 10;
    } else {
      digit = digit - '0';
    }
    value = (value << 4) + digit;
  } while (i != 0);

  return value;
};

void setup() {
  // Initialize hardware serial communication
  Serial.begin(115200);

  // Initialize software serial communication (optional)
  mySerial.begin(9600);
  mySerial.setTimeout(1000);
  while (!mySerial) {
    ;  // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("Arduino is going to sleep...");

  // Set up the sleep mode
  set_sleep_mode(SLEEP_MODE_PWR_SAVE);  // Choose appropriate sleep mode

  // Enable sleep mode
  sleep_enable();

  // Attach the interrupt to wake up the Arduino upon receiving serial data
  attachInterrupt(digitalPinToInterrupt(rxPin), wakeUp, LOW);
}

void loop() {
  // Put the Arduino to sleep
  sleep_mode();  // The program will continue from here after waking up

  // Disable sleep mode after waking up
  sleep_disable();

  // Detach the interrupt
  detachInterrupt(digitalPinToInterrupt(rxPin));

  // Perform tasks after waking up
  Serial.println("Arduino woke up!");

  while (mySerial.available() >= Rfid134_Packet_SIZE) {
    Serial.println("Working");
    char packet[Rfid134_Packet_SIZE];

    packet[Rfid134_Packet_StartCode] = mySerial.read();

    //check for the first byte being the packet start code
    if (packet[Rfid134_Packet_StartCode] != 0x02) {
      Serial.println("Rfid134_Error_None");
    }

    uint8_t read;

    read = mySerial.readBytes(&(packet[Rfid134_Packet_Id]), Rfid134_Packet_SIZE - 1);

    if (read != Rfid134_Packet_SIZE - 1) {
      Serial.println("Rfid134_Error_PacketSize");
    }

    if (packet[Rfid134_Packet_EndCode] != 0x03 && packet[Rfid134_Packet_EndCode] != 0x07) {
      Serial.println("Rfid134_Error_PacketEndCodeMissmatch");
    }

    // calculate checksum
    uint8_t checksum = 0;
    for (uint8_t i = Rfid134_Packet_Id; i < Rfid134_Packet_CheckSum; i++) {
      checksum = checksum ^ packet[i];
    }

    // test checksum
    if (checksum != packet[Rfid134_Packet_CheckSum]) {
      Serial.println("Rfid134_Error_PacketChecksum");
    }

    if (static_cast<uint8_t>(~checksum) != static_cast<uint8_t>(packet[Rfid134_Packet_CheckSumInvert])) {
      Serial.println("Rfid134_Error_PacketChecksumInvert");
    }

    Rfid134Reading reading;

    // convert packet into the reading struct
    reading.id = HexLsbAsciiToUint64(&(packet[Rfid134_Packet_Id]), Rfid134_Packet_Country - Rfid134_Packet_Id);
    reading.country = HexLsbAsciiToUint64(&(packet[Rfid134_Packet_Country]), Rfid134_Packet_DataFlag - Rfid134_Packet_Country);
    reading.isData = packet[Rfid134_Packet_DataFlag] == '1';
    reading.isAnimal = packet[Rfid134_Packet_AnimalFlag] == '1';
    reading.reserved0 = HexLsbAsciiToUint64(&(packet[Rfid134_Packet_Reserved0]), Rfid134_Packet_Reserved1 - Rfid134_Packet_Reserved0);
    reading.reserved1 = HexLsbAsciiToUint64(&(packet[Rfid134_Packet_Reserved1]), Rfid134_Packet_CheckSum - Rfid134_Packet_Reserved1);
    print_uint64_t(reading.id);
  }

  // Prepare to sleep again by enabling sleep mode and attaching the interrupt
  sleep_enable();
  attachInterrupt(digitalPinToInterrupt(rxPin), wakeUp, LOW);
}

// Interrupt service routine to wake up the Arduino
void wakeUp() {
}


void print_uint64_t(uint64_t num) {

  char rev[128]; 
  char *p = rev+1;

  while (num > 0) {
    *p++ = '0' + ( num % 10);
    num/= 10;
  }
  p--;
  /*Print the number which is now in reverse*/
  while (p > rev) {
    Serial.print(*p--);
  }
  Serial.println();
}

Example

I tried to compile the example provided for software serial and gives me error.

Error

Get get following error

error: 'Serial1' was not declared in this scope
Rfid134<HardwareSerial, RfidNotify> rfid(Serial1);

how can I fix this?

execute Wl134 with independent power supply

Hello
The project I am currently executing will use arduino pro with WL134 to read animal tags and transmit them through LORA. A problem I encountered is that when the MCU is connected to the computer to see the reception of the com port, the performance of WL134 is quite stable, but when I remove the computer. driven by an external power supply of 9V only, the performance of WL134 is very bad. I can't read any tags. I have confirmed that arduino and WL134 share ground with each other.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.