How to feed back digital signals from SDA (SC4) into Arduino Nano 33 iot DAC

I am using another device hooked up over i2c using the SDA and SCA pins of the Arduino Nano 33 iot and I would like to take those received digital signals and feed them through the DAC0 of the same Arduino board to convert it to analog.

Is this possible? If so, can anyone explain how?

Thank you

Mark

For what purpose are you converting it ?

You want to convert the bursts of 100 or 400KHz I2C clock and whatever the data is on SDA into an analog signal and read it?
I would buffer them, then use a low-pass filter to smooth the buffered signal into a DC-ish level and convert that.

mwk088:
I am using another device hooked up over i2c using the SDA and SCA pins of the Arduino Nano 33 iot and I would like to take those received digital signals and feed them through the DAC0 of the same Arduino board to convert it to analog.

I suspect there is some confusion is that description.

I can't see how it would make any sense to convert the pulses on the SDA or SDC pins into analog output. It would make more sense to convert the values that are received using I2C.

If you describe the project you are trying to create I suspect this confusion will go away.

...R

I would like to see digital signals as a voltage range instead. The device feeding the Arduino board with digital signals is a photosensor that varies as the brightness in the room changes. Instead of digital signals I would like to see the voltage analog equivalent and send that into a laptop audio jack and run it through some software.

I might not be going about what I want in the correct manner.

Read the digial data from the I2C bus and then send the data received to the dac .

What is the photosensor part number? Link to it’s datasheet?

My apologies. The photosensor is an Adafruit TSL2591.

What I did initially was with the adafruit hooked up to the SDA and SCL lines of the arduino, I then hooked a wire between the SDA and DAC0 pins.

In the code I did the following:
I set the DAC0 pin to output, and the SDA pin to input and set the analog write resolution to 10. I then do an analog write to the DAC0 pin.

I would like to verify that the signals are being converted, but i am struggling how to do this.

Maybe these other sensors would work better for my application?

mwk088:
In the code I did the following:
I set the DAC0 pin to output, and the SDA pin to input and set the analog write resolution to 10. I then do an analog write to the DAC0 pin.

That does not sound right.

Please post the complete program.

If you are using I2C then the Wire library looks after the mode of the pins

...R

mwk088:
I would like to see digital signals as a voltage range instead. The device feeding the Arduino board with digital signals is a photosensor that varies as the brightness in the room changes. Instead of digital signals I would like to see the voltage analog equivalent and send that into a laptop audio jack and run it through some software.

I might not be going about what I want in the correct manner.

Are you trying to actually read the room brightness and use it to produce an audio signal? The room brightness normally changes too slowly to produce any sound in the audio range. Also the digital signal cannot be "heard" because it is encoded, and has no simple relationship to the sensor response.

You need to explain the whole system to us in terms of complete inputs and outputs, e.g. "when the room brightness increases, I want [....] to happen. When the brightness decreases, I want [...] to happen".

I ideally this is what I want....say the photo sensor has a lux range of 0.000118 to 88,000...and I would like to have the lux range correspond to a voltage or current out...for example...0 to 5 volts corresponds to 0.000118 to 88,000 lux....thus if I see 2.5 volts on the output pin, that would correspond to somewhere around 44,000 lux.

Why not just take a photo diode, put the cathode to 5V/3.3V, hook the anode to a 1M resistor, and send the other end of the resistor to ground? At the point of photo resistor/resistor connection, that's your analog signal that relates to light brightness detected.

I2C not only sends and receive data but register info and other device instructions. You'd have to receive the data being sent, most likely a library, take the I2C data.... Blah, Blah, blah. A lot of work when you can just read the analog voltage off a photodiode.

Most Arduinos do not have a genuine DAC (pure analog) output. They use PWM to simulate an analog level instead. If you want a "smooth" voltage from it, you need to follow the output with a (usually RC) low pass filter. You are lucky and you have an actual DAC.

In that case, you would do this:

  1. use the appropriate sensor library or custom wire library functions to obtain the lux from the sensor via the sensor's I2C pins

  2. scale and condition the values to fit the range of the analog output.

  3. send the values to the analog output (or DAC) pins via analogWrite().

May I ask, what is the DAC voltage connected to?

aarg:
Most Arduinos do not have a genuine DAC (pure analog) output. They use PWM to simulate an analog level instead. If you want a "smooth" voltage from it, you need to follow the output with a (usually RC) low pass filter. You are lucky and you have an actual DAC.

In that case, you would do this:

  1. use the appropriate sensor library or custom wire library functions to obtain the lux from the sensor via the sensor's I2C pins

  2. scale and condition the values to fit the range of the analog output.

  3. send the values to the analog output (or DAC) pins via analogWrite().

May I ask, what is the DAC voltage connected to?

Thank you for the response.

  1. I have a library function to obtain the lux from the sensor via the sensor's I2C pins
  2. To do this would I scale using like a voltage divider before connecting to the DAC pin of the Arduino?
  3. In the code, would I set the input to the SDA pin, and the output to Pin A0 (DAC), and do a digitalRead on the SDA and an analogWrite to the DAC pin?

Sure, I was planning on hooking the DAC voltage to an audiojack of a laptop for further analysis.

Idahowalker:
Why not just take a photo diode, put the cathode to 5V/3.3V, hook the anode to a 1M resistor, and send the other end of the resistor to ground? At the point of photo resistor/resistor connection, that's your analog signal that relates to light brightness detected.

I2C not only sends and receive data but register info and other device instructions. You'd have to receive the data being sent, most likely a library, take the I2C data.... Blah, Blah, blah. A lot of work when you can just read the analog voltage off a photodiode.

I like that idea, and seems simple enough for me to try it out. I have a simple photoresistor in a box of goodies. I think I could also use the simpler Adafruit photosensors to do the same thing. Thoughts?

I use the photo diode resistor scheme to keep a solar cell pointed at the sun. My thought, works well lasts a long time.

All bets are off until reply #1 is answered.

aarg:
All bets are off until reply #1 is answered.

reply #1?

If you are referencing your 1 of 3 questions. I can already use software to read the photosensor and output the corresponding lux values in a com port.