Assistance Request: M5Core2 and 4-Relay Unit
-
Good morning! I am trying to perform a simple test by flashing the LEDs and cycling the relays on a 4-relay unit board, and for some reason, the magic isn't happening, below is my code:
#include <M5Core2.h> #include "Unit_4RELAY.h" UNIT_4RELAY relay; void setup() { // Init M5Core2 And the I2C port(21,22). M5.begin(true,false,true,true); // Draw screen M5.Lcd.setCursor(0, 10); M5.lcd.setTextSize(2); M5.lcd.setTextColor(GREEN); M5.Lcd.printf("Hello World!"); // Relay relay.Init(1); } void loop() { relay.relayAll(1); relay.ledAll(1); delay(2500); relay.relayAll(0); relay.ledAll(0); }Any reason as to why this wouldn't work? The device is plugged into Port A on the M5Core2. Additionally, using wire scan, I am able to detect the device successfully on the I2C bus. I based my code off of this:
Additionally, this is the specific module I am using:
https://shop.m5stack.com/products/4-relay-unit
Thanks in advance!
-
Hello @wanderingchimp
the example is missing a
relay.begin()call before therelay.init(). I've created a PR for that.Also for me it only works if I call
relayAll()only. If I call bothrelayAll()andledAll()as in your example it doesn't work for me.Thanks
Felix -
Thanks for the help! I've got it working now :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login