太阳能级:供电微控制器项目

35,981

2

0.

Introduction: Solar Class: Powering Microcontroller Projects

About: Making and sharing are my two biggest passions! In total I've published hundreds of tutorials about everything from microcontrollers to knitting. I'm a New York City motorcyclist and unrepentant dog mom. My wo…

类目录:

在本课程中,我们正在制作太阳能的土壤水分监测器。它使用ESP8266 WiFi微控制器运行低功耗代码,以及一切都是防水的,所以它可以留在外面。您可以完全遵循此配方,或从中获取您自己项目的有用技术。

If you're new to microcontroller programming, please check out myarduino.Class事物课程陷入布线,编码和连接到互联网的基础知识。

第1步:你需要什么

您需要一个太阳能电池充电板和esp8266突破nodemcu esp8266.或者Huzzh.以及土壤传感器,电池,电源开关,一些电线和外壳,以将电路放入其中。

以下是用于土壤水分监测器的组件和材料:

以下是您需要的工具:

您需要在云数据网站上免费帐户io.adafruit.com.ifttt.

第2步:面包板原型

为像这样的项目创建无焊接面包板原型非常重要,这样您就可以确保您的传感器和代码在制作任何永久连接之前都在工作。

In this case, the soil sensor has stranded wires to it was necessary to temporarily attach solid headers to the ends of the sensor wires using solder, helping hands, and some heat shrink tubing.

遵循电路图以连接传感器的电源,接地,时钟和数据引脚(数据也获得了土壤传感器的10K上拉电阻)。

  • 传感器绿线到GND
  • Sensor red wire to 3.3V
  • 传感器黄线到Nodemcu引脚D5(GPIO 14)
  • 传感器蓝线到Nodemcu引脚D6(GPIO 12)
  • 蓝色数据引脚和3.3V之间的10K上拉电阻

您可以将其转换为您的首选微控制器。如果您使用的是Arduino uno或类似,您的电路板已由Arduino软件支持。如果您使用的是esp8266,请查看我的事物课程有关逐步帮助在Arduino中的ESP8266设置(通过将补充URL添加到Arduino的首选项中的附加电路管理器URL字段中,然后从电路板管理器中搜索和选择新的电路板)。我倾向于使用Adafruit ESP8266 Huzzah板类型来编程Nodemcu ESP8266板,但您还可以安装并使用通用ESP8266板支持。你也需要Silabs USB通信芯片驱动程序(available for Mac/Windows/Linux).

要使用我的Arduino兼容的电路板获取传感器并运行,我下载了sht1x.arduino.Library from Practical Arduino's github page,然后解压缩文件并将库文件夹移动到我的arduino / libraries文件夹,然后重命名它sht1x.。打开示例草图readsht1xvalues.并将引脚数更改为12(DataPin)和14(Clockpin),或在此处复制修改后的草图:

#include  #define datapin 12 // nodemcu pin d6 #define clockpin 14 // nodemcu引脚D5 sht1x sht1x(Datapin,Clockpin);//实例化SHT1x对象void setup(){serial.begin(38400);//打开串行连接,以向主机序列号的值报告值(“启动”);void循环(){float temp_c;float temp_f;浮动湿度;temp_c = sht1x.readtemperaturec();//从传感器temp_f = sht1x.readtemperaturef()的读取值;湿度= sht1x.readhumity();serial.print(“温度:”); // Print the values to the serial port Serial.print(temp_c, DEC); Serial.print("C / "); Serial.print(temp_f, DEC); Serial.print("F. Humidity: "); Serial.print(humidity); Serial.println("%"); delay(2000); }

Upload this code to your board and open up the serial monitor to see the sensor data stream in.

If your code won't compile and complains about SHT1x.h not being found, you haven't got the required sensor library installed properly. Check your Arduino/libraries folder for one calledsht1x.,如果它在其他地方,就像您的下载文件夹一样,将其移动到您的Arduino Libraries文件夹,并根据需要重命名。

如果您的代码编译但不会上传到您的电路板,请仔细检查电路板设置,请确保插入电路板,然后从“工具”菜单中选择正确的端口。

If your code uploads but your serial monitor input is unrecognizable, double check your baud rate matches that specified in your sketch (38400 in this case).

If your serial monitor input doesn't seem correct, double check your wiring against the circuit diagram. Is your 10K pull-up resistor in place between the data pin and 3.3V? Are data and clock connected to the correct pins? Are power and ground connected as they should be throughout the circuit? Do not proceed until this simple sketch is working!

下一步是特定于ESP8266,并配置示例项目的可选无线传感器报告部分。如果您使用的是使用标准(非无线)arduino兼容的微控制器,请继续开发最终的Arduino素描并跳至准备太阳充电板

第3步:软件设置

To compile the code for this lesson's sample project with the ESP8266, you'll need to install a few more Arduino libraries (available through the library manager):

下载附加到此步骤的代码,然后解压缩文件并在Arduino软件中打开Solar_Powered_soil_moisture_monitor_tutorial。

#include  #include  #include  #include  //指定数据和时钟连接和实例化sht1x对象#define datapin 12// nodemcu引脚D6 #define clockpin 14 // nodemcu引脚d5 sht1x sht1x(Datapin,Clockpin);//设置Feed Adafruitio_feed * Humity = Io.Feed(“湿度”);adafruitio_feed *温度= io.feed(“温度”);Const int speptime = 15;// 15分钟
void setup(){serial.begin(115200);//打开串行连接,以向主机序列号的值报告值(“启动”);//连接到io.adafruit.com serial.print(“连接到Adafruit IO”);IO.Connect();//等待连接(IO.Status()
        
void loop(){io.run();// io.run();保留客户端连接,是所有草图所必需的。float temp_c;float temp_f;浮动水分;temp_c = sht1x.readtemperaturec();//从传感器temp_f = sht1x.readtemperaturef()的读取值;湿度= sht1x.readhumity();serial.print(“温度:”); // Print the values to the serial port Serial.print(temp_c, DEC); Serial.print("C / "); Serial.print(temp_f, DEC); Serial.print("F. Humidity: "); Serial.print(moisture); Serial.println("%"); humidity->save(moisture); temperature->save(temp_f); Serial.println("ESP8266 is sleeping..."); ESP.deepSleep(sleepTime * 1000000 * 60); // Sleep }

This code is a mashup of the sensor code from earlier in this lesson and a basic example from the cloud data service Adafruit IO. The program enters low power mode and sleeps most of the time, but wakes up every 15 minutes to read the temperature and humidity of the soil, and reports its data to Adafruit IO. Navigate to the config.h tab and fill in your Adafruit IO username and key, as well as your local wifi network name and password, then upload the code to your ESP8266 microcontroller.

You'll have to do a bit of prep onio.adafruit.com.。在为温度和湿度创建饲料后,您可以为显示器创建一个仪表板,其中包含传感器值的图表和传入的馈送数据。如果您需要进入Adafruit IO的进入,请退房在我的互联网上课上课的课程

第4步:准备太阳能充电板

通过在其电容器上焊接以及向负载输出焊盘上的一些电线准备太阳充电板。我正在通过可选的附加电阻(在PROG焊接)的可选附加电阻以更快的速度来充电,使其更快地充电,并使用连接到电池本身的10K热敏电阻,更安全,无人看管。这将限制充电以安全的温度范围。我们更详细地介绍了这些修改上一课

第5步:构建微控制器电路

将微控制器板和电源开关焊接到PERMA-PROLO板上。

将太阳能充电器电源输出连接到开关的输入,应额定至少1放大器。

创建和焊接在上面的电路图中描述的面包板线连接(或您的个人版本的规格),包括传感器数据线上的10K上拉电阻。

The solar charger'sLoadpins will provide 3.7V battery power when no solar power exists, but will be powered directly from the solar panel if it's plugged in and sunny. Therefore the microcontroller must be able to tolerate a variety of voltages, as low as 3.7V and up to 6V DC. For those requiring 5V, a PowerBoost (500 or 1000, depending on the current required) can be used to modulate theLoad电压为5V(如图所示)上一课)。以下是一些公共板及其输入电压范围:

  • Nodemcu ESP8266(用于本课程):5V USB或3.7V-10V VIN
  • Arduino UNO:5V USB或7-12V VIN
  • Adafruit Huzzah ESP8266突破:5V USB或3.4-6V VBAT

为了达到最长可能电池life, you should take some time to consider and optimize the total current your current draws. The ESP8266 has a deep sleep feature which we used in the Arduino sketch to reduce its power consumption dramatically. It wakes up to read the sensor and draws more current while it connects to the network to report the sensor's value, then goes back to sleep for a specified amount of time. If your microcontroller draws a lot of power and can't easily be made to sleep, consider porting your project to a compatible board that draws less power. Drop a question in the Q&A section below if you need help identifying which board could be right for your project.

第6步:安装电缆腺体

为太阳能电池板和传感器电缆进行防风雨的入口点,我们将在防风雨外壳的一侧安装两个电缆腺体。

测试适合您的组件以识别理想的放置,然后使用a的防水外壳中标记和钻孔step drill。安装两个电缆腺体。

步骤7:完整的电路组件

将防水电缆的端口侧插入一个并将其焊接到太阳能充电器的直流输入(红色到+和黑色)。

通过另一个压盖将土壤传感器插入,并根据电路图将其连接到PERMA-PROLO。

将热敏电阻探头胶带到电池。这将限制在安全温度范围内限制,而项目留在外面的情况下。

Charging while too hot or too cold could damage the battery or start a fire. Exposure to extreme temperatures can cause damage and shorten the battery's life, so bring it inside if it's below freezing or above 45℃/113F.

Tighten the cable glands to make a weatherproof seal around their respective cables.

第8步:准备太阳能电池板

按照的说明太阳能电池板课拼接电缆适用于带有防水直流电源线组的插头侧的太阳能电池板。

第9步:测试它

通过按电源开关插入电池并打开电路。

测试它并确保它在关闭外壳之前向互联网报告并在您的WiFi网络中的信号范围内安装珍贵的盆栽植物或其他土壤中的传感器。

Once the data from the sensor is being logged online, it’s easy to set up a recipe for email or text alerts on the API gateway site If This Then That. I configured mine to email me if the soil moisture level drops below 50.

To test it without waiting for my plant to dry out, I manually entered a data point to my humidity feed on Adafruit IO that fell below the threshold. A few moments later, the email arrives! If the soil's levels fall below my specified level, I'll get an email every time the feed is updated until I water the soil. For my sanity, I updated my code to sample the soil much less often than every 15 minutes.

第10步:在外面使用它!

这是一个根据您的工厂的水合需求定制的有趣项目,并且易于换掉或添加传感器或将太阳能功能集成到您的其他Arduino项目中。

非常感谢您注册我的太阳级!我很乐意看到您在下面的甲上型部分中构建的任何太阳能项目,并听取您的反馈。如果你喜欢这堂课,你也可以享受:

类目录:

3 People Made This Project!

建议书

  • Sticky Stuff Speed Challenge

    Sticky Stuff Speed Challenge
  • Toys & Games Contest

    Toys & Games Contest
  • Furniture Contest

    Furniture Contest

注释