VFO-ESP32-Si5351
VFO-ESP32-Si5351 copied to clipboard
Simple test for beginner with ESP32 and si5351 (with a M5StackStickCplus)
Sorry to bother, but it seems you are one of the few that got the ESP32 and the si5351 working nicely. After downloading and looking at your code, I was trying to find out how to simply the code for my M5StackStickCplus to work. But I could not figure that out.to get the I2C working on pin G26 (SCL) and pin G0(SDA).
Please advise me how to make a simple .ino file with the modified libraries you made (Ii2c.h and si5351.h)
Regards, Rob Oudendijk
Hello Rob,
This repository is a bit older and the solution I used was to implement my own simple I2C functions. If you create the SI5351 class you can specify the SCL and SDA pins. Si5351::Si5351(uint8_t i2c_addr, uint8_t i2c_sda, uint8_t i2c_scl). In the file IO.CPP you can see the definition for the ports.
------------------------------------------------------- Si5351 --------------------------------------------------------/
#define I2C_SDA2 16 #define I2C_SCL2 17 #define SI5351_XTAL_FREQ1 SI5351_XTAL_FREQ //25 mhz //#define SI5351_XTAL_FREQ1 32000000
#define CLK_BFO_RX SI5351_CLK2 #define CLK_VFO_RX SI5351_CLK2 #define CLK_BFO_TX SI5351_CLK0 #define CLK_VFO_TX SI5351_CLK0 #define CLK_NA SI5351_CLK1
Si5351 si5351; Si5351 si5351_bfo(SI5351_BUS_BASE_ADDR, I2C_SDA2, I2C_SCL2);
In the meantime there is a fix for the SI5351 library (https://github.com/etherkit/Si5351Arduino) but the maintainer did not implement it. You have to change the SI5351::si5351_read method
Change Wire.requestFrom(i2c_bus_addr, (uint8_t)1, (uint8_t)false);
to Wire.requestFrom(i2c_bus_addr, (uint8_t)1); //, (uint8_t)false);
Than you can use the original library
Whooo, thank you so much for the fast reply. I will check tomorrow and report back to you.
Warm regards, Rob Oudendijk
Paul,
Just before going to bed. Tried the modifications you mentioned. Worked great!! Now very simple code.
/*
- Copyright (c) 2022 YR-Design
- Visit for more information:
- https://docs.m5stack.com/en/core/m5stickc_plus
- I2C modified code from https://github.com/paulh002/VFO-ESP32-Si5351
- Describe: Display and Si5351 setup test
- Date: 2022/12/20
*/ #include "M5StickCPlus.h" #include "si5351.h" #include <Wire.h>
Si5351 si5351;
void setup() { bool i2c_found; // Start serial and initialize the Si5351 Serial.begin(9600); i2c_found = si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
M5.begin(); // Lcd display M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(10, 10); M5.Lcd.setTextColor(WHITE); M5.Lcd.setTextSize(2); M5.Lcd.setRotation(3); delay(500);
//Check I2C if(!i2c_found) { M5.Lcd.setTextColor(RED); M5.Lcd.println("Error on I2C bus!"); } else { M5.Lcd.println("si5351 on I2C bus!"); }
delay(1000); // text print M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(10, 10); M5.Lcd.setTextColor(WHITE); M5.Lcd.setTextSize(2); M5.Lcd.setRotation(3); M5.Lcd.println("Si5351 test"); M5.Lcd.println();
// Set CLK0 to output 27.12 MHz si5351.set_freq(2712000000ULL, SI5351_CLK0); M5.Lcd.println(" CLK0 =27.12MHz");
}
void loop() {
}
Output from si5351 with new code at 27.12MHz
Great that it works!
And here the M5StickCPlus and the Si5351.