Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
34 changes: 34 additions & 0 deletions anemometer/anemometer_readings/anemometer_readings.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Anemometer calibration values
const float anemometer_min_volts = 0.4;
const float anemometer_max_volts = 2.0;
const float min_wind_speed = 0.0;
const float max_wind_speed = 50;

// ADC input pin
const int adcPin = A0; //use A0 or whatever analog pin you are using

// Teensy 4.0 default analog reference is 3.3V (don't need to set analogReference)

void setup() {
Serial.begin(9600); //standard baud rate
}

void loop() {
int adcVal = analogRead(adcPin); // 10-bit ADC, returns 0-1023
float voltage = adcVal / 1023.0 * 3.3;
float wind_speed = mapFloat(voltage, anemometer_min_volts, anemometer_max_volts, min_wind_speed, max_wind_speed);

Serial.print("Voltage: ");
Serial.print(voltage);
Serial.print(" V, Wind Speed: ");
Serial.print(wind_speed);
Serial.println(" m/s");

delay(50);
}

// Custom map function for floats
float mapFloat(float x, float in_min ,float in_max, float out_min, float out_max){
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

72 changes: 72 additions & 0 deletions hallEffectSensor/current_sensor/current_sensor.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const float VCC = 5.0;// supply voltage 5V or 3.3V. If using PCB, set to 5V only.
const int model = 0; // enter the model (see below)

float cutOffLimit = 1.00;// reading cutt off current. 1.00 is 1 Amper

/*
"ACS758LCB-050B",// for model use 0
"ACS758LCB-050U",// for model use 1
"ACS758LCB-100B",// for model use 2
"ACS758LCB-100U",// for model use 3
"ACS758KCB-150B",// for model use 4
"ACS758KCB-150U",// for model use 5
"ACS758ECB-200B",// for model use 6
"ACS758ECB-200U"// for model use 7
sensitivity array is holding the sensitivy of the ACS758
current sensors. Do not change.
*/
float sensitivity[] ={
40.0,// for ACS758LCB-050B
60.0,// for ACS758LCB-050U
20.0,// for ACS758LCB-100B
40.0,// for ACS758LCB-100U
13.3,// for ACS758KCB-150B
16.7,// for ACS758KCB-150U
10.0,// for ACS758ECB-200B
20.0,// for ACS758ECB-200U
};

/*
* quiescent Output voltage is factor for VCC that appears at output
* when the current is zero.
* for Bidirectional sensor it is 0.5 x VCC
* for Unidirectional sensor it is 0.12 x VCC
* for model ACS758LCB-050B, the B at the end represents Bidirectional (polarity doesn't matter)
* for model ACS758LCB-100U, the U at the end represents Unidirectional (polarity must match)
* Do not change.
*/
float quiescent_Output_voltage [] ={
0.5,// for ACS758LCB-050B
0.12,// for ACS758LCB-050U
0.5,// for ACS758LCB-100B
0.12,// for ACS758LCB-100U
0.5,// for ACS758KCB-150B
0.12,// for ACS758KCB-150U
0.5,// for ACS758ECB-200B
0.12,// for ACS758ECB-200U
};
const float FACTOR = sensitivity[model]/1000;// set sensitivity for selected model
const float QOV = quiescent_Output_voltage [model] * VCC;// set quiescent Output voltage for selected model
float voltage;// internal variable for voltage
float cutOff = FACTOR/cutOffLimit;// convert current cut off to mV

void setup() {
Serial.begin(9600);// initialize serial monitor
}

void loop() {
float voltage_raw = (5.0 / 1023.0)* analogRead(VIN);// Read the voltage from sensor
voltage = voltage_raw - QOV + 0.007 ;// 0.007 is a value to make voltage zero when there is no current
float current = voltage / FACTOR;
if(abs(voltage) > cutOff ){
Serial.print("V: ");
Serial.print(voltage,3);// print voltage with 3 decimal places
Serial.print("V, I: ");
Serial.print(current,2); // print the current with 2 decimal places
Serial.println("A");
}else{
Serial.println("No Current");
}
delay(500);
}