Showing posts with label m5stickC. Show all posts
Showing posts with label m5stickC. Show all posts

Wednesday, 16 February 2022

M5StickC (RF) Remote Control decoder

When tinkering with 433 Mhz RF appliance switches it's handy to easily check what codes they respond to. This is a simple decoder using the RCswitch library

 
#include <M5StickC.h>
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

int x=0;
int y=4; 
void setup() {
   M5.begin();
   M5.Lcd.setRotation(3);
   Serial.begin(115200); 
   mySwitch.enableReceive(0); 
    //labelled G0 on the "HAT" end of the M5StickC 
}

void loop() {
  if (mySwitch.available()) {
   
    Serial.print("Code ");
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(" / ");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.println(mySwitch.getReceivedProtocol() );
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(",");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print(",");
    Serial.println( mySwitch.getReceivedProtocol() );
 
    M5.Lcd.fillScreen(TFT_BLACK);
    M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK);   
    M5.Lcd.setCursor(x, y, 2);
    M5.Lcd.setTextSize(1);
    M5.Lcd.print("Code ");
    M5.Lcd.print( String(mySwitch.getReceivedValue()) );
    M5.Lcd.print(" / ");
    M5.Lcd.print( String(mySwitch.getReceivedBitlength()) );
    M5.Lcd.println("bit ");
    M5.Lcd.print("Protocol: ");
    M5.Lcd.println( String(mySwitch.getReceivedProtocol()) );
    mySwitch.resetAvailable();
     
   } //if mySwitch
}//loop 
 

 

Friday, 27 December 2019

M5StickC with ENV Unit

I ordered the Grove version of the M5 ENV module instead of the HAT version by mistake so the M5StickC ENV.ino example did not work out of the box.   

The Wire.begin() needs to be told to use the GROVE pins G32 and G33 as SDA/SCL :  


Wire.begin(32,33,100000); //SDA, SCL 





Later...
The github entry for the example was updated 3 months ago, so my local copies are out of date, that will teach me :-(