As a university project, we created a code that tags an nfc card and weighs it, then sends it to Bluetooth without connecting it to a laptop and a port and outputs it to putty. But nothing is output on putty. What's the problem? The red light says Bluetooth connected comes out normally, but the TX RX doesn't light up
Below is the full text of our code.
#include <Wire.h>
#include <Adafruit_PN532.h>
#include "HX711.h"
#include <SoftwareSerial.h>
#define PN532_IRQ (2)
#define PN532_RESET (3)
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
#define calibration_factor -7050.0
const int DOUT = 4;
const int CLK = 5;
HX711 scale;
SoftwareSerial bluetooth(6, 7); // RX, TX (HC-06 module)
void setup(void) {
Serial.begin(9600);
nfc.begin();
scale.begin(DOUT, CLK);
scale.set_scale(calibration_factor);
scale.tare();
bluetooth.begin(9600);
uint32_t versiondata = nfc.getFirmwareVersion();
if (!versiondata) {
bluetooth.println("Didn't find PN53x board");
} else {
bluetooth.print("Found chip PN5");
bluetooth.println((versiondata >> 24) & 0xFF, HEX);
bluetooth.print("Firmware ver. ");
bluetooth.print((versiondata >> 16) & 0xFF, DEC);
bluetooth.print('.');
bluetooth.println((versiondata >> 8) & 0xFF, DEC);
}
nfc.SAMConfig();
bluetooth.println("Waiting for an ISO14443A Card ...");
}
void loop(void) {
bluetooth.println("Found");
uint8_t success;
uint8_t uid[] = {0, 0, 0, 0, 0, 0, 0};
uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
bluetooth.println("Found an ISO14443A card");
bluetooth.print("UID Length: ");
bluetooth.print(uidLength, DEC);
bluetooth.println(" bytes");
bluetooth.print("UID Value: ");
for (uint8_t i = 0; i < uidLength; i++) {
bluetooth.print(uid[i], HEX);
bluetooth.print(" ");
}
bluetooth.println();
if (uidLength == 4) {
bluetooth.println("Seems to be a Mifare Classic card (4 byte UID)");
uint8_t keya[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
}
float weight_kg = scale.get_units(1);
bluetooth.print("UID: ");
for (uint8_t i = 0; i < uidLength; i++) {
bluetooth.print(uid[i], HEX);
bluetooth.print(" ");
}
bluetooth.print("Weight: ");
bluetooth.print(weight_kg, 1);
bluetooth.println(" kg");
} else {
bluetooth.println("NFC tag not found.");
}
}
I think we made a mistake with Arduino's connection somewhere, right? when I compile the code no error occur