Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Sending data from WiFi module to Teensy, looking for I2C alternatives

  1. #1
    Junior Member
    Join Date
    May 2022

    Sending data from WiFi module to Teensy, looking for I2C alternatives

    Hi all!

    New to the Teensy world, I am using Teensyduino 1.56 on MAC OSX Monterey.

    I have a Node MCU V0.9 ESP8266 which connects as a client to my phone's hotspot. I use it to read the RSSI value (signal strength) of the connection and map this value to a new range (0-255).

    I want to send that value every 200 millis to my Teensy board (Teensy 3.2), read it and use it to modulate the frequency of waveform 1.

    What i tried: I set up an I2C communication where the NODE MCU is a Master - Sender and the Teensy is the Slave - Receiver.

    That works, however, I get no sound coming out while the I2C is running. Seems like the I2C blocks my void loop() and is not the appropriate method to achieve this. I am therefore looking for another way to send this value.

    What could work? I read that PWM is too eratic (
    Could this be done using software Serial? I am not sure to understand how this works...

    My code below
    /CODE FOR THE NODE MCU = NODE MCU is a Master - Sender
    //CODE FOR THE NODE MCU = NODE MCU is a Master - Sender
    #include <ESP8266WiFi.h>
    #include <Wire.h>
    const byte SlaveDeviceId = 1;
    void setup() {
      pinMode(LED, OUTPUT);
      pinMode(SIG, OUTPUT);
      pinMode(ON, OUTPUT);
      digitalWrite(ON, HIGH);
      WiFi.begin("SSID", "pw");  // Try to connect to a given WiFi network
    void loop() {
      int map_sig = dbmtoper();
      int input = map_sig;
      // Send two bytes to slave.
      Wire.write(input >> 8);
      Wire.write(input & 255);
    void printWiFiState() {
      static boolean printed = false;
      if (WiFi.status() == WL_CONNECTED) {
        if (printed)
        printed = true;
      } else {  // if WiFi is not connected
        if (!printed)
        printed = false;
    int dbmtoper() {
      int best_rssi = -20;
      int worst_rssi = -70;
      if (WiFi.status() != WL_CONNECTED)
        return 0;
      int dBm = WiFi.RSSI();
      // Serial.println(dBm);
      if (dBm <= worst_rssi)
        return 0;
      if (dBm >= best_rssi)
        return 255;
      return map(dBm, worst_rssi, best_rssi, 0, 255);
    Below is the code on my Teensy 3.2
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    // GUItool: begin automatically generated code
    AudioSynthWaveform       waveform1;      //xy=186,238
    AudioOutputAnalog        dac1;           //xy=523,243
    AudioConnection          patchCord1(waveform1, dac1);
    const byte SlaveDeviceId = 1;
    int receivedValue; 
    void setup() {
      // Audio connections require memory to work.  For more
      // detailed information, see the MemoryAndCpuUsage example
      waveform1.begin(0.1, 440, WAVEFORM_SINE);
       // Start IC bus as a slave
    void loop() {
      int freq = map(receivedValue, 0, 255, 100, 500);
      waveform1.frequency (freq);
    // aCount is the number of bytes received.
    void receiveCallback(int aCount)
      if(aCount == 2)
        receivedValue  = << 8; 
        receivedValue |=;
        Serial.print("Unexpected number of bytes received: ");

    Thank you for your help!
    Last edited by VerMaR; 05-14-2022 at 01:29 PM. Reason: forgot legend

  2. #2
    Wire I think only deals with masters, so you have two masters there. I think it's pretty hard to get Teensy to run as a slave without getting into some deep code. For something like this, it sounds like a serial connection would be better. I may be wrong.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts