reiniervdl / vinduino Goto Github PK
View Code? Open in Web Editor NEWVinduino is an open license project for agricultural irrigation management
License: GNU General Public License v3.0
Vinduino is an open license project for agricultural irrigation management
License: GNU General Public License v3.0
Hi, i try works your source code: Vinduino-H_V3.1.ino with only one watermark connect to Arduino M0. But it doesn't work. I see the signal in the oscilloscope, but the code no changes values
And this mi code:
#include <math.h>
#define NUM_READS 11 // Number of sensor reads for filtering
typedef struct { // Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
int moisture;
long resistance;
double tension;
} values;
const long knownResistor = 4700; // Constant value of known resistor in Ohms
int activeDigitalPin = 11; // 6 or 7 interchangeably
int supplyVoltageAnalogPin; // 6-ON: A0, 7-ON: A1
int sensorVoltageAnalogPin; // 6-ON: A1, 7-ON: A0
int supplyVoltage; // Measured supply voltage
int sensorVoltage; // Measured sensor voltage
values valueOf[NUM_READS]; // Calculated moisture percentages and resistances to be sorted and filtered
int i; // Simple index variable
void setup() {
// initialize serial communications at 9600 bps:
SerialUSB.begin(9600);
analogReadResolution(12);
// initialize the digital pin as an output.
// Pin 6 is sense resistor voltage supply 1
pinMode(11, OUTPUT);
// initialize the digital pin as an output.
// Pin 7 is sense resistor voltage supply 2
pinMode(13, OUTPUT);
}
void loop() {
bemoticCore.ON_SENS();
for (i=0; i<NUM_READS; i++) {
setupCurrentPath(); // Prepare the digital and analog pin values
// Read 1 pair of voltage values
digitalWrite(activeDigitalPin, HIGH); // set the voltage supply on
delay(10);
supplyVoltage = analogRead(supplyVoltageAnalogPin); // read the supply voltage
SerialUSB.print("SV:");
SerialUSB.println(supplyVoltage);
sensorVoltage = analogRead(sensorVoltageAnalogPin); // read the sensor voltage
SerialUSB.print("SV:");
SerialUSB.println(sensorVoltage);
digitalWrite(activeDigitalPin, LOW); // set the voltage supply off
delay(10);
// Calculate resistance and moisture percentage without overshooting 100
// the 0.5 add-term is used to round to the nearest integer
// Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
valueOf[i].resistance = long( float(knownResistor) * ( supplyVoltage - sensorVoltage ) / sensorVoltage + 0.5 );
valueOf[i].moisture = min( int( pow( valueOf[i].resistance/31.65 , 1.0/-1.695 ) * 400 + 0.5 ) , 100 );
// valueOf[i].tension = round( -20 * (double(valueOf[i].resistance)/1000) * ( 1 - 0.55)); // Watermark 0 < 1 kOhm
valueOf[i].tension = round( ( -3.213 * (double(valueOf[i].resistance)/1000) - 4.093) / ( 1 - 0.009733 * (double(valueOf[i].resistance)/1000) - 0.01205*24)); // Watermark 1 < 8 kOhm
// valueOf[i].tension = round(-2.246 - (5.239 * (double(valueOf[i].resistance)/1000)) - 0.06756 * pow(valueOf[i].resistance/1000,2)); // Watermark > 8 kOhm
// valueOf[i].moisture = min( int( pow( valueOf[i].resistance/331.55 , 1.0/-1.695 ) * 100 + 0.5 ) , 100 );
}
sortMoistures();
// Print out median values
SerialUSB.print("SV: ");
SerialUSB.println(supplyVoltage);
SerialUSB.print("Se: ");
SerialUSB.println(sensorVoltage);
SerialUSB.print("Resistencia Sensor: ");
SerialUSB.println(valueOf[NUM_READS/2].resistance);
SerialUSB.print("Moisture Sensor: ");
SerialUSB.println(valueOf[NUM_READS/2].moisture);
SerialUSB.print("Tension Sensor: ");
SerialUSB.print(valueOf[NUM_READS/2].tension);
SerialUSB.println(" kPa");
delay(3000);
}
void setupCurrentPath() {
if ( activeDigitalPin == 11 ) {
activeDigitalPin = 13;
supplyVoltageAnalogPin = A2;
sensorVoltageAnalogPin = A0;
}
else {
activeDigitalPin = 11;
supplyVoltageAnalogPin = A0;
sensorVoltageAnalogPin = A2;
}
}
// Selection sort algorithm
void sortMoistures() {
int j;
values temp;
for(i=0; i<NUM_READS-1; i++)
for(j=i+1; j<NUM_READS; j++)
if ( valueOf[i].moisture > valueOf[j].moisture ) {
temp = valueOf[i];
valueOf[i] = valueOf[j];
valueOf[j] = temp;
}
}
I'm using the Vinduino R3 with the 2nd LM-210 wired into the Raspberry Pi. After a random amount of time (minutes but rairly to hours) the USB serial crashes out and forces a reboot/re-plug of the usb ftdi in order to work again. Easiest way to see this error is through:
dmesg -T
with the result:
Nov 4 14:23:13 localhost kernel: [11761.350820] ftdi_sio ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
(Note: this was not my exact error, but was close enough and how I found my solution.)
Solution:https://github.com/raspberrypi/linux/issues/1187
You could try the nuclear option - add dwc_otg.speed=1 to /boot/cmdline.txt - this forces the entire bus to USB1.1 speeds. If you still get disconnects after that, then it's probably safe to say that the Pi isn't the issue.
This fixed my issue, though it seems a bit inelegant. I don't need any high speed USB devices on the pi, so it seems effective.
No real question here, just posting for posterity. Perhaps best in a Wiki format, but didn't see any other wiki pages. If a more elegant solution exists, I'd be willing to try it.
Hi Reinier,
In the arduino sketches, you #include "LowPower.h" that isn't in the tree.
Is this from https://github.com/rocketscream/Low-Power, described in http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/ ?
I cant seem to see a BOM list for the parts used on the R3
can you point me in the right direction please :-)
Hello, I notice Vinduino is up to Version R5
is there any chance that any further version from R3 going to be made open source?
Sample code inludes a library LowPower.h but I can't find any libraries that match that name.
H:\Outbox\Vinduino-20180719T042419Z-001\Vinduino\Vinduino-R3_Wifi\VR3-WiFi-sample_code\Vinduino-R_Wifi_V1.0.ino:20:49: fatal error: LowPower.h: No such file or directory
#include "LowPower.h" // Needed for sleep mode
^
compilation terminated.
exit status 1
Error compiling for board Arduino Pro or Pro Mini.
I'm using Vinduino-H_V3.1 code, soil moisture always shows zero for WET and DRY and resistance is always NEGATIVE I done connection according picture attached, but I'm using 4700 ohm resistance help me what I'm doing wrong, I have attached images of connection and readings, first reading image is of wet and second is for dry.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.