Send correct data to SC

Hi there,

I have a sensor that reads the light. the sensor is connected to Analog 1.

in Serial Monitor when I print the "light level" I get values from 0 to ~5 as the datasheet refers.

But when I load standar firmata and I connected with sc I get other values 0 - ~632 in SC

why this is happening?

how it is possible to receive the actual values in SC that my arduino sketch reads?

Strange... can you post your sketch?

here is the arduino code:

#include <Wire.h> //I2C needed for sensors

//Pin definitions

// digital I/O pins

const byte STAT1 = 7;
const byte STAT2 = 8;

// analog I/O pins

const byte LIGHT = A1;

const byte REFERENCE_3V3 = A3;

//=-=-=-=-=-=-=-=-=-=-= Global Variables =-=-=-=-=-=-=-=-=-=-=\\

long lastSecond; //The millis counter to see when a second rolls by
byte seconds; //When it hits 60, increase the current minute
float light_lvl = 455; //[analog value from 0 to 1023]

void setup() {

  Serial.println("Weather Shield Example");

  pinMode(STAT1, OUTPUT); //Status LED Blue
  pinMode(STAT2, OUTPUT); //Status LED Green

  pinMode(LIGHT, INPUT);

  seconds = 0;
  lastSecond = millis();

  // attach external interrupt pins to IRQ functions

  // turn on interrupts

  Serial.println("Weather Station online! :)");


void loop() {

  //Keep track of which minute it is
  if(millis() - lastSecond >= 1000)
    digitalWrite(STAT1, HIGH); //Blink stat LED

    lastSecond += 1000;

    //Calc the wind speed and direction every second for 120 second to get 2 minute average


    digitalWrite(STAT1, LOW); //Turn off stat LED


//light function 

void calcWeather() {
  //Get light level
  light_lvl = get_light_level();
  Serial.print(" | Light level = ");
  Serial.println(light_lvl, 2);


//Read the light level

float get_light_level()
  float operatingVoltage = analogRead(REFERENCE_3V3);

  float lightSensor = analogRead(LIGHT);

  operatingVoltage = 3.3 / operatingVoltage; //The reference voltage is 3.3V

  lightSensor = operatingVoltage * lightSensor;


And here is the SC code



// Connect with arduino 
	~connectArduino = Routine{
		~arduino ="/dev/tty.usbmodem1421", 9600);
		"The Firmata firmware version on this Arduino board is: ".post;

//activate the analog pin

~arduinoLoop = {loop {

Arduino serial monitors reads 0 to 3.3 because the light sensor is based on the 3.3V rail
In Supercollider I am reading from Analog 1 but I get values from 0 to ~632

As the Arduino multiplexes the analogReads they affect each other. Could be a cause One way to handle this is to do multiple reads and throw away the first one.

float get_light_level()
  analogRead(REFERENCE_3V3);  // dummy read
  float operatingVoltage = analogRead(REFERENCE_3V3);

  analogRead(LIGHT); // dummy read
  return analogRead(LIGHT) * 3.3 / operatingVoltage;

632 / 3.3 * 5.0 = 957 ( comes close to 1023) could that be a cause?

632 just being the max value for 3.3 volt