1、arduino代码如下:
可直接进行串口打印或者oled显示(spi)
#include <SPI.h>
#include <Wire.h>
#include <math.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <MsTimer2.h>
#include "TSL2581.h"
//---------------------------TDS-----------------------------------
#include <OneWire.h>
#include <DallasTemperature.h>
//-----------------------------------------------------------------
#include <SoftwareSerial.h> //开启软串口
SoftwareSerial mySerial(2 , 3); //第2= RX,第3= TX //开启软串口
WaveShare_TSL2581 tsl = WaveShare_TSL2581();
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
#define NUMFLAKES 10 // Number of snowflakes in the animation example
#define Blank_KEY 7
#define Dark_KEY_INT 1
#define LED_Control 8
//************************* User Defined Variables for TDS********************************************************//
//##################################################################################
//----------- Do not Replace R1 with a resistor lower than 300 ohms ------------
//##################################################################################
int R1= 1000;
int Ra=25; //Resistance of powering Pins
int ECPin= A0;
int ECGround=A1;
int ECPower =A3;
//*********** Converting to ppm [Learn to use EC it is much better**************//
// Hana [USA] PPMconverion: 0.5
// Eutech [EU] PPMconversion: 0.64
//Tranchen [Australia] PPMconversion: 0.7
// Why didnt anyone standardise this?
float PPMconversion=0.7;
//*************Compensating for temperature ************************************//
//The value below will change depending on what chemical solution we are measuring
//0.019 is generaly considered the standard for plant nutrients [google "Temperature compensation EC" for more info
float