Couldn't find any packages in ["react-redux#7.2.5"] on jsdelivr - ruby-on-rails-7

I am migrating an already existing Rails/React app from webpacker to Rails7/importmaps/jsbundling-rails.
As I am pining the dependent node packages I receive these:
Couldn't find any packages in ["redux-form#8.3.7"] on jsdelivr
~/p/r/h/ReactBikes rails-7-impo…s-jsbundling ❯ ./bin/importmap pin reactstrap#8.10.0 --from jsdelivr
Couldn't find any packages in ["reactstrap#8.10.0"] on jsdelivr
~/p/r/h/ReactBikes rails-7-impo…s-jsbundling ❯ ./bin/importmap pin react-redux#7.2.5 --from jsdelivr
Couldn't find any packages in ["react-redux#7.2.5"] on jsdelivr
~/p/r/h/ReactBikes rails-7-impo…s-jsbundling ❯
However on jsdeliver the packages with the given version exists:
https://www.jsdelivr.com/package/npm/reactstrap?version=8.10.0
https://www.jsdelivr.com/package/npm/redux-form?version=8.3.7
https://www.jsdelivr.com/package/npm/react-redux?version=7.2.5
This is my importmap.rb file:
# Pin npm packages by running ./bin/importmap
pin "application", to:"/assets/application.js", preload: true
pin "axios", to: "https://cdn.jsdelivr.net/npm/axios#0.22.0/index.js"
pin "bootstrap", to: "https://cdn.jsdelivr.net/npm/bootstrap#5.1.2/dist/js/bootstrap.esm.js"
pin "#popperjs/core", to: "https://cdn.jsdelivr.net/npm/#popperjs/core#2.11.6/lib/index.js"
pin "prop-types", to: "https://cdn.jsdelivr.net/npm/prop-types#15.8.1/index.js"
pin "react", to: "https://cdn.jsdelivr.net/npm/react#17.0.2/index.js"
pin "react-day-picker", to: "https://cdn.jsdelivr.net/npm/react-day-picker#7.4.10/lib/react-day-picker.min.js"
pin "react-dom", to: "https://cdn.jsdelivr.net/npm/react-dom#17.0.2/index.js"
pin "react-google-maps", to: "https://cdn.jsdelivr.net/npm/react-google-maps#9.4.5/lib/index.js"
pin "react-hot-loader", to: "https://cdn.jsdelivr.net/npm/react-hot-loader#4.13.0/index.js"
pin "react-rater", to: "https://cdn.jsdelivr.net/npm/react-rater#5.1.1/lib/index.js"
pin "react-router-dom", to: "https://cdn.jsdelivr.net/npm/react-router-dom#5.3.0/esm/react-router-dom.js"
pin "#babel/runtime/helpers/esm/extends", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/extends.js"
pin "#babel/runtime/helpers/esm/inheritsLoose", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/inheritsLoose.js"
pin "#babel/runtime/helpers/esm/objectWithoutPropertiesLoose", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/objectWithoutPropertiesLoose.js"
pin "history", to: "https://cdn.jsdelivr.net/npm/history#4.10.1/esm/history.js"
pin "hoist-non-react-statics", to: "https://cdn.jsdelivr.net/npm/hoist-non-react-statics#3.3.2/dist/hoist-non-react-statics.cjs.js"
pin "mini-create-react-context", to: "https://cdn.jsdelivr.net/npm/mini-create-react-context#0.4.1/dist/esm/index.js"
pin "path-to-regexp", to: "https://cdn.jsdelivr.net/npm/path-to-regexp#1.8.0/index.js"
pin "react-is", to: "https://cdn.jsdelivr.net/npm/react-is#16.13.1/index.js"
pin "react-router", to: "https://cdn.jsdelivr.net/npm/react-router#5.2.1/esm/react-router.js"
pin "resolve-pathname", to: "https://cdn.jsdelivr.net/npm/resolve-pathname#3.0.0/esm/resolve-pathname.js"
pin "tiny-invariant", to: "https://cdn.jsdelivr.net/npm/tiny-invariant#1.2.0/dist/tiny-invariant.esm.js"
pin "tiny-warning", to: "https://cdn.jsdelivr.net/npm/tiny-warning#1.0.3/dist/tiny-warning.esm.js"
pin "value-equal", to: "https://cdn.jsdelivr.net/npm/value-equal#1.0.1/esm/value-equal.js"
pin "react-select", to: "https://cdn.jsdelivr.net/npm/react-select#5.1.0/dist/react-select.esm.js"
pin "#babel/runtime/helpers/defineProperty", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/defineProperty.js"
pin "#babel/runtime/helpers/esm/classCallCheck", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/classCallCheck.js"
pin "#babel/runtime/helpers/esm/createClass", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/createClass.js"
pin "#babel/runtime/helpers/esm/defineProperty", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/defineProperty.js"
pin "#babel/runtime/helpers/esm/inherits", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/inherits.js"
pin "#babel/runtime/helpers/esm/objectWithoutProperties", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/objectWithoutProperties.js"
pin "#babel/runtime/helpers/esm/slicedToArray", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/slicedToArray.js"
pin "#babel/runtime/helpers/esm/taggedTemplateLiteral", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/taggedTemplateLiteral.js"
pin "#babel/runtime/helpers/esm/toConsumableArray", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/toConsumableArray.js"
pin "#babel/runtime/helpers/esm/typeof", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/typeof.js"
pin "#babel/runtime/helpers/extends", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/extends.js"
pin "#babel/runtime/helpers/objectWithoutProperties", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/objectWithoutProperties.js"
pin "#babel/runtime/helpers/slicedToArray", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/slicedToArray.js"
pin "#babel/runtime/helpers/taggedTemplateLiteral", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/taggedTemplateLiteral.js"
pin "#babel/runtime/helpers/toConsumableArray", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/toConsumableArray.js"
pin "#babel/runtime/helpers/typeof", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/typeof.js"
pin "#emotion/cache", to: "https://cdn.jsdelivr.net/npm/#emotion/cache#11.10.1/dist/emotion-cache.browser.esm.js"
pin "#emotion/hash", to: "https://cdn.jsdelivr.net/npm/#emotion/hash#0.9.0/dist/emotion-hash.esm.js"
pin "#emotion/memoize", to: "https://cdn.jsdelivr.net/npm/#emotion/memoize#0.8.0/dist/emotion-memoize.esm.js"
pin "#emotion/react", to: "https://cdn.jsdelivr.net/npm/#emotion/react#11.10.0/dist/emotion-react.browser.esm.js"
pin "#emotion/serialize", to: "https://cdn.jsdelivr.net/npm/#emotion/serialize#1.1.0/dist/emotion-serialize.browser.esm.js"
pin "#emotion/sheet", to: "https://cdn.jsdelivr.net/npm/#emotion/sheet#1.2.0/dist/emotion-sheet.browser.esm.js"
pin "#emotion/unitless", to: "https://cdn.jsdelivr.net/npm/#emotion/unitless#0.8.0/dist/emotion-unitless.esm.js"
pin "#emotion/utils", to: "https://cdn.jsdelivr.net/npm/#emotion/utils#1.2.0/dist/emotion-utils.browser.esm.js"
pin "#emotion/weak-memoize", to: "https://cdn.jsdelivr.net/npm/#emotion/weak-memoize#0.3.0/dist/emotion-weak-memoize.esm.js"
pin "memoize-one", to: "https://cdn.jsdelivr.net/npm/memoize-one#5.2.1/dist/memoize-one.esm.js"
pin "stylis", to: "https://cdn.jsdelivr.net/npm/stylis#4.0.13/index.js"
pin "react-select2-wrapper", to: "https://cdn.jsdelivr.net/npm/react-select2-wrapper#1.0.4-beta6/lib/components/Select2.js"
pin "react-spinners", to: "https://cdn.jsdelivr.net/npm/react-spinners#0.11.0/index.js"
pin "-", to: "https://cdn.jsdelivr.net/npm/-#0.0.1/dist/index.js"
pin "react-toggle", to: "https://cdn.jsdelivr.net/npm/react-toggle#4.1.2/dist/component/index.js"
pin "redux", to: "https://cdn.jsdelivr.net/npm/redux#4.1.1/es/redux.js"
pin "#babel/runtime/helpers/esm/objectSpread2", to: "https://cdn.jsdelivr.net/npm/#babel/runtime#7.18.9/helpers/esm/objectSpread2.js"
pin "redux-react-session", to: "https://cdn.jsdelivr.net/npm/redux-react-session#2.6.1/dist/index.js"
pin "redux-thunk", to: "https://cdn.jsdelivr.net/npm/redux-thunk#2.3.0/es/index.js"
pin "title-case", to: "https://cdn.jsdelivr.net/npm/title-case#3.0.3/dist.es2015/index.js"
Why the importmap states that the redux-form#8.3.7 "reactstrap#8.10.0 and react-redux#7.2.5 couldn't be found on jsdeliver if they are there?

Related

JS package not working with Rails 7 importmap

I have a Rails 7 app that is trying to use the #walletconnect/web3-provider npm package. After running ./bin/importmap pin #walletconnect/web3-provider#1.7.5, a bunch of JS modules get pinned in importmap.rb:
pin "#walletconnect/web3-provider", to: "https://ga.jspm.io/npm:#walletconnect/web3-provider#1.7.5/dist/esm/index.js"
pin "#walletconnect/browser-utils", to: "https://ga.jspm.io/npm:#walletconnect/browser-utils#1.7.8/dist/esm/index.js"
pin "#walletconnect/client", to: "https://ga.jspm.io/npm:#walletconnect/client#1.7.8/dist/esm/index.js"
pin "#walletconnect/core", to: "https://ga.jspm.io/npm:#walletconnect/core#1.7.8/dist/esm/index.js"
pin "#walletconnect/crypto", to: "https://ga.jspm.io/npm:#walletconnect/crypto#1.0.2/dist/esm/browser/index.js"
pin "#walletconnect/encoding", to: "https://ga.jspm.io/npm:#walletconnect/encoding#1.0.1/dist/esm/index.js"
pin "#walletconnect/environment", to: "https://ga.jspm.io/npm:#walletconnect/environment#1.0.0/dist/cjs/index.js"
pin "#walletconnect/http-connection", to: "https://ga.jspm.io/npm:#walletconnect/http-connection#1.7.8/dist/esm/index.js"
pin "#walletconnect/iso-crypto", to: "https://ga.jspm.io/npm:#walletconnect/iso-crypto#1.7.8/dist/esm/index.js"
pin "#walletconnect/jsonrpc-types", to: "https://ga.jspm.io/npm:#walletconnect/jsonrpc-types#1.0.1/dist/esm/index.js"
pin "#walletconnect/jsonrpc-utils", to: "https://ga.jspm.io/npm:#walletconnect/jsonrpc-utils#1.0.3/dist/esm/index.js"
pin "#walletconnect/qrcode-modal", to: "https://ga.jspm.io/npm:#walletconnect/qrcode-modal#1.7.8/dist/cjs/index.js"
pin "#walletconnect/randombytes", to: "https://ga.jspm.io/npm:#walletconnect/randombytes#1.0.2/dist/esm/browser/index.js"
pin "#walletconnect/safe-json", to: "https://ga.jspm.io/npm:#walletconnect/safe-json#1.0.0/dist/esm/index.js"
pin "#walletconnect/socket-transport", to: "https://ga.jspm.io/npm:#walletconnect/socket-transport#1.7.8/dist/esm/index.js"
pin "#walletconnect/utils", to: "https://ga.jspm.io/npm:#walletconnect/utils#1.7.8/dist/esm/index.js"
pin "#walletconnect/window-getters", to: "https://ga.jspm.io/npm:#walletconnect/window-getters#1.0.0/dist/cjs/index.js"
pin "#walletconnect/window-metadata", to: "https://ga.jspm.io/npm:#walletconnect/window-metadata#1.0.0/dist/cjs/index.js"
pin "bn.js", to: "https://ga.jspm.io/npm:bn.js#4.11.8/lib/bn.js"
pin "buffer", to: "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.24/nodelibs/browser/buffer.js"
pin "cookiejar", to: "https://ga.jspm.io/npm:cookiejar#2.1.3/cookiejar.js"
pin "copy-to-clipboard", to: "https://ga.jspm.io/npm:copy-to-clipboard#3.3.1/index.js"
pin "decode-uri-component", to: "https://ga.jspm.io/npm:decode-uri-component#0.2.0/index.js"
pin "detect-browser", to: "https://ga.jspm.io/npm:detect-browser#5.2.0/index.js"
pin "dijkstrajs", to: "https://ga.jspm.io/npm:dijkstrajs#1.0.2/dijkstra.js"
pin "eventemitter3", to: "https://ga.jspm.io/npm:eventemitter3#4.0.7/index.js"
pin "http", to: "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.24/nodelibs/browser/http.js"
pin "https", to: "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.24/nodelibs/browser/https.js"
pin "is-typedarray", to: "https://ga.jspm.io/npm:is-typedarray#1.0.0/index.js"
pin "isarray", to: "https://ga.jspm.io/npm:isarray#2.0.5/index.js"
pin "js-sha3", to: "https://ga.jspm.io/npm:js-sha3#0.8.0/src/sha3.js"
pin "os", to: "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.24/nodelibs/browser/os.js"
pin "preact", to: "https://ga.jspm.io/npm:preact#10.4.1/dist/preact.module.js"
pin "preact/compat", to: "https://ga.jspm.io/npm:preact#10.4.1/compat/dist/compat.module.js"
pin "preact/hooks", to: "https://ga.jspm.io/npm:preact#10.4.1/hooks/dist/hooks.module.js"
pin "process", to: "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.24/nodelibs/browser/process-production.js"
pin "qrcode", to: "https://ga.jspm.io/npm:qrcode#1.4.4/lib/browser.js"
pin "qrcode/lib/utils/buffer.js", to: "https://ga.jspm.io/npm:qrcode#1.4.4/lib/utils/typedarray-buffer.js"
pin "query-string", to: "https://ga.jspm.io/npm:query-string#6.13.5/index.js"
pin "split-on-first", to: "https://ga.jspm.io/npm:split-on-first#1.1.0/index.js"
pin "strict-uri-encode", to: "https://ga.jspm.io/npm:strict-uri-encode#2.0.0/index.js"
pin "toggle-selection", to: "https://ga.jspm.io/npm:toggle-selection#1.0.6/index.js"
pin "typedarray-to-buffer", to: "https://ga.jspm.io/npm:typedarray-to-buffer#3.1.5/index.js"
pin "url", to: "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.24/nodelibs/browser/url.js"
pin "xhr2-cookies", to: "https://ga.jspm.io/npm:xhr2-cookies#1.1.0/dist/index.js"
I import the package in application.js:
import "#walletconnect/web3-provider"
And then I try to import a specific module in my custom JS file (which is also imported in application.js):
import WalletConnectProvider from "#walletconnect/web3-provider";
When I start the server and visit the site in the browser, it shows following error:
Uncaught SyntaxError: The requested module 'js-sha3' does not provide an export named 'keccak_256' (at index.js:1:189)
I don't understand why this error is happening. When I look at the js-sha3 repo, I see that keccak_256 is exported here. So, why is this error happening?
Thanks!
What you linked to is a TS type definition. It has no runtime effect. It's just there for type hints in your editor.
That package is only distributed as CJS -- there are no exports, and you cannot use it without a bundler. Using it directly in the browser (as you attempt to) will not work.

Arduino communication with TMC2209

I'm trying to communicate with TMC2209 (stepper drive) with an Arduino nano Every.
I connected pin RX on pin D2 and TX on pin D3.
I placed a 1K resistor between TX and RX.
It seems I can write parameters (even I'm testing this deeply, I'm not so sure now..) but I'm not able
to read nothing from driver.
Picture added 15/04/2021 related to datasheet of TMC2209
In my test, I tried with only one driver with address 0, means MS1_AD0 and MS2_AD1 connected to GND.
driver1.microsteps(MICROSTEPS);
SerialPort.print("Counter1=");
SerialPort.print(driver1.IFCNT());
SerialPort.print(", Status=");
SerialPort.println(driver1.DRV_STATUS());
I tried reading IFCNT and DRV_STATUS, always ZERO.
The initialization is done in this way:
#include <Wire.h>
#include <AG_AS5600.h>
#include <TMCStepper.h>
#include <AccelStepper.h>
#define ENCODER false
#define FEEDBACK_I2C true
#define GEARBOX 139 //51
#define MICROSTEPS 16
#define MIN_SPEED 20
#define MAX_SPEED 3000
double offsetHome = 77.0;
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SerialPort SerialUSB
#define SYS_VOL 3.3
#else
#define SerialPort Serial
#define SYS_VOL 5
#endif
#define SW_RX 2 // TMC2208/TMC2224 SoftwareSerial receive pin
#define SW_TX 3 // TMC2208/TMC2224 SoftwareSerial transmit pin
#define EN_PIN 7 // Enable
#define DIR_PIN 8 // Direction
#define STEP_PIN 9 // Step
#define SERIAL_PORT Serial1 // TMC2208/TMC2224 HardwareSerial port
#define DRIVER_ADDRESS1 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f // Match to your driver
// SilentStepStick series use 0.11
// UltiMachine Einsy and Archim2 boards use 0.2
// Panucatt BSD2660 uses 0.1
// Watterott TMC5160 uses 0.075
AG_AMS_5600 ams5600;
TMC2209Stepper driver1(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS1);
AccelStepper stepper = AccelStepper(stepper.DRIVER, STEP_PIN, DIR_PIN);
String cmd = {};
void setup()
{
SerialPort.begin(115200);
Wire.begin();
Wire.setTimeout(10);
SerialPort.println(">>>>>>>>>> Program started <<<<<<<<<<");
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH); // Enable driver in hardware
// Enable one according to your setup
SPI.begin(); // SPI drivers
driver1.beginSerial(115200); // SW UART drivers
driver1.begin(); // SPI: Init CS pins and possible SW SPI pins
// UART: Init SW UART (if selected) with default 115200 baudrate
driver1.toff(5); // Enables driver in software
driver1.rms_current(2000); // Set stepper current to 600mA. The command is the same as command TMC2130.setCurrent(600, 0.11, 0.5);
driver1.microsteps(MICROSTEPS);
driver1.pwm_autoscale(true); // Needed for stealthChop
stepper.setMaxSpeed(degToSteps(500.0)); // steps/s
stepper.setAcceleration(degToSteps(1.0)); // steps/s^2
stepper.setEnablePin(EN_PIN);
stepper.setPinsInverted(false, false, true);
stepper.disableOutputs();
}
void loop()
{
unsigned long t0 = micros();
switch (step) {
case 0:
cmd = SerialPort.readString();
if (cmd.charAt(0)=='a' && cmd.charAt(1)=='=') {
acc = degToSteps(cmd.substring(2).toDouble());
SerialPort.print("Acceleration=");
SerialPort.println(acc);
cmd = "";
}
else if (cmd.charAt(0)=='d' && cmd.charAt(1)=='=') {
dec = cmd.substring(2).toInt();
SerialPort.print("Deceleration=");
SerialPort.println(dec);
cmd = "";
}
else if (cmd.charAt(0)=='c' && cmd.charAt(1)=='?') {
driver1.microsteps(MICROSTEPS);
driver2.microsteps(MICROSTEPS);
SerialPort.print("Counter1=");
SerialPort.print(driver1.IFCNT());
SerialPort.print(", Counter2=");
SerialPort.print(driver2.IFCNT());
SerialPort.print(", Status=");
SerialPort.println(driver1.DRV_STATUS());
cmd = "";
}
}
The hardware should be ok because the jumper for UART is configured as default on pin4.
Can someone help me to understand why?
Thanks
Andrea
I found!
The issue was the handling of "software" serial port.
Unfortunately I was confused because many examples of "TMCstepper.h" library are shown using two pins as TX and RX, so I was convinced internally pins were handled to send and receive.. but it's not.
So solution I found is:
#include <SoftwareSerial.h>
SoftwareSerial SerialDriver1(SW_RX, SW_TX);
TMC2209Stepper driver1(&SerialDriver1, R_SENSE, DRIVER_ADDRESS1);
void setup()
{
SerialDriver1.begin(57600);
SerialDriver1.listen();
...
and was really important to comment:
//driver1.beginSerial(115200); // SW UART drivers
this is important I guess because the port was already opened in the setup by me.
and it's necessary to specify the software port where to listen, not done by TMC library.
Last hint, with Arduino Nano Every I found out that Software Serial seems to work with max baudrate of 57600, 115200 was not working.

OLED (I2C) and Micro SD card module not working together in Arduino

I am trying to write some data to SD card and read it back to serial monitor as well as display it to the OLED.
Both the SD card and OLED work separately but they seem to be interfering with each other when combined. I have used Arduino SD and Adafruit OLED libraries.
Connections from Arduino Uno to Micro SD card module:
5V to SD VCC
GND TO SD GND
PIN 10 TO SD Chip Select
PIN 11 TO SD MOSI
PIN 12 TO SD MISO
PIN 13 TO SD SCK
Connections to OLED:
3.3V to OLED VCC
GND TO OLED GND
A4 TO OLED SDA
A5 TO OLED SCK
Here is the code:
#include <SPI.h>
#include <SD.h>
File myFile;
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while(!Serial) {
;
}
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // CODE GETS STUCK HERE. DISPLAY NEVER INITIALISES
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(29,29);
display.print("INITIALISING");
display.display();
delay(5000);
if (!SD.begin(10)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
display.clearDisplay();
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
while (myFile.available()) {
Serial.write(myFile.read());
display.setCursor(0,0);
display.print(myFile.read());
display.display();
delay(5000);
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// put your main code here, to run repeatedly:
}
Code gets stuck at OLED initialization as mentiontioned above. If I replace these lines:
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // CODE GETS STUCK HERE. DISPLAY NEVER INITIALISES
}
To this:
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
I have run I2C scanner code on OLED so the address "0x3C" is correct.
The OLED still doesn't work and SD card initialises but Arduino is writing wrong data to TXT file on SD card like this:
teóting 1,à2, ó®
Instead of:
testing 1, 2, 3.
I have also tried using U8G2 library's sketches with SD card in case Arduino was running out of RAM but it still doesn't work. I have also changed SD chip select to Arduino digital pin 4 but still same results.
On browsing and experimenting more,I found MISO OR MOSI PIN of SD maybe interfering with SDA/SCL pins of OLED. Maybe wiring needs to change.
ANY SUGGESTIONS?
(I had the same issue) Just posting the suggestions of the comments as an answer, all credit to #gre_gor and #datafiddler for discovering this:
Both libraries together run out of RAM (main memory).
From my testing, the SD library might continue to work if it is initialized first in setup(). The solution is to use the U8G2 OLED driver, which is much more memory economic. The driver is also in the official Arduino library directive, so you can install and use it directly from the IDE.

DS1302 RTC board weird outputs on Arduino's Serial monitor

I have a DS1302 RTC board (Waveshare) connected to an Arduino uno.
I'm printing time to Arduino's Serial Monitor but I get weird numbers/characters, and after 2-4 seconds it stops printing.
Wiring:
Vcc -> 5v
GND -> GND
I/O (MISO) -> Pin 12
SCLK -> Pin 13
CE (CS) -> Pin 10
Library used: VirtuabotixRTC library.
Things I've tried so far:
I tried a second DS1302 RTC board.
I tried a different Arduino board.
I tried changing the jumper wires.
I tried different baud rates.
Code:
#include <virtuabotixRTC.h>
virtuabotixRTC myRTC(7,8,9);
void setup() {
Serial.begin(9600);
// myRTC.setDS1302Time(30,30,5,5,5,5,2020);
}
void loop() {
myRTC.updateTime();
Serial.print(myRTC.hours);
Serial.print(":");
Serial.print(myRTC.minutes);
Serial.print(":");
Serial.println(myRTC.seconds);
}
Screenshots:

Can't connect Arduino to RFID

I am using an A-Star 32U4 Micro Arduino and I'm trying to connect the RDM6300 - 125KHz Cardreader Mini-Module.
I'm using this sketch at the moment:
#include <SoftwareSerial.h>
// RFID | Nano
// Pin 1 | D2
// Pin 2 | D3
SoftwareSerial Rfid = SoftwareSerial(2,3);
void setup() {
// Serial Monitor to see results on the computer
Serial.begin(9600);
// Communication to the RFID reader
Rfid.begin(9600);
}
void loop() {
// check, if any data is available
if(Rfid.available() > 0 ){
// as long as there is data available...
while(Rfid.available() > 0 ){
// read a byte
int r = Rfid.read();
// print it to the serial monitor
Serial.print(r, DEC);
Serial.print(" ");
}
// linebreak
Serial.println();
}
}
With this circuit:
module TX --- Arduino pin 2
module VCC ----- 5v
module ground ---- ground
antenna pins ---- antenna
When I put the card in the sensor nothing shows up on serial port. I tried this setup and the exact same sensors on an Arduino Uno (same sketch) and it worked perfectly, but I cant get this working on the Micro.
Arduino UNO and Micro uses different processors, though they work fairly similarly, they are not totaly identical.
It seams that
not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
From the SoftwareSerial Library description ( https://www.arduino.cc/en/Reference/softwareSerial )
Change the module TX from pin 2 to pin 8. and you should be good. :-)

Resources