• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

si4703 fm и nodemcu

teliy

New member
Всем привет, прошу помощи в подключении si4703 fm и nodemcu

Есть скетч
Но в ушах тишина.
Подкючаю пины к плате как в скетче.

Код:
#include <Wire.h>

#define SI4703_ADDR 0x10
#define RST D7
#define SDIO D3
#define SCL D4

void setup() {
  Serial.begin(115200);
  delay(20);
  Serial.println();
  pinMode(RST, OUTPUT);
  pinMode(SDIO, OUTPUT);
  digitalWrite(SDIO, LOW);
  digitalWrite(RST, LOW);
  delay(1);
  digitalWrite(RST, HIGH);
  delay(1); // Above sets up Si4703 as I2C and resets it

  Wire.begin(SDIO, SCL);

  uint8_t res = Wire.requestFrom(SI4703_ADDR, 32);
  //We want to read the entire register set from 0x0A to 0x09 = 32 bytes.
  Serial.print("requestFrom result code: ");
  Serial.println(res);
  if (res != 32)
    Serial.println("Mismatch detected");

  Serial.println("Spinning on available == 32");
  while(Wire.available() < 32) ; //Wait for 16 words/32 bytes to come back from Si4703
  Serial.println("Finished spinning");

  uint16_t registers[16];
  //Remember, register 0x0A comes in first so we have to shuffle the array around a bit
  for(int x = 0x0A ; ; x++) { //Read in these 32 bytes
    if(x == 0x10) x = 0; //Loop back to zero
    registers[x] = read16();
    if(x == 0x09) break; //We're done!
  }
}

uint16_t read16() {
  uint8_t hiByte = Wire.read();
  uint8_t loByte = Wire.read();
  return((hiByte << 8) + loByte);
}

void loop() {

}
 

teliy

New member
Терминал пишет
requestFrom result code: 0
Mismatch detected
Spinning on available == 32

Есть еще такой код
В библиотеке ыш4703.cpp меняю #define SDIO A4 на например D4 или A0. Но все не удачно.
Код:
///
/// \file  TestSI4703.ino
/// \brief An Arduino sketch to operate a SI4703 chip based radio using the Radio library.
///
/// \author Matthias Hertel, http://www.mathertel.de
/// \copyright Copyright (c) 2014 by Matthias Hertel.\n
/// This work is licensed under a BSD style license.\n
/// See http://www.mathertel.de/License.aspx
///
/// \details
/// This sketch implements a "as simple as possible" radio without any possibility to modify the settings after initializing the chip.\n
/// The radio chip is initialized and setup to a fixed band and frequency. These settings can be changed by modifying the
/// FIX_BAND and FIX_STATION definitions.
///
/// Open the Serial console with 57600 baud to see the current radio information.
///
/// Wiring
/// ------
/// The SI4703 board has to be connected by using the following connections:
/// | Arduino UNO pin    | Radio chip signal  |
/// | -------------------| -------------------|
/// | 3.3V (red)         | VCC                |
/// | GND (black)        | GND                |
/// | A5 or SCL (yellow) | SCLK               |
/// | A4 or SDA (blue)   | SDIO               |
/// | D2 (white)         | RST                |
/// More documentation and source code is available at http://www.mathertel.de/Arduino
///
/// CHangeLog:
/// ----------
/// * 05.08.2014 created.
/// * 03.05.2015 corrections and documentation.

#include <Arduino.h>
#include <Wire.h>
#include <radio.h>
#include <si4703.h>

// ----- Fixed settings here. -----

#define FIX_BAND     RADIO_BAND_FM   ///< The band that will be tuned by this sketch is FM.
#define FIX_STATION  10370            ///< The station that will be tuned by this sketch is 89.30 MHz.
#define FIX_VOLUME   10               ///< The volume that will be set by this sketch is level 4.

SI4703 radio;    // Create an instance of Class for Si4703 Chip

/// Setup a FM only radio configuration
/// with some debugging on the Serial port
void setup() {
  // open the Serial port
  Serial.begin(115200);
  Serial.println("Radio...");
  delay(200);

  // Enable information to the Serial port
  radio.debugEnable();

  // Initialize the Radio
  radio.init();

  // Set all radio setting to the fixed values.
  radio.setBandFrequency(FIX_BAND, FIX_STATION);
  radio.setVolume(FIX_VOLUME);
  radio.setMono(false);
  radio.setMute(false);
} // setup


/// show the current chip data every 3 seconds.
void loop() {
  char s[12];
  radio.formatFrequency(s, sizeof(s));
  Serial.print("Station:");
  Serial.println(s);
 
  Serial.print("Radio:");
  radio.debugRadioInfo();
 
  Serial.print("Audio:");
  radio.debugAudioInfo();

  delay(3000);
} // loop

// End.
 

CodeNameHawk

Moderator
Команда форума
Где вы в есп нашли D7 ?
Резисторы подтягивающие подключили? Покажите электрическую схему подключения.

В библиотеке ыш4703.cpp меняю #define SDIO A4 на например D4 или A0. Но все не удачно.
Где вы в есп это нашли....

В примере для ардуиноуно подключают библиотеку #include <si4703.h>, для есп она может не подойти.
 
Сверху Снизу